123

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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div id="grid" class="cell-1">
      <div id="grid" class="cell-1 cell-topimage">
        <!-- LOOK INTO WRITING A MARGIN IN CSS AND APPLYING IT THERE -->
        <div class="center"><h1><b>{Free Code Campers}<br/>leader board</b><h1></div>
       </div>
      </div>
   <div class="pad">
<h1 class="p">Leader Board</h1>
	<p>This list is assembled by a remote JSON file.  The list is updated every couple of days. 
       It is a realtime repesentation of user scores on FreeCodeCamp.com .                                                                
    The list is ordered by descending total score.
    The score is calculated as Points + (projects * 50). <br/>
    This was completed as a project.  
    Part of the React training of Free Code Camp.The responsive tables were inspired by a tutorial on responsive tables by Chris Coyier.<br/> Also inspired by SASS workflow a class at udemy.com taught by Lawrence Turton.</p>     
    </div>   
<div id="table-rap"></div>
<h5 class="center"> (un-official board)</h5><br/>
<!--CELL BOTTOM STARTS HERE -->
<div id="grid" class="cell-bottomimage">
       <div class="center"><a href="https://www.freecodecamp.com/map" target='_blank' rel='noopener'><h1><b>Course outline</b></h1></a></div>
</div>
      <div id="grid" class="cell-footer">
         <div class="center"><p><a href="https://www.freecodecamp.com/map" target='_blank' rel='noopener'>Follow the map!</a></p></div>
      </div>


            
          
!
            
              $offWhite: #eee; $white : #fff;
$lightGray : #ccc; $darkGray : #aaa;
$drkBluGreen : #035f5b; $bluGreen : #9bb1ac; $drkgreen : #338c78;
$bgColor : #035f5b;
$fontFamily1: 23px/1.6 'Ubuntu', Verdana, sans-serif;
$fontFamily2: 16px/1.6 'Georgia', Serif;
html {
  background: #338c78;
  font-size: 120%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  cursor: default;
}

a {
  color: $white;
  text-decoration: none;
}

button {
  background-color: $bgColor;
  border: none;
  color: $white;
  font: $fontFamily2;
  padding: 8px 8px;
  text-decoration: none;
  border-radius: 5px;

  &:hover {
    background-color: $bgColor * 0.8;
    cursor: pointer;
  }
}
$max: 12;
@for $i from 5 through $max {

   $equ: 100% / $i ;
   #grid.cell-#{ $i } > div {
      width: $equ;
   }
}

#grid {
  > div {
    height: 25%;
    background: $drkBluGreen;
    box-sizing: border-box;
    float: left;
  }

  &.cell-5 > div {
    width: 20%;
  }

  &.cell-6 > div {
    width: 16.66667%;
  }

  &.cell-7 > div {
    width: 14.28571%;
  }

  &.cell-8 > div {
    width: 12.5%;
  }

  &.cell-9 > div {
    width: 11.11111%;
  }

  &.cell-10 > div {
    width: 10%;
  }

  &.cell-11 > div {
    width: 9.09091%;
  }

  &.cell-12 > div {
    width: 8.33333%;
  }

  > div {
    height: 25%;
    background: $drkBluGreen;
    box-sizing: border-box;
    float: left;
  }

  &.cell-1 > div {
    width: 100%;
    height: 100%;
  }

  &.cell-topimage > div {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100vh;
    background-image: url("https://dl.dropboxusercontent.com/s/gzvk5bxnnevohv4/pexels-photo-27865.jpg?");
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
  }

  &.cell-bottomimage > div {
    width: 100%;
    height: 40vh;
    background-image: url("https://dl.dropboxusercontent.com/s/mizd2uzff36ydmq/pexels-photo-297642.jpeg?");
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
  }

  &.cell-footer > div {
    width: 100%;
    height: 10%;
    margin: 0%;
  }
}

.center {
  text-align: center;
  padding: 0.02%;
}

.block_center {
  margin: 0 auto;
}

#grid {
  &.cell-2 > div {
    width: 50%;
  }

  &.cell-3 > div {
    width: 33.33333%;
    height: 9%;
    padding: 0.50%;
    border: none;
  }

  &.cell-4 > div {
    width: 25%;
    padding: 5.01%;
    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    border-radius: 10px;
    padding: 1%;
  }
}

* {
  padding: 0;
  margin: 0px;
}

#table-rap {
  margin: 1.5%;
  font-family: $fontFamily2;
}

p {
  padding: 5 15 17px;
  margin: 0 15px;
  font-family: $fontFamily1;
  font-size: 130%;
  color: $offWhite;
}

h1 {
  margin: 0 15px;
  color: $offWhite;
}

h5 {
  color: $lightGray;
}

table {
  width: 100%;
  border-collapse: collapse;
}

tr:nth-of-type(odd) {
  background: $bluGreen;
}

th {
  background: $drkBluGreen;
  color: $white;
  font-weight: bold;
}

td, th {
  padding: 6px;
  border: 1px solid $lightGray;
  text-align: left;
}

@media only screen and (max-width: 760px), (min-device-width: 768px) and (max-device-width: 1024px) {
  table, thead, tbody, th, td, tr {
    display: block;
  }
  html{
    font-size: 80%;
    color: $white;
  }

  thead tr {
    position: absolute;
    top: -10000px;
    left: -10000px;
  }

  tr {
    border: 1px solid $lightGray;
  }

  td {
    border: none;
    border-bottom: 1px solid $offWhite;
    position: relative;
    padding-left: 50%;

    &:before {
      position: absolute;
      top: 6px;
      left: 6px;
      width: 45%;
      padding-right: 0.05%;
      white-space: nowrap;
    }

    &:nth-of-type(1):before {
      content: "Camper name";
    }

    &:nth-of-type(2):before {
      content: "Score";
    }

    &:nth-of-type(3):before {
      content: "score";
    }

    &:nth-of-type(4):before {
      content: "Last Update";
    }

    &:nth-of-type(5):before {
      content: "toggle";
    }

    &:nth-of-type(6):before {
      content: "Help Score";
    }

    &:nth-of-type(7):before {
      content: "Overall score";
    }

    &:nth-of-type(8):before {
      content: "Last checked";
    }

    &:nth-of-type(9):before {
      content: "toggle";
    }
  }
}
            
          
!
            
              class App extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      showRecent: true,
      recent: { data: [] },
      alltime: { data: [] }
    }
  }
  componentWillMount() {
    this._updateData()
  }
  _updateData() {
    this.setState({
      showRecent: !this.state.showRecent
    }, () => {
      axios.get('https://fcctop100.herokuapp.com/api/fccusers/top/recent')
      .then(res => {
        this.setState({
          recent: res
        })
      })
      .then(() => {
        axios.get('https://fcctop100.herokuapp.com/api/fccusers/top/alltime')
        .then(res => {
          this.setState({
            alltime: res
          })
        })
      })
    })
  }
  render() {
    var data = this.state.showRecent
      ? this.state.recent.data.sort((a, b) => { a.recent < b.recent })
      : this.state.alltime.data.sort((a, b) => { a.alltime < b.alltime })
    return (
      <div>        
        <p>Sorted by {this.state.showRecent ? "Recent" : "All Time"}</p>
                  <table summary="Camper Postion">
		<thead>
		<tr>
			<th>Camper name</th>
			<th>{this.state.showRecent ? "Recent" : "All Time"} Score</th>
			<th>{this.state.showRecent ? "All Time" : "Recent"} Score</th>
						
			<th>Last checked</th>
			<th>Recent, All time</th>
		</tr>
		</thead>
		<tbody>
          {
            data.map(item => {
            //  console.log(item)
              return (                
		<tr>
			<td> <img src={item.img} width='40' height='40'/>    {item.username}</td>
                        <td>{this.state.showRecent ? item.recent : item.alltime}</td>
                        <td>{this.state.showRecent ? item.alltime : item.recent}</td>						
			<td>{item.lastUpdate}</td>
			<td><button value={this.state.showRecent} onClick={this._updateData.bind(this)}> {this.state.showRecent ? "Recent" : "All Time"}</button></td>
		</tr>	             
              )
            })
          }
                    	</tbody>
	</table>
      </div>
    )
  }
}
 ReactDOM.render(<App />, document.querySelector('#table-rap'))
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console