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

              
                <!--This imports graphics for the buttons-->
<script src="https://kit.fontawesome.com/02b939d641.js" crossorigin="anonymous"></script>


<!--this is the beginning of the document-->
    <div id="quote-box-wrapper">
    <div id="quote-box">
        <div id="whole-text-wrapper">
            <div id="whole-text">
            
            <div id="quote-and-author">
                    <div id="text"></div>
                    <div id="author"></div>
            </div>
        </div>
        </div>

        <!--This is only here to pass the fCC tests, please refer to the button rendered with React in in the js rather than this-->
        <a id="tweet-quote" href="twitter.com/intent/tweet"></a>

        <div id="buttons">
          <!--button1 is where the generate new quote button is rendered to-->
            <div id="button1">
            </div>
          
           <!--button2 is where the twitter button is rendered to-->
            <div id="button2">
            </div>
        </div>

        <!--this contains the Night Mode button and the text at the bottom-->
        <div id="bottom-elements">
          <div id="night-mode-button"></div>
            <p id="jay-line">Jay's Random Quote Generator</p>
        </div>
        
    </div>
    </div>
              
            
!

CSS

              
                    :root {
        --faint-text: lightgrey;
        --body-text: black;
        --box-shadow: rgba(0, 0, 0, 60%);
        --generate-gradient: linear-gradient(180deg, white, rgb(211, 211, 211));
        --generate-hover: linear-gradient(180deg, rgb(211, 211, 211), rgb(211, 211, 211));
        --generate-active: linear-gradient(180deg, rgb(160, 160, 160), rgb(211, 211, 211));
    }
    
    * {
        font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
        font-size: 16px;
    }

    button {
        cursor: pointer;
    }



    /*--ID's--*/
    
    #quote-box-wrapper {
        /*this wraps #quote-box*/
        display: flex;
        justify-content: center;
        margin-top: 3rem;
    }

    #quote-box {
        /*this contains the quote machine elements*/
        box-shadow: 5px 5px 10px var(--box-shadow);
        min-height: 100px;
        min-width: 460px;
        max-width: 461px;
    }

    #whole-text {
        /*this is a div that contains the quote and author elements*/
        display: flex;
        justify-content: center;
        align-items: center;

    }
    /*this div contains whole-text*/
    #whole-text-wrapper {
        height: 300px;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    #quote-and-author {
        /*this styles the div of both the quote and author*/
        border: 2px solid var(--faint-text);
        margin: 2rem;
        box-shadow: 4px 4px 5px var(--faint-text);
        padding-bottom: 2rem;
    }


    #text {
        /*this contains the quote generated*/
        padding-top: .5rem;
        line-height: 34px;
        display: block;
        text-align: center;
        padding: 1rem;
    }

    #text::before, 
    #text::after  {
        /*this adds quotation marks before and after #text*/
        font-size: 30px;
        line-height: 16px;
        font-family:Georgia, 'Times New Roman', Times, serif;
        font-style: italic;
        color: var(--faint-text);
    }


    /*these adds quotation marks before and after #text*/
    #text::before {
        content: "\"";
    }

    #text::after {
        content: "\"";
    }


    #author {
        /*this styles the author's name div*/
        text-align: right;
        padding-right: 3rem;
        font-style: italic;
        font-size: 20px;
        color: var(--body-text);
    }

    #author::before {
        /*this puts an em-dash before the author's name*/
        content: "-- ";
    }

    #buttons {
        /*this div contains the Generate Random Quote and Twitter button*/
        display: flex;
        justify-content: right;
        padding: 1rem 2rem 0rem 0rem;
    }


    #new-quote {
        /*ID for "Generate New Quote" button*/
        border-radius: 4px;
        border-color: lightgrey;
        background-image: var(--generate-gradient);
        box-shadow: 2px 2px 5px var(--faint-text);
    }

    #new-quote:hover {
        background-image: var(--generate-hover);
    }

    #new-quote:active {
        background-image: var(--generate-active);
    }



    #button1, #button2 {
        /*This styles the divs for each individual button*/
        display: inline;
        padding: 0 1rem 0 0;
    }

    #button1 {
        /*this adds a pinch of extra padding to make the Generate button aesthetically similar with the Twitter button*/
        padding-top: .1rem;
    }

    #bottom-elements {
        /*this styles the div containing the #night-mode-button and #jay-line*/
        border: 1px solid white;
        position: relative;
    }

    #night-mode-button {
      /*This is a div that contains the night-btn button*/
        position: absolute;
        left: 25px;
        top: 7px;
    }

    #night-mode-style {
        /*this styles the night-mode button base*/
        border: 1px solid var(--faint-text);
        color: var(--faint-text);
        background-color: white;
        border-radius: 20px;
        font-size: 10px;
        line-height: 10px;
        height: 30px;
        width: 30px;
    }

    #night-mode-style:hover {
      /*this styles the night-mode button base when it's hovered on*/
      background-color: var(--faint-text);
      color: white;
    }

    #night-mode-style:active {
      /*this styles the night-mode button base when it's clicked*/
      background-color: var(--box-shadow);
      color: white;
    }


    #jay-line {
        /*this is the tagline at the bottom of the box that says, "Jay's Random Quote Generator"*/
        margin: 1rem 2.5rem 1rem 1rem;
        color: var(--faint-text);
        text-align: right;
        font-size: 12px;
    }



    /*-- (close) ID's--*/
              
            
!

JS

              
                import React from "https://esm.sh/react";
import ReactDOM from "https://esm.sh/react-dom";

/*This imports the necessary js to get the pretty X button*/
window.twttr = (function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0],
    t = window.twttr || {};
  if (d.getElementById(id)) return t;
  js = d.createElement(s);
  js.id = id;
  js.src = "https://platform.twitter.com/widgets.js";
  fjs.parentNode.insertBefore(js, fjs);

  t._e = [];
  t.ready = function(f) {
    t._e.push(f);
  };

  return t;
}(document, "script", "twitter-wjs"));

let quotes = [
    ["Do not anticipate trouble, or worry about what may never happen. Keep in the sunlight.", "Benjamin Franklin"]
    ["The world is a wonderful place, full of variety", "David Hockney"],
    ["In the midst of chaos, there is also opportunity", "Sun Tzu"],
    ["To obtain better results than the others, you must do something different than the others", "Sir John Templeton"],
    ["Take up one idea. Make that idea your life. Think of it, dream it, live on that idea. Let the brain, muscles, nerves, every part of your body, be full of that idea, and just leave every other idea alone. This is the way to success.", "Swami Vivekananda"],
    ["At first dreams seem impossible, then improbable, then inevitable.", "Christopher Reeve"],
    ["Make no small plans for they have no power to stir the soul", "Niccolo Machiavelli"],
    ["History shows us that the people who end up changing the world -- the great political, social, scientific, technological, artistic, even sports revolutionaries -- are always nuts, until they are right, and then they are geniuses.", "John Eliot"],
    ["All great changes are preceded by chaos", "Deepak Chopra"],
    ["Man's mind, once stretched to a new idea, never regains its original dimensions", "Oliver Wendell Holmes"],
    ["You're braver than you believe, and stronger than you seem, and smarter than you think", "A.A. Milne"],
    ["Life is either a daring adventure, or it is nothing", "Helen Keller"],
    ["Argue for your limitations and sure enough, they're yours", "Richard Bach"],
    ["Greatest success comes just one step beyond the point at which defeat overtakes you.", "Unknown"],
    ["Success is not built on success. It's built on failure. It's built on frustration, Sometimes it's built on catastrophe.", "Sumner Redstone"]
];


/*This generates a random quote, and I call this function after it's definition in order to generate a random quote on page load*/
function genQuote() {
    let randomNum = Math.round(Math.random(1) * quotes.length);
    document.getElementById('text').innerHTML = quotes[randomNum][0];
    document.getElementById('author').innerHTML = quotes[randomNum][1];
}
genQuote();

/*This takes the current quote and converts it into the appropriate hyperlink for the tweet button*/
let twitterHref;
function getLinkString() {
  let stringQuote = document.getElementById('text').innerText;
  let stringAuthor = document.getElementById('author').innerText;
  let fullQuote = '""' + stringQuote + '""' + ' -' + stringAuthor;
  let converted = fullQuote.split(" ");
  let hyperlink = converted.join('%20');
  twitterHref = "https://twitter.com/intent/tweet?text=" + hyperlink;
  return twitterHref;
}
getLinkString();


/*This renders the "generate new quote" button to the DOM*/
const GenButton = () => {
  return (
    <div>
  <button id="new-quote" onClick={genQuote}>Generate Random Quote <i className="fa fa-refresh" aria-hidden="true" /></button>
    </div>
  );
}
ReactDOM.render(<GenButton />, document.getElementById("button1"));



/*This renders the Twitter button to the DOM*/
const TweetButton = () => {
  return (
  <a id="tweet-quote-2" data-size="large" class="twitter-share-button" href={twitterHref}></a>
  );
}
ReactDOM.render(<TweetButton />, document.getElementById("button2"));







              
            
!
999px

Console