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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
    <meta charset="utf-8">
    <title>Quote Machine</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script>
    <link rel="stylesheet" type="text/css" href="index.css">
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css" integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous">
</head>
    <body>
        <div id="root"></div>
    </body>
</html>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Raleway|Lato:400,700');

body {
    display: flex;
    margin: 0;
    font-family: 'Lato', sans-serif;
    overflow: hidden;
}

#root{
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-content: center;
    width: 100vw;
    height: 100vh;
    background: url('https://i.ibb.co/ZTZg8D7/apple-clean-containers-205316-1.jpg') no-repeat center center fixed;
    background-size: cover;
}

#quote-box {
    width: 34vw;
    height: max-content;
    margin: 0 auto;
    text-align: justify;
}

#text {
    font-family: 'Raleway', sans-serif;
    font-size: 1.4em;
    padding: 1vh 1vw;
}

#author {
    font-style: italic;
    font-size: 1.3em;
    margin: 0 2vw;
    text-align: right;
}

#new-quote, .tweet-quote {
    margin: 2vh 1vw;
    font-size: 1.1em;
    float: right;
}

.twitter-share-button {
    text-decoration: none;
    color: #23A4FF;
}

@media screen and (max-width: 1200px) and (min-width: 640px) {
    #text {
        font-size: 1em;
    }

    #author {
        font-size: .8em;
    }

    #new-quote, .tweet-quote {
        font-size: .7em;
    }
}

@media screen and (max-height: 355px){
  #text {
        font-size: .6em;
  }
}

@media screen and (max-width: 639px){
    body {
        background-color: #FF5652;

    }
    #root {
        background-image: none;

    }
    #quote-box {
        width: 80vw;
        height: max-content;
        margin: 0 auto;
        box-shadow: 2px 2px 5px dimgray;
        background-color: white;
        padding: 5vh 5vw;
    }
    #text {
        font-size: 1.3em;
    }

    #author {
        font-size: 1.2em;
    }
}

              
            
!

JS

              
                //https://github.com/SviatlanKa/Quote-Machine

let { Component } = React;

class App extends Component {
    constructor(props){
        super(props);
        this.state = {
            quote: '',
            author: ''
        };
    }

    getQuote() { 
      fetch('https://cors-anywhere.herokuapp.com/http://quotes.stormconsultancy.co.uk/random.json', {method: 'GET'}).then(response => response.json()).then(json => {
              const { quote, author } = json;
              this.setState({ quote, author });
            })
        console.log('state', this.state);
    }
    componentDidMount() {
      this.getQuote();
    }

    render() {
        return (
            <div id="quote-box">
                <Quote
                    quote={this.state.quote}
                    author={this.state.author}
                />
                <button
                    id="new-quote"
                    onClick={() => this.getQuote()}
                >
                    New Quote
                </button>
                <button className="tweet-quote">
                    <a
                       className="twitter-share-button"
                       href={"https://twitter.com/intent/tweet?hashtags=quotes&text="
                       + this.state.quote + " " + this.state.author}
                      id="tweet-quote" 
                      ><i className="fab fa-twitter"></i> Tweet
                    </a>
                </button>
            </div>
        );
    }
}

class Quote extends Component {
    render() {
        return (
            <div>
                <div id="text">{this.props.quote}</div>
                <div id="author">{this.props.author}</div>
            </div>
        )
    }
}


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

              
            
!
999px

Console