Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!--<script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script>-->
<main id="root">
</main>
              
            
!

CSS

              
                main {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(18, 27, 37);
  overflow: auto;
}

#tweet-quote .fab {
  color: rgba(255, 255, 255, 1);
  &:hover {
    color: rgba(255, 255, 255, 0.8);
  }
}
              
            
!

JS

              
                const quotes = [
  {body: 'If you cannot do great things, do small things in a great way.', author: 'Napoleon Hill'},
  {body: 'Permanence, perseverance and persistence in spite of all obstacles, discouragements, and impossibilities: It is this, that in all things distinguishes the strong soul from the weak.', author: 'Thomas Carlyle'},
  {body: 'The supreme art of war is to subdue the enemy without fighting.', author: 'Sun Tzu'},
  {body: 'Keep your face always toward the sunshine - and shadows will fall behind you.', author: 'Walt Whitman'},
  {body: 'Being entirely honest with oneself is a good exercise.', author: 'Sigmund Freud'},
  {body: 'Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better.', author: 'Samuel Beckett'},
  {body: 'Not all those who wander are lost.', author: 'J. R. R. Tolkien'},
  {body: 'I have not failed. I\'ve just found 10,000 ways that won\'t work.', author: 'Thomas A. Edison'},
  {body: 'Tell me and I forget. Teach me and I remember. Involve me and I learn.', author: 'Benjamin Franklin'},
  {body: 'A leader is one who knows the way, goes the way, and shows the way.', author: 'John C. Maxwell'},
  {body: 'Very little is needed to make a happy life - it is all within yourself, in your way of thinking.', author: 'Marcus Aurelius'},
  {body: 'If opportunity doesn\'t knock, build a door.', author: 'Milton Berle'},
  {body: 'The secret of getting ahead is getting started.', author: 'Mark Twain'},
  {body: 'Problems are not stop signs, they are guidelines.', author: 'Robert H. Schuller'},
  {body: 'Life is not a problem to be solved, but a reality to be experienced.', author: 'Soren Kierkegaard'},
  {body: 'Life isn\'t about finding yourself. Life is about creating yourself.', author: 'George Bernard Shaw'},
  {body: 'The only true wisdom is in knowing you know nothing.', author: 'Socrates'},
  {body: 'The pessimist complains about the wind - the optimist expects it to change - the realist adjusts the sails.', author: 'William Arthur Ward'},
  {body: 'In three words I can sum up everything I\'ve learned about life: it goes on.', author: 'Robert Frost'},
  {body: 'Blessed are the hearts that can bend - they shall never be broken.', author: 'Albert Camus'},
  {body: 'Success is not final, failure is not fatal: it is the courage to continue that counts.', author: 'Winston Churchill'},
  {body: 'Do not go where the path may lead, go instead where there is no path and leave a trail.', author: 'Ralph Waldo Emerson'},
  {body: 'Do not dwell in the past, do not dream of the future, concentrate the mind on the present moment.', author: 'Buddha'},
  {body: 'Don\'t judge each day by the harvest you reap but by the seeds that you plant.', author: 'Robert Louis Stevenson'},
  {body: 'Find a place inside where there\'s joy, and the joy will burn out the pain.', author: 'Joseph Campbell'},
  {body: 'Try to be a rainbow in someone\'s cloud.', author: 'Maya Angelou'},
  {body: 'It is during our darkest moments that we must focus to see the light.', author: 'Aristotle'},
  {body: 'Good, better, best. Never let it rest. \'Til your good is better and your better is best.', author: 'St. Jerome'},
];

const { Card, Button } = ReactBootstrap;


const Content = ({ body, author }) => {
  return (
    <blockquote className="blockquote">
      <p id="text" className="text-justify">{body}</p>
      <footer id="author" className="blockquote-footer text-right">{author}</footer>
    </blockquote>
  );
}

const NextQuote = ({ action, title }) => {
  return (
    <Button variant="outline-light" id="new-quote" onClick={action}>{title}</Button>
  );
}

const TwitterLink = ({ body, author }) => {
  return (
    <a 
      id="tweet-quote" 
      href={`https://www.twitter.com/intent/tweet?text=${body} – ${author}`} 
      target="_blank">
      <span>
        <i className="fab fa-twitter-square fa-3x"/>
      </span>
    </a>
  );
}

class QuoteMachine extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      quoteIndex: this.getRandomQuoteId(quotes)
    }
  }
  
  getRandomQuote = () => {
    this.setState({
      quoteIndex: this.getRandomQuoteId()
    });
  }
  
  getRandomQuoteId = () => {
    return Math.floor(Math.random() * quotes.length);
  }
  
  render () {
    const { quoteIndex } = this.state;
    const quote = quotes[quoteIndex];
    
    return (
      <Card id="quote-box" bg="dark" text="white" style={{ width: '36rem' }}>
        <Card.Body>
          <Content body={quote.body} author={quote.author} />
          <NextQuote id="new-quote" title="New Quote" action={this.getRandomQuote} />
        </Card.Body>
        <Card.Footer className="text-center">
          <TwitterLink body={quote.body} author={quote.author} />
        </Card.Footer>
      </Card>
    );
  }
};

ReactDOM.render(<QuoteMachine />, document.getElementById('root'));


              
            
!
999px

Console