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.

            
              <div id="wrapper">
   <div class="container">
      <div class="row">
         <div id="quote" class="col-12 fade">
         </div>
      </div>
      <div class="row u-cntr">
         <div class="col-4">
            <a id="twitter" href="#" target="_blank"><i class="icon fab fa-twitter-square"></i></a>
         </div>
         <div class="col-4"></div>
         <div class="col-4">
            <button id="getQuote" class="btn">Next Quote</button>
         </div>
      </div>
   </div>
</div>
            
          
!
            
              $white: #FAFAFA
$gray: #333333

// Text Colors
$orange: #FF7C19
$purple: darken(purple, 5%)
$light-purple: #6d00d2
$blue: #276689
$green: darken(green, 5%)

body
   background-color: transparent
   padding: 150px 0
a
   color: $gray
html
   height: 100%
   transition: all .5s ease
   
   &.style1
      background: radial-gradient(farthest-corner at bottom 250px left, #9500cc 0%, #0076cc 200%)
      blockquote, svg
         color: $purple
      button
         color: $purple
         border-color: $purple
         &:hover
            background-color: $purple
            color: $white

   &.style2
      background: radial-gradient(farthest-corner at bottom 250px left, #2b802b 0%, #32836f 100%)
      blockquote, svg
         color: $green
      button
         color: $green
         border-color: $green
         &:hover
            background-color: $green
            color: $white

   &.style3
      background: radial-gradient(farthest-corner at bottom 250px left, red 0%, orange 75%, yellow 100%)
      blockquote, svg
         color: $orange
      button
         color: $orange
         border-color: $orange
         &:hover
            background-color: $orange
            color: $white
         
   &.style4
      background: radial-gradient(farthest-corner at bottom 250px left, #276689 0%, #2eb4d8 100%)
      blockquote, svg
         color: $blue
      button
         color: $blue
         border-color: $blue
         &:hover
            background-color: $blue
            color: $white
         
   &.style5
      background: radial-gradient(farthest-corner at bottom 250px left, #c300ff 0%, #6d00d2 100%)
      blockquote, svg
         color: $light-purple
      button
         color: $light-purple
         border-color: $light-purple
         &:hover
            background-color: $light-purple
            color: $white

#wrapper
   display: block
   position: relative
   width: 100%
         
.container
   max-width: 650px
   border-radius: 2px
   background-color: $white
   color: $gray
   box-shadow: 2px 2px 3px 1px rgba(0,0,0,.35)
   
@media screen and (max-width: 760px)
   .container
      max-width: none
      width: 95%

   
.icon, .btn
   transition: all .25s ease
   
.icon
   font-size: 4.5rem
   margin-top: 20px
   cursor: pointer
   margin: 0 10px
   
.btn
   font-family: 'Open Sans', sans-serif
   font-size: 1.7rem
   
   margin-top: 3px
   margin-bottom: 25px
   padding: 8px 12px
   outline: none
   border: 1px solid $gray
   border-radius: 2px
   
   background-color: $white
   color: $gray
   cursor: pointer
   
   transition: all .25s ease
   
   &:hover
      color: $white
      background-color: $gray

#quote
   opacity: 1
   transition: all 1s ease
   &.fade
      transition: all .5s ease
      opacity: 0
   
blockquote
   font-size: 2.2rem
   svg
      margin-right: 25px
   p
      display: inline
cite
   display: block
   margin-left: 35px
   margin-top: 15px
            
          
!
            
              'use strict';
// https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1

/*
tweet url: https://twitter.com/intent/tweet?hashtags=quotes&related=brycejech%2Ccreator&text=THE_TEXT;
*/
(function(){
   
   const twitter = document.getElementById('twitter'),
         quote   = document.getElementById('quote');
   
   const styles = [1,2,3,4,5];

   function loadQuote(){
      
      const opts = {
         url: 'https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&t=' + Date.now(),
         method: 'GET',
         dataType: 'json',
         success: function(data){
            const obj  = data[0],
                  html = '<blockquote><i class="fas fa-quote-left"></i>' + obj.content + '<cite>- ' + obj.title + '</cite></blockquote>';

            twitter.href = getTweetURL({author: obj.title, quote: obj.content});
            
            quote.innerHTML = html;
            quote.classList.remove('fade');
            applyRandomStyle();
         },
         error: function(xhr, status, err){
            console.log(xhr);
            console.log(status);
            console.log(err); 
         }
      }
      document.getElementById('quote').classList.add('fade');
      ajax(opts);  
   }
   
   function applyRandomStyle(){
      const el       = document.getElementsByTagName('html')[0],
            curStyle = getCurrentStyle();
      
      let className;
      
      // don't duplicate current style
      while((className = getRandomStyle()) == curStyle){
         className = getRandomStyle();
      }
      
      el.classList.remove(curStyle);
      el.classList.add(className);
   }

   function getCurrentStyle(){
      let elem = document.getElementsByTagName('html')[0];
      for(let i = 0; i < elem.classList.length; i++){
         if(/style\d/.test(elem.classList[i])) return elem.classList[i];
      }
      return undefined;
   }
   
   function getRandomStyle(){
      return 'style' + styles[Math.floor(Math.random() * styles.length)]
   }
   
   function getTweetURL(obj){
      let quote  = obj.quote
         .replace(/<.*?>/gi, '') // strip html
         // common html entities
         .replace(/&#8217;/gi, "'")
         .replace(/&#8211;/gi, "-")
         .replace(/(&#8221;)|(&#8220;)/gi, "'")
         // trailing whitespace
         .trim(),
          author = obj.author;
      return `https://twitter.com/intent/tweet?hashtags=quotes&related=brycejech%2Ccreator&text="${quote}"%0A-%20${author}%0A`;
   }

   /*
      CONTROL FLOW
   */
   loadQuote();
   document.getElementById('getQuote').addEventListener('click', function(){
      loadQuote();
   });

})();
            
          
!
999px
🕑 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.

Console