Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

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="root"></div>
              
            
!

CSS

              
                .profilePhotos{
  max-width: 40px;
  height: auto;
  border-radius:50%;
  margin-left: 0px;
  margin-right: 10px;
  margin-top: 0px;
  margin-botton: 0px;
  float:left;
}

.tableShadow{
  box-shadow: 10px 10px 5px grey;
}

.grad {
  background: #11998e;  /* fallback for old browsers */
  background: -webkit-linear-gradient(to right, #558B2F, #33691E);  /* Chrome 10-25, Safari 5.1-6 */
  background: linear-gradient(to right, #558B2F, #33691E); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
.banner{
  padding-top:25px;
  padding-bottom:25px;
  text-align:center;
  color: #FFFFFF;
}

.logo{
  max-width: 150px;
  height: auto;
  text-align:center;
}

.notSelected{
  background-color:#FFFFFF;
  color:#212121;
}
.selected{
  color:#FFFFFF;
}

              
            
!

JS

              
                const allTimeApi = 'https://fcctop100.herokuapp.com/api/fccusers/top/alltime'
const recentApi = 'https://fcctop100.herokuapp.com/api/fccusers/top/recent'

class App extends React.Component{
  constructor(props){
    super(props)
  }
  
  render(){
    return(
      <div>
          <div className="banner grad">
            <img src="http://metakata.altervista.org/wordpress/wp-content/uploads/2015/08/freecodecamp_white.png" alt="FreeCodeCamp Logo" className="logo "/>
            <h1> FreeCodeCamp Leaderboard </h1>
          </div>
          <TableContent/>
       </div>
    )
  }
  
}
 
class TableContent extends React.Component{
  constructor(props){
    super(props)
    this.state = {
      allTimeRequested:false,
      usersData:[],
    }   
  };
  
  getFetch(){
    fetch(this.state.allTimeRequested? allTimeApi : recentApi)
      .then(results => results.json())
      .then(data => {
        let tableData = data.map((user,index)=>(
          <tr key={user.username} style={{textAlign: 'center'}}>
            <th>{index+1}</th>
            <td>
              <img src={user.img} className="profilePhotos" alt={`${user.username} profile photo`}/>
              <a href={`https://www.freecodecamp.com/${user.username}`}>{user.username}</a>
            </td>
            <td>{user.recent}</td>
            <td>{user.alltime}</td>
          </tr>
          ))
          this.setState({
            usersData: tableData,
          })
      })
  }
  
  showBestRecent = () => {
    this.setState({allTimeRequested:false},()=>this.getFetch())
  }
  
  showBestAllTime = () => {
    this.setState({allTimeRequested:true},()=>this.getFetch())

  }
  
  componentDidMount(){
    this.getFetch()
 }

 render(){
   return(
     <div className="col-12" style={{textAlign: 'center'}}>
      <table className="table table-striped table-bordered tableShadow">
        <th>#</th>
        <th>Camper name</th>
        
        <th className={this.state.allTimeRequested? "notSelected":"selected grad"}
          onClick={this.showBestRecent} >Points in past 30 days</th>
        
        <th className={this.state.allTimeRequested? "selected grad":"notSelected"} 
          onClick={this.showBestAllTime}>All time points</th>
        
        <tbody>
          {this.state.usersData}
        </tbody>
      </table>
     </div>
   )
 } 
}

ReactDOM.render(
  <App/>,
  document.getElementById("root")
)


              
            
!
999px

Console