Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <div id = "root"></div>
              
            
!

CSS

              
                * {
  box-sizing: border-box;
}
body{
  width: 100%;
  height: 100vh;
}
              
            
!

JS

              
                const back = {
  backgroundColor: "#ee8a8a",
  color: "#ee8a8a",
   width: "100%",
  height: "100vh", 
  display: "flex",
  flexDirection: "column",
  justifyContent: "center",
  alignItems: "center" 
};
const box = {
  padding: 40,
  backgroundColor: "white",
  width: 450,
  display: "table",
  
};
const header = {
  textAlign: "center",
  fontSize: "1.75em",
  fontWeight: 500
};
const auth = {
  textAlign: "end"
}
const butt = {
  float: "right",
  backgroundColor: "#ee8a8a",
  border: "none",
  borderRadius: 6,
  padding: 10,
  color: "white"
};
const ref = {
  float: "left",
  backgroundColor: "#ee8a8a",
  width: 40,
  height: 40,
  paddingTop: 9,
  textAlign: "center",
  borderRadius: 8,
  fontSize: "1.2em"
};
const i = {
  color: "white",
  fontSize: 18
};

class Quote extends React.Component{
  constructor(props){
    super(props)
    this.state = {
      randomIndex: 0
    };
    this.randomSet = this.randomSet.bind(this);
  }
  randomSet(){
    this.setState ({
      randomIndex: Math.floor(Math.random() * 8)
    })
  }

   render() {
     const Quotes = [
       "If people knew how hard I worked to get my mastery, it wouldn't seem so wonderful after all.",
       "Do the best you can until you know better. Then when you know better, do better.",
       "Success is no accident. It is hard work, perseverance, learning, studying, sacrifice and most of all, love of what you are doing or learning to do.",
       "I do not know anyone who has got to the top without hard work. That is the recipe. It will not always get you to the top, but should get you pretty near." ,
       "Hard work spotlights the character of people: some turn up their sleeves, some turn up their noses, and some don’t turn up at all." ,
       "The only thing standing between you and outrageous success is continuous progress you need discipline." ,
       "Talent is cheaper than table salt. What separates the talented individual from the successful one is a lot of hard work.",
       "Hard work is a prison sentence only if it does not have meaning. Once it does, it becomes the kind of thing that makes you grab your wife around the waist and dance a jig." 
            ];
     
     const Authors = [
       "-Michelangelo",
       "-Maya Angelou",
       "-Pele",
       "-Margaret Thatcher",
       "- Sam Ewing",
       "- Dan Waldschmidt",
       "-Stephen King",
       "-Malcolm Gladwell"       
     ];
     const randomQuote = Quotes[this.state.randomIndex];
     const randomAuthor = Authors[this.state.randomIndex]; 
           
     return (
       <div style = {back} id = "background">
       <div style = {box} id = "quote-box">
         <h1 style = {header} id ="text"><i className="fa-solid fa-quote-left"></i> {randomQuote}</h1>
         <p style = {auth} id = "author">{randomAuthor}</p>
         <a target = "_blank" style = {ref} href="twitter.com/intent/tweet" id = "tweet-quote"><i style = {i} className="fa-brands fa-twitter"></i></a>
         <button style = {butt} id = "new-quote" onClick = {this.randomSet}>New Quote</button>
       </div>
         </div>
     );
   }
 };

ReactDOM.render(<Quote/>, document.getElementById('root'))
              
            
!
999px

Console