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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

            
              $size: 16px

body 
  font-family: sans-serif

h1
  font-size: $size*2
  text-align: center
  font-weight: 700
  padding-top: 20px
  padding-bottom: 20px

p
  padding: 20px
  text-align: center
  
table
  margin-left: auto
  margin-right: auto
  
td, th 
  padding: 10px
  vertical-align: middle
  font-size: $size
  
  img
    width: 60px
    height: 60px
    
.row 
  border: 1px solid #999
  color: #333
  
.evenRow
  @extend .row
  background-color: #999

.oddRow
  @extend .row
  background-color: white
 
.selected 
  font-weight: 700
  color: gray
  text-decoration: underline
  cursor: pointer

.unselected
  font-weight: 400
  color: black
  text-decoration: underline
  cursor: pointer

#loading
  width: 2*$size
  margin: 50px 0 50px 0
  font-size: 30px
  text-align: center
            
          
!
            
              class App extends React.Component {
  render() {
    return <div>
      <h1>FreeCodeCamp Leaderboard</h1>
      <LeaderBoard />
      <p>Code by <a href="http://lukewalker.org" target="_blank">Luke Walker</a></p>
    </div>
  }                                          
}

class UserRow extends React.Component {
  render() {
    var rank = this.props.index + 1;
    var rowStyle = rank % 2 === 0 ? 'evenRow' : 'oddRow'
    return <tr className={rowStyle} key={rank}><td>{rank}</td><td><img src={this.props.avatar} /></td><td>{this.props.username}</td><td>{this.props.recent}</td><td>{this.props.alltime}</td></tr>;
  }  
}

class LeaderBoard extends React.Component {
  constructor(props) {
    super(props)
    this.state = { users: [], sort: 'Recent', loading: true } 
    this.recent = this.recent.bind(this)
    this.alltime = this.alltime.bind(this)
  }
  componentDidMount() {
    this.recent()
  }
  renderLoading() {
    return <div id="loading">Loading...</div>
  }
  recent() {
    $.get(recent)
    .then(data => this.setState({ users: data, sort: 'Recent', loading: false }))
  }
  alltime() {
    $.get(alltime)
    .then(data => this.setState({ users: data, sort: 'All Time', loading: false }))
  }
  render() {
    var leaderList = this.state.users.map((user, idx) => <UserRow index={idx} avatar={user.img} username={user.username} recent={user.recent} alltime={user.alltime} /> )
    return <table>
      <thead><tr><th>Rank</th><th>Avatar</th><th>Username</th><th onClick={this.recent} className={this.state.sort === 'Recent' ? 'selected' : 'unselected'}>Recent</th><th onClick={this.alltime} className={this.state.sort === 'All Time' ? 'selected' : 'unselected'}>All Time</th></tr></thead>
      <tbody>{ this.state.loading? this.renderLoading() : leaderList }</tbody></table>
  }
}


var recent = "https://fcctop100.herokuapp.com/api/fccusers/top/recent"
var alltime = "https://fcctop100.herokuapp.com/api/fccusers/top/alltime"        
ReactDOM.render(<App />, document.querySelector('#app'))
            
          
!
999px
Loading ..................

Console