css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <!-- This is 99% visually inspired by the design of the Random Quote Machine by Gabriel "hezag" Nunes. I really liked the visual design of it. I also used the same database for quotes and colors. Everything else, code-wise, is mine. -->

<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.2/css/all.css" integrity="sha384-/rXc/GQVaYpyDdyxK+ecHPVYJSN9bmVFBvjA/9eOB+pb3F2w2N6fc5qB9Ew5yIns" crossorigin="anonymous">

<div id="app" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react-dom.min.js"></script>

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

              * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;

#wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  transition: 2s;

#quote-box {
  font-family: 'Raleway', sans-serif;
  background: #fff;
  width: 700px;
  border: none;
  border-radius: 3px;
  display: table;
  padding: 40px 50px;
  box-shadow: 0px 0px 100px;

#text {
  font-size: 1.75em;
  text-align: center;
  margin: 30px;

.fa-quote-left {
  margin-right: 10px;

.fa-quote-right {
  margin-left: 10px;

#author {
  text-align: right;
  font-size: 1.25em;

.button {
  height: 45px;
  color: #fff;
  margin-top: 20px;
  padding: 20px;
  border: none;
  border-radius: 3px;
  padding: 0px 20px;
  cursor: pointer;
  font-size: 1em;
  transition: 1s;

.button:hover {
  opacity: 0.9;

#tweet-quote {
  float: left;
  width: 50px;
  font-size: 1.4em;
  padding: 10px 0px 0px 15px;  

#new-quote {
  float: right;

class App extends React.Component {
  constructor(props) {
    this.state = {
      text: "",
      author: "",
      style: {},
      quotesData: {},
      colors: ['#16a085', '#27ae60', '#2c3e50', '#f39c12', '#e74c3c', '#9b59b6', '#FB6964', '#342224', '#472E32', '#BDBB99', '#77B1A9', '#73A857']
    } //This array of colors was copied from hezag to save time.
    this.getQuotes = this.getQuotes.bind(this);
    this.getQuote = this.getQuote.bind(this);
    this.handleNewQuote = this.handleNewQuote.bind(this);
    this.changeColor = this.changeColor.bind(this);
  componentDidMount() {
  getQuotes() {
       .then( response => {
       if (response.ok) {
         return response;
       } else {
         let errorMessage = "${response.status(${response.statusText})", error = new Error(errorMessage);
       .then( response => response.json() )
       .then( data => {
         { quotesData: data }
  getQuote() {
    //console.log("Starting getQuote");
    let randomQuote = this.state.quotesData.quotes[Math.floor(Math.random() * this.state.quotesData.quotes.length)];
    //console.log("Finished initializing randomQuote");
        text: randomQuote.quote,
        author: randomQuote.author
  changeColor() {
    let randomColor = this.state.colors[Math.floor(Math.random() * this.state.colors.length)];
        style: {...this.state.style, backgroundColor: randomColor}
  handleNewQuote() {
  render() {
    return (
      <div id="wrapper" style={this.state.style}>
        <div id="quote-box">
          <QuoteText text={this.state.text} />
          <QuoteAuthor author={this.state.author} />
          <div id="buttons">
            <NewQuote style={this.state.style} onClick={this.handleNewQuote} />
            <TweetQuote style={this.state.style} text={this.state.text} author={this.state.author} />            
} // ends class App

const QuoteText = (props) => {
  return (
    <div id="text">
      <i className="fa fa-quote-left"></i>
      <i className="fa fa-quote-right"></i>

const QuoteAuthor = (props) => {
  return (
    <div id="author">
      - {props.author}

const NewQuote = (props) => {
  return (
    <button id="new-quote" className="button" style={props.style} onClick={props.onClick}>New Quote</button>

const TweetQuote = (props) => {
  //let test = encodeURIComponent(props.text);
  //console.log("test: " + test);
  //let tweetURL = "hello" + "this is me" + encodeURIComponent({props.text});
  let tweetURL = 'https://twitter.com/intent/tweet?hashtags=quotes&text="' + encodeURIComponent(props.text) + '" - ' + encodeURIComponent(props.author);
  return (
    <a id="tweet-quote" className="button" style={props.style} href={tweetURL} target="_blank" rel="noopener noreferrer">
      <i className="fab fa-twitter"></i>

ReactDOM.render(<App />, document.getElementById("app"));

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................