css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

            
                <script type="text/html" id="template">
   <div class="pure-g-r alpha">

     <div class="pure-u-1-4">
        <div class="pure-g beta">
          
          <div class="pure-u-1">
            <h2 data-content="title"></h2>
          </div>
          
          <div class="pure-u-1">
              <div data-content="date"></div>
          </div>
          
          <br>
          
          <div class="pure-u-1">
              <div data-content="description"></div>
          </div>
        </div>
     </div>
     
     <div class="pure-u-3-4">
       <div class="pure-g-r gamma">

         <div class="pure-u-1-3 overflow">
           <img class="pen__link" data-src="penPicture" data-alt="CodePen preview"/>
         </div>   
         
         <div class="pure-u-2-3">
           <table>
             <tr class="chart"></tr>
           </table>
         </div>
         
       </div>
     </div>
  </div>
</script>

<div class="dashboard">
  
   <div class="pure-g-r eta">
     <div class="pure-u-1-2">
       <h1>CodePen Dashboard | <span class="username"></span></h1>
     </div>
     
     <div class="pure-u-1-2">
       <table>
         <tr>
           <td>Hearts</td>
           <td>Views</td>
           <td>Comments</td>
         </tr>
       </table>
     </div>
  </div>
  
</div>

<footer>
  2013 by <a href="https://twitter.com/TimPietrusky" target="_blank">Tim Pietrusky</a>
</footer>
            
          
!
            
              @import "compass/css3";

$color-alpha: #e7e9e8;
$color-beta: darken($color-alpha, 10%);
$color-gamma: #fff;
$color-delta: rgba(#666, .25);
$color-epsilon: #666;
$color-zeta: #76daff;

$unit-alpha: .75em;
$unit-beta: .15em;
$unit-gamma: 4em;

body {
  background: $color-alpha;
  font: 1em "Lato", sans-serif;
  margin: $unit-gamma 0;
  
  @include breakpoint(small) {
    margin: $unit-gamma * 1.5 0;
  }
}

footer {
  text-align:right;
  padding-right: $unit-alpha;
}

.dashboard {
  margin: $unit-alpha;
  padding: 0 $unit-alpha;
  background: $color-gamma;
  box-shadow: .05em .05em 0 .05em $color-beta;
   
  h1 {
    font-size: 1.45em;
    font-weight: 400;
    padding: 0;
    margin: 0;
    
    @include breakpoint(small) {
      text-align: center;
      letter-spacing: .05em;
      font-weight: 700;
    }
    
    > span {
      color: $color-zeta;
    }
  }
  
  section {
    &:last-child {
      .alpha {
        border-bottom: none;
      }
    }
  }
  
  table {
    width: 100%;
    
    td {
      position: relative;
      text-align: center;
    }
  }
  
  .pen__link {
    margin: $unit-alpha 0;
    
    @include breakpoint(small) {
      margin: 0;
    }
  }
}

a {
  text-decoration: none;
  color: $color-epsilon;
  
  @include transition(color .15s ease-in-out);
  
  &:hover {
    color: #000;
  }
}

p {
  margin-top: $unit-alpha / 2;
  line-height: 1.35em;
}

canvas {
  margin: 0 .5em;
} 

.overflow {
  overflow: hidden;
  position: relative;
  
  @include breakpoint(small) {
    padding: $unit-alpha 0;
    background: #fff;
  }
}

.alpha {
  border-bottom: $unit-beta solid darken($color-zeta, 25%);
  
  img {
    width:100%;
    max-width: 100%;
    margin-bottom: -1em;
  }
  
  a {
    display: inline-block;
  }
}

.beta {
  padding-right: $unit-alpha;
  
  h2 {
    font-size:1.35em;
    font-weight: 400;
    letter-spacing: .05em;
    padding:$unit-alpha;
    margin: 0 0 $unit-alpha 0;
    
    color: #fff;
    background: darken($color-zeta, 25%);
  }
  
  h3 {
    display: inline-block;
    font-size:1.15em;
    font-weight: 400;
    margin: 0;
    padding: 0;
    
    @include breakpoint(small) {
      margin-bottom: $unit-alpha * 2;
    }
  }
}

.delta {
  border-bottom: $unit-beta solid $color-alpha;
}

.gamma {
  background: linear-gradient(left, $color-gamma, rgba($color-beta, .1), $color-gamma);
  background: linear-gradient(to right, $color-gamma, rgba($color-beta, .1), $color-gamma);
}

.epsilon {
  width: 5em !important;
  height: 5em;
  padding-right: $unit-alpha;
}

.zeta {
  @extend %center;
}

.eta {
  position: fixed;
  z-index: 999;
  top: 0;
  left: 0;
  background: rgba(#000, .8); 
  color: #fff;
  width: 100%;
  max-height: 2em;
  padding: $unit-alpha 0 $unit-alpha $unit-alpha;
  
  @include breakpoint(small) {
    max-height: 4em;
    
    h1 {
      margin-bottom: $unit-alpha;
    }
  }
  
  table {
    td {
      font-size: 1.25em;
      text-align: center;
      
      &:nth-child(1) {
        padding-right: 1.05em;
      }
      
      &:nth-child(2) {
        padding-right: -.15em;
      }
    }
  }
}


@media (max-width:50em){
  .pure-g-r > .pure-u,
  .pure-g-r > [class *="pure-u-"]{width:100%;}
} 
            
          
!
            
              /*
 * CodePen Dashboard for anyone
 * 
 * Create your own personal CodePen Dashboard by just 
 * changing the "codepen_username" variable to match your 
 * CodePen nickname (your name in the URL)
 *
 * e.g. https://codepen.io/TimPietrusky/ = TimPietrusky
 * 
 * 
 * 2013 by Tim Pietrusky
 * timpietrusky.com
 */

var codepen_username = "TimPietrusky";

var colors = {
  alpha : "#f7464a",
  beta : "#e2eae9",
  gamma : "#2980b9",
  delta : "#ff0",
  epsilon : "#0f0"
};

var result = {
  hearts : 0,
  views : 0,
  comments: 0,
  max_hearts : 0,
  max_views : 0,
  max_comments : 0
};

var amount = 25,
    size = 160,
    strokeWidth = 5;

$('.username').text(codepen_username);


function getData(username, type) {
  
$.ajax({
      dataType: 'jsonp',
      jsonp: 'jsonp',
      url: 'http://codepen-awesomepi.timpietrusky.com/'+username+'/' + type, 
      success: function(data) {
        if (data.content != null) {
          var pens = data.content.pens;
          
          amount = pens.length ;
          
          for (var i = 0; i < pens.length; i++) {
            if (amount - 1 < i) {
              break;
            }
            
            result["hearts"] += pens[i]["hearts"];
            result["views"] += pens[i]["views"];
            result["comments"] += pens[i]["comments"];
            
            if (result["max_hearts"] <= pens[i]["hearts"]) {
              result["max_hearts"] = pens[i]["hearts"];
            }
            
            if (result["max_views"] <= pens[i]["views"]) {
              result["max_views"] = pens[i]["views"];
            }
            
            if (result["max_comments"] <= pens[i]["comments"]) {
              result["max_comments"] = pens[i]["comments"];
            }
          }
          
          for (var i = 0; i < pens.length; i++) {
            if (amount - 1 < i) {
              break;
            }
            
          var pen = pens[i],
          group = $('<section></section>').loadTemplate($("#template"),
            {
                title: pen['title'],
                date: pen['last_updated'],
                penPicture: 'https://codepen.io/'+username+'/pen/'+pen['hash']+'/image/large.png',
                description: pen['description'],
                url : pen['url']['pen']
            });
            
            // Hearts
            var data = [
              { 
                value: pens[i]["hearts"],
                color: colors['alpha']
              },
              {
                value : result["max_hearts"] - pens[i]["hearts"],
                color : colors['beta']
              }
            ];
            newChart("Hearts", data, pen, group);
            
            
            // Views
            var data = [
              { 
                value: pens[i]["views"],
                color: colors['gamma']
              },
              {
                value : result["max_views"] - pens[i]["views"],
                color : colors['beta']
              }
            ];
            newChart("Views", data, pens[i], group);
            
            
            // Comments
            var data = [
              { 
                value: pens[i]["comments"],
                color: colors['delta']
              },
              {
                value : result["max_comments"] - pens[i]["comments"],
                color : colors['beta']
              }
            ];
            newChart("Comments", data, pens[i], group);
            
          }
        }  
      } 
    });
}

function newChart(title, data, pen, group) {
  var canvas = newCanvas();
  new Chart(canvas['ctx']).Doughnut(data, { 
    segmentStrokeWidth: strokeWidth, 
    animateScale : true, 
    animationSteps : 120,
    percentageInnerCutout : 70
  });
  var url_pen = pen['url']['pen'];
  var type = title.toLowerCase();
  
  group.find('h2').wrapAll('<a href="'+url_pen+'" />');
  group.find('.pen__link').wrapAll('<a href="'+url_pen+'" />');
  group.find('.title').append(title);
  var td = $('<td></td>').append(canvas['canvas']);
  td.append($('<div class="zeta">'+ pen[type] + '</div>'));

  group.find('.chart').append(td);

  $('.dashboard').append(group);  

}

function newCanvas() {
  var canvas = $('<canvas width="'+size+'" height="'+size * 1.5+'"></canvas>');
  return { canvas: canvas, ctx : canvas.get(0).getContext("2d") };
}
 
function template(options) {
  var template =  $('<div />').loadTemplate($("#"+options.name), options);
  return template;
}

// Start the application
getData(codepen_username, "public/list");
            
          
!
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.
Loading ..................

Console