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 class="content">
  <header><h1>Random Quote Machine</h1></header>
  <section id="quoteWrapper">
    <article>
      <i class="fas fa-quote-left"></i>
      <span id="quoteBody">
        This is a placeholder quote.
      </span><!-- #quoteBody -->
      <i class="fas fa-quote-right"></i>

      <div id="quoteAuthorWrapper">
        &ndash; <span id="quoteAuthor">
        Quote Author
        </span><!-- #quoteAuthor -->
      </div><!-- #quoteAuthor -->
    </article>
  </section><!-- #quoteWrapper -->

  <button id="generateButton">Generate Quote</button>

  <section id="social">
    <a id="twitterShare" class="button" role="button"><i class="fab fa-twitter-square"></i></a>
    <!--<a id="fbShare" class="button" role="button"><i class="fab fa-facebook-square"></i></a>-->
  </section>
</div><!-- .content -->

  <footer>
    &copy; 2018 <a href="https://jerkeller.com" target="_blank">Jer Keller</a>
  </footer>

  <script defer src="https://use.fontawesome.com/releases/v5.0.8/js/all.js"></script>
              
            
!

CSS

              
                /* GOOGLE FONT FAMILIES
font-family: 'Oswald', sans-serif;
font-family: 'Rammetto One', cursive;
*/

body {
  font-family: 'Oswald', sans-serif;
  font-size: 1.5rem;
  background: #ccc;
}

a, a:visited {
  color: #555;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Rammetto One', cursive;
}

h1, h2 {
  font-size: 2.4rem;
  margin: 0 0 25px;
}

.content {
  width: 100%;
  padding: 30px;
  margin: 0;
  background: #fff;
}

#quoteWrapper {
  margin: 0 0 25px 50px;
  max-width: 600px;
}

.fa-quote-left {
  margin-right: 5px;
  color: #555;
}

.fa-quote-right {
  margin-left: 5px;
  color: #555;
}

#quoteAuthorWrapper {
  font-size: 1.1rem;
  font-style: italic;
}

#twitterShare {
  font-size: 2rem;
  color: #1DA1F2;
  border: 0;
  background: #fff;
  padding: 0;
  margin: 5px;
}

#twitterShare:hover {
  color: #0488D9;
  cursor: pointer;
}

#fbShare {
  font-size: 2rem;
  color: #3B5998;
  border: 0;
  background: #fff;
  padding: 0;
  margin: 0;
}

#fbShare:hover {
  color: #22407F;
  cursor: pointer;
}

#social {
  margin: 25px 0 25px;
}

footer {
  margin-top: 20px;
  font-size: 0.9rem;
  text-align: center;
}

// DEFAULT: Extra small devices (portrait phones, less than 576px)
// Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {

}

/* Medium devices (tablets, 768px and up)*/
@media (min-width: 768px) {
  .content {
    width: 650px;
    margin: auto;
  }
}

/* Large devices (desktops, 992px and up)*/
@media (min-width: 992px) {
    
}

/* Extra large devices (large desktops, 1200px and up)*/
@media (min-width: 1200px) {
    
}
              
            
!

JS

              
                // USER STORY 1: I CAN CLICK A BUTTON TO SHOW A NEW RANDOM QUOTE
// USER STORY 2: I CAN CLICK A BUTTON TO TWEET THE QUOTE

// *PSUEDO CODE

//  *GET AN INITIAL RANDOM QUOTE FROM AN EXTERNAL API
//    * COLLECT AUTHOR AND ASSIGN IT TO A VARIABLE
//    * COLLECT QUOTE AND ASSIGN IT TO A VARIABLE

function parseQuote(response) {
  var quoteText = response.quoteText;
  var quoteAuthor = response.quoteAuthor;
  $("#quoteBody").text(quoteText);
  $("#quoteAuthor").text(quoteAuthor);
  
  var tweet = "https://twitter.com/intent/tweet?text=" + encodeURIComponent('\"' + quoteText.trim() + '\" - ' + quoteAuthor);
  $("#twitterShare").attr({"href":tweet, "target":"_blank"});
};

var tag = document.createElement("script");
tag.src="https://api.forismatic.com/api/1.0/?method=getQuote&format=jsonp&lang=en&jsonp=parseQuote";
$('#quoteBody').html(tag);

//  * WHEN THE 'GENERATE QUOTE' BUTTON IS DEPRESSED . . .
//    * UPDATE THE INNER HTML OF THE "quoteBody" SPAN TAG WITH THE BODY OF THE NEW QUOTE AND . . .
//    * UPDATE THE "quoteAuthor" SPAN TAG WITH THE NEW QUOTE AUTHOR

$('#generateButton').click(function() {
  $.getJSON("https://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=?")
  .done(function(response){
    var quoteText = response.quoteText;
    var quoteAuthor = "";
    
    if (response.quoteAuthor == "") {
      var quoteAuthor = "Anonymous";
    } else {
      var quoteAuthor = response.quoteAuthor;
    }
    
    $("#quoteBody").text(quoteText);
    $("#quoteAuthor").text(quoteAuthor);
    
    var tweet = "https://twitter.com/intent/tweet?text=" + encodeURIComponent('\"' + quoteText.trim() + '\" - ' + quoteAuthor);
  $("#twitterShare").attr({"href":tweet, "target":"_blank"});
  });
});
              
            
!
999px

Console