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 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

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

              
                table.tablesorter
  font-family: arial
  background-color: #CDCDCD
  margin: 10px 0pt 15px
  font-size: 8pt
  width: 100%
  text-align: left
  thead tr th, tfoot tr th
    background-color: #e6EEEE
    border: 1px solid #FFF
    font-size: 8pt
    padding: 4px
  tbody
    td
      color: #3D3D3D
      padding: 4px
      background-color: #FFF
      vertical-align: top
    tr.odd td
      background-color: #F0F0F6

img
  width: 32px
  height: 32px

a
  text-decoration: palegreen
  color: navy

.down
  background-image: url('https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.30.4/css/images/black-desc.gif')
  background-repeat: no-repeat
  text-align: left
  
.unset
  background-image:  none
  
a:hover
  border-color: greenyellow
  cursor: pointer

.shadowbox
  box-shadow: -2px 2px 8px rgba(0, 0, 0, 0.6), -3px 4px 12px rgba(0, 0, 0, 0.5), -4px 6px 15px rgba(0, 0, 0, 0.4), -5px 8px 18px rgba(0, 0, 0, 0.3)
  margin: 20px
  padding: 10px

.boxshadowinset
  box-shadow: inset -1px -3px 20px 5px rgba(0, 0, 0, 0.75)

h3
  text-shadow: 1px 1px 5px 5px white
  padding: 8px
  font-family: 'Courier New', Courier, monospace
  width: 100%
  height: 50px
  border: 1px solid black
  background-color: darkslateblue
  text-align: center
              
            
!

JS

              
                

class App extends  React.Component {


       state = { data: [],data30: [],dataall: [],
               baseurl : "https://www.freecodecamp.org/" 
             
    }
      
      loadData() {
        fetch('https://fcctop100.herokuapp.com/api/fccusers/top/alltime?Origin=*')
          .then(response => response.json())
          .then(data => {
            this.setState({data: data });
            this.setState({dataall: data });
        })
          .catch(err => console.error(this.props.url, err.toString()));
          fetch('https://fcctop100.herokuapp.com/api/fccusers/top/recent?Origin=*')
          .then(response => response.json())
          .then(data => {
            this.setState({data30: data });
                 })
          .catch(err => console.error(this.props.url, err.toString()));
      }

      componentDidMount() {
        this.loadData();  
        this.setState({styleClassall: 'down'});   
      } 
   
 pick_data(g){
  
   let id = g;
  
let data = this.state.data.slice();
if(id==='30' ){
    this.setState({styleClass30: 'down'})
    this.setState({styleClassall: 'unset'})
  data = this.state.data30;
this.setState({data});
}else if (id==='all'){
   this.setState({styleClassall: 'down'})
   this.setState({styleClass30: 'unset'})
  data = this.state.dataall;
  this.setState({data});

}

}
     
  render() {
  let {data, baseurl}= this.state;
  
    return (
     

      <div className="App">
        <header className="App-header">    
                  
        </header>
     
        <div className=" shadowbox"    >
      <h3 className=" tablecolor boxshadowinset"  >Leaderboard</h3> 
        <table className=" tablesorter"  id="myTable" >
            <thead >
              <tr>
                <th>#</th>
                <th >Campername</th>
                <th  className={this.state.styleClass30} onClick= {(event)=> this.pick_data(event.target.id)}><a id='30' href ='#'>Points in past 30 days</a></th>
                <th  className={this.state.styleClassall} onClick= {(event)=> this.pick_data(event.target.id)} ><a id='all' href ='#'>All time points</a> </th>   
                </tr>
   </thead>
            <tbody> 
           {data.map(function(object, i){   
            let element = data[i];
            let username =element.username;          
                 let x=0;
          x=Number(i)+1;  
         var cnames  = 'even' ;
          if(x%2===0)
          { cnames = 'odd' }    
          var userurl = {baseurl}+  {username};
  return<tr key={i} className={cnames}>
 <td ><p> {x} </p> </td>
    <td><img src={element.img}  alt="" ></img> 
    <a href={userurl} target="_blank">{element.username}  </a></td>
     <td> { element.recent}</td>
   <td> {element.alltime }</td>
  </tr>

          })
          }                     
            </tbody> 
  </table>
          </div>
      </div>
    );
  }
}
ReactDOM.render(
	<App />,
  document.getElementById('root')
);

              
            
!
999px

Console