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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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.

            
              $green: #659446;
$light-green: #75a456;
$teal: #426D52;
$dark-gold: #585414;
$light-brown: #3D3A1B;
$chocolate: #1D1405;


html {
  background-color: $chocolate;
  color: white;
}

#board {
  margin: auto;
  overflow: hidden;
  max-width: 1000px;
  background-color: $green;
}

#board-title {
  background-color: $teal;
  max-width: 1000px;
  height: 60px;
  margin: auto;
  margin-top: 50px;
  font-family: 'Caesar Dressing', cursive;
  font-weight: bold;
  font-size: 50px;
  text-align: center;
  padding: 20px 0;
}

#board-labels{
  background-color: $dark-gold;
  position: relative;
  max-width: 1000px;
  height: 50px;
  margin: auto;
  font-family: 'Changa', sans-serif;
  button {
    font-family: 'Changa', sans-serif;
    border: none;
    background: none;
    color: white;
    cursor: pointer;
    padding: 0;
    margin: 0;
    font-size: 16px;
    &.btn-active {
      color: yellow;
    }
  }
  .points {
    padding: 10px;
  }
}

.camper-row {
  img {
    height: 50px;
    width: 50px;
  }
  height: 50px;
  position: relative;
  
  &:nth-child(2n) {
    background-color: $light-green;
  }
}

.column {
  text-align: center;
  font-size: 20px;
  display: block;
  float: left;
  height: 50px;
  &.points {
    width: 60px;
    height: 30px;
    padding: 10px;
    position: absolute;
    &.all-time {
      right: 0;
    }
    &.recent {
      right: 80px;
    }

  }
  &.rank {
    width: 50px;
    height: 30px;
    padding: 10px;
  }
  &.username {
    height: 30px;
    padding: 10px;
  }
  &.user {
    height: 30px;
    padding: 10px 0;
  }
}
            
          
!
            
              var BoardLabels = React.createClass({
    render: function(){
        return(
            <div id="board-labels">
                <div className="column rank">Rank</div>
                <div className="column user">Camper</div>
                <div className="column points all-time btn-active">
                    <button className={this.props.active === 'allTime' ? "btn-active" : ""}  
                            onClick={this.props.displayAllTime}>All Time</button>
                </div>
                <div className="column points recent">
                    <button className={this.props.active === 'recent' ? "btn-active" : ""}  
                            onClick={this.props.displayRecent}>Recent</button>
                </div>
            </div>
        )
    }
});

var CamperData = React.createClass({
    render: function(){
        return(
            <div id="board">
                {this.props.items.map(function(item, index) {
                    return <div className="camper-row" key={index}> 
                        <div className="column rank"> {index+1}</div> 
                        <div className="column avatar"><img src={item.img}/></div>
                        <div className="column username">{item.username}</div> 
                        <div className="column points all-time"> {item.alltime}</div> 
                        <div className="column points recent">{item.recent}</div> 
                    </div>
                })}
            </div>
        )
    }
});

//Main competent rendering all components
var LeaderBoard = React.createClass({
    getInitialState: function(){
        return {
            allTime: [],
            recent: [],
            active: 'allTime'
        }
    },
    componentDidMount: function() {
        let component = this;
        axios.get('https://fcctop100.herokuapp.com/api/fccusers/top/alltime').then(function(allTime){
            axios.get('https://fcctop100.herokuapp.com/api/fccusers/top/recent').then(function(recent){
                component.setState({
                    recent: (recent.data),
                    allTime: (allTime.data)
                });
            })
        }).catch(function(err){console.log(err)});
    },
    displayAllTime: function(){
        console.log("display all time points");
        this.setState({active: 'allTime'});
    },
    displayRecent: function(){
        console.log("display recent points");
        this.setState({active: 'recent'});
    },
    render: function(){
        console.log(this.state);
        return(
            <div>
                <div id="board-title"> FCC Camper Leaderboard </div>
                <BoardLabels displayAllTime={this.displayAllTime} 
                             displayRecent={this.displayRecent} 
                             active={this.state.active} />
                <CamperData items={this.state[this.state.active]}/>
            </div>
        )
    }
});


//render components
ReactDOM.render(<LeaderBoard/>, document.getElementById("app"));
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console