cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

              <div id="container"></div>
  background: #457E86
  font-family: cursive
  display: flex
  justify-content: center
  font-size: 3em
  margin: 10px

h1 img
  max-width: 400px

  border-spacing: 0
  font-family: sans-serif
  display: flex
  justify-content: center
/* row striping */
  background: #eee
  background: white

  background: #381F0B
  color: white
  font-weight: bold

th a
  color: white

th a.active.asc:after
  content: " \25bc"
th a.active.desc:after
  content: " \25b2"
  text-decoration: none
  text-decoration: underline
td, th
  padding: 1em
  border: none
  text-align: left
  font-size: 1em

.camperName img
  height: 2em
  border-radius: 5px
  vertical-align: middle

td a:last-child
  color: black
  margin-left: 10px
td:nth-of-type(1), td:nth-of-type(3), td:nth-of-type(4)
  text-align: center

              /** USER STORIES **
User Story: I can see a table of the Free Code Camp campers who've earned the most brownie points in the past 30 days.
User Story: I can see how many brownie points they've earned in the past 30 days, and how many they've earned total.
User Story: I can toggle between sorting the list by how many bronwie points they've earned in the past 30 days and by how many brownie points they've earned total.
Hint: To get the top 100 campers for the last 30 days: https://fcctop100.herokuapp.com/api/fccusers/top/recent.
Hint: To get the top 100 campers of all time: https://fcctop100.herokuapp.com/api/fccusers/top/alltime.

var CamperTable = React.createClass({
  render: function() {
    var dataNodes = this.props.data.map(function(data) {
      var userUrl = 'https://www.freecodecamp.com/'+data.username;
      return (
          <td className="camperId">
          <td className="camperName">
            <a href={userUrl} target="_blank"><img src={data.img}/></a>
            <a href={userUrl} target="_blank">{data.username}</a>
          <td className="points30Days">
          <td className="pointsAllTime">

    return (

var LeaderBoard = React.createClass({
  getInitialState: function() {
    return {data: []};
  componentDidMount: function(url) {
    if (!url) {
      var url = this.props.url;
      url: url,
      dataType: 'json',
      cache: false,
      success: function(data) {
        for (var i=0;i<data.length;i++) {
          data[i].id = i+1;
        this.setState({data: data});
      error: function(xhr, status, err) {
        console.error(this.props.url, status, err.toString());
  updateTable: function(event) {
    // Re-sort existing dataset
    if (event.target.classList[0] =='active') {
      var data = this.state.data.reverse();
      this.setState({data: data});
      $('.active').toggleClass('asc desc');
    } else {
    // Fetch new data from the API if new dataset chosen
      $('#'+event.target.id).removeClass('desc asc').addClass('asc');
  render: function() {
    return (
      <div className="leaderBoard">
        <h1><img src="https://s3.amazonaws.com/freecodecamp/freecodecamp_logo.svg" alt="Free Code Camp"></img></h1>
        <div className="camperTable">
              <th><a href="#" id="recent" className="active asc" onClick={this.updateTable}>Recent points</a></th>
              <th><a href="#" id="alltime" className="" onClick={this.updateTable}>Total points</a></th>
            <CamperTable data={this.state.data}/>

React.render(<LeaderBoard url='https://fcctop100.herokuapp.com/api/fccusers/top/recent'/>, document.getElementById('container'));
🕑 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 ..................