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

              
                @import url('https://fonts.googleapis.com/css?family=Pacifico');

.logo{
  margin-top: 0.5rem;
  margin-left: 0.5rem;
}

nav{
  background-color: #45B69C;
}

body{
  background-color:#D8DDEF;
}

.brand-logo{
  font-family: 'Pacifico', 'sans-serif' !important;
}

h4,h5,h6,p{
  color:#7293A0;
}

.divider{
  border: 0.5px solid #A0A4B8;
}
              
            
!

JS

              
                class LeaderBoard extends React.Component{
  constructor(props){
    super(props);
    this.state = {
      recent: {},
      alltime: {},
      endpoints:[
        'https://fcctop100.herokuapp.com/api/fccusers/top/recent',
        'https://fcctop100.herokuapp.com/api/fccusers/top/alltime'
      ],
    };
  }
  
  componentDidMount(){
    this.GetAllUsersPoints(this.state.endpoints);
  }
  
  render(){
    return(
      <div class="none">
        <nav>
          <div class="nav-wrapper">
            <a class="left brand-logo logo" href="www.freecodecamp.org"><img src="https://design-style-guide.freecodecamp.org/downloads/freeCodeCamp-alternative.png" width="400px" height="auto"/></a>
            <ul class="right brand-logo">
              <li> LeaderBoard for Campers</li>
            </ul>
          </div>
        </nav>
        <div class="row">
          <div class="col s12 m12 l12 data-holder">
            <h5 class="col s2 m2 l1">#</h5>
            <h5 class="col s4 m4 l3">Name</h5>
            <h5 class="col s3 m3 l4">Points last 30 days</h5>
            <h5 class="col s3 m3 l4">All Time points</h5>
            <div class="divider"/>
            <Users info={this.state.recent} />
          </div>
        </div>
      </div>
    );
  }
  
  GetAllUsersPoints(endpoints){
      for(var x = 0; x < endpoints.length; x++){
        console.log('Executing ajax in ',endpoints[x]);
        $.ajax({
          url: endpoints[x],
          dataType: 'JSON',
          method: 'GET',
          success: (a) => {
            if(x == 1){
              this.setState({recent: a});
               console.log(this.state.recent[0]);
            }else{
              this.setState({alltime: a});
              console.log(this.state.alltime[0]);
            }  
          },
          error: (b) => {
            console.log("Some error occurred in ajax request ", b);
          },
        });
      }
  } 
}

class Users extends React.Component{
  constructor(props){
    super(props);
    this.state = {
      info: {
        
      },
    };
  }
  
  componentDidMount(){
    const information = this.props.info;
    this.setState({info: information});
  }
  
  render(){
    return(
      <div class="row">
       <h5 class="col s2 m2 l1">{this.state.info.key}</h5>
       <h5 class="col s4 m4 l3">{this.state.info.username}</h5>
       <h5 class="col s3 m3 l4">{this.state.info.recent}</h5>
       <h5 class="col s3 m3 l4">{this.state.info.alltime}</h5>
       <div class="divider"/>
      </div>
    );
  }
}

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

Console