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 id="app">
</div>

<footer><p>Coded with <span>&hearts;</span> by <a href="http://satinflame.com">satinflame design</a></p></footer>
              
            
!

CSS

              
                body, html { background:#333; }
html, body {background-color:#001;
background-image: radial-gradient(#b54c68 15%, transparent 16%),
radial-gradient(#f99 15%, transparent 16%);
background-size:30px 30px;
background-position: 0 0, 15px 15px;}
.container { max-width: 800px; }
body { padding: 10px;}
table img { width:30px; height:30px; padding: 1px; border: 1px solid #ccc; margin-right:8px; }
td, th { background:#fff;}
table { border: 3px solid #000;}
caption { color:#fff; font-size:24px; padding:10px; background:rgba(0,0,0,.5); margin-top:10px; border: 5px solid #f99; border-bottom:0;}

.fancy {
  text-align: center;
  font-family: 'Kaushan Script'; 
} 
#recent.active:after, #alltime.active:after { content: "\25bc"; float:right; font-size: 14px;   } 
th#recent, th#alltime { width:30%;  cursor:pointer;
}
table th {font-family: 'Kaushan Script'; font-size:1.6rem; }
footer { color:#ccc; font-family: 'Kaushan Script'; text-align:center;background:rgba(0,0,0,.5);padding:10px;  
  a, span{ color:#b54c68;}
}

table tr:first-of-type td { font-weight:bold; font-size:1.8rem; border-top: 3px solid #b54c68; border-bottom: 3px solid #b54c68;}
table.table-bordered.table td { vertical-align:middle;}
table.table-bordered.table td:first-child { text-align:center;}
table a {   color:#b54c68;}
#app table { border:5px solid #f99;}
              
            
!

JS

              
                var Display = React.createClass({

  getInitialState: function() {    
    return {
      users: [],
      orderby: "recent",
      orderbyprev: "alltime"
    }
    this.onClick = this.handleClick.bind(this);
    this.getData();
  },

  handleClick(e) {
    //console.log("e " +e);
    var passedState = e; // what is clicke
    var orderState = this.state.orderby; // what it currently is
    if ((passedState !== "alltime") && (orderState === "alltime")) {
      this.setState({
        orderby: "recent",
        orderbyprev: "alltime"
      }); 
    } else if ((passedState !== "recent") && (orderState === "recent")) {
      this.setState({
        orderby: "alltime",
        orderbyprev: "recent"
      }); 
    }
//this.getData();
    //console.log('click: '+ this.state.orderby);
  },

  getData() {
    $.ajax({
      url: this.props.apiroot + this.state.orderby,
      dataType: 'json',
      cache: false,
      success: function(data) {
        var users = data;
        this.setState({
          users: users
        });
      }.bind(this),
      error: function(xhr, status, err) {
        console.error(this.props.apiroot, status, err.toString());
      }.bind(this)
    });
  },
  componentDidMount() {
    this.getData();
  },
  
   
  componentDidUpdate() {
    this.getData();
  },

  render: function() {
  var alltimeClass = (this.state.orderby === "alltime") ? 'active' : '';
    var recentClass = (this.state.orderby === "recent") ? 'active' : '';

    //console.log(this.state.orderby);
    return (
      <div className="editor container">
        <div className="row">
          <div className="markdown-input col-sm-12"> 
              <table className="table-responsive table table-bordered">
                  <caption className="fancy"><span className="fa fa-free-code-camp" aria-hidden="true"></span> freeCodeCamp Leaderboard</caption>
             
                 <thead>
                  <tr><th>Rank</th>
                    <th>Username</th>
                    <th id="recent" className={recentClass} onClick={this.handleClick.bind(this, "recent")}>Points in the past 30 days</th>
                    <th id="alltime" className={alltimeClass} onClick={this.handleClick.bind(this, "alltime")}>All-time Points</th>
                  </tr>
                </thead>
                <Output 
                  users={this.state.users} />
              </table>
          </div> 
        </div>
      </div>
    );
  }
});

var Output = React.createClass({
  render() {
    var count = 0;
    var userlist = this.props.users.map(function(user) {
      count++;
      return (
        <UserDetails user={user} key={user.username} img={user.img} username={user.username} recent={user.recent} alltime={user.alltime} count={count} apiroot={this.props.apiroot} updatePage={this.props.updatePage}/>
      );
    }.bind(this));

    return (
      <tbody>
        {userlist}
      </tbody>
    );
  }
});

function UserDetails(props) {
  return (
    <tr>
      <td>{props.count}</td>
      <td><a href={"https://www.freecodecamp.com/"+props.username}><img src={props.img}/>{props.username}</a></td>
      <td>{props.recent}</td>
      <td>{props.alltime}</td>
    </tr>
  )
}

ReactDOM.render(<Display apiroot="https://fcctop100.herokuapp.com/api/fccusers/top/" />, document.getElementById("app"));
              
            
!
999px

Console