React Leaderboard

Developer
Size
4,333 Kb
Views
10,120

How do I make an react leaderboard?

Sortable Leaderboard showing free code campers with the most points. Made using Sass and React for free code camp . What is a react leaderboard? How do you make a react leaderboard? This script and codes were developed by Adam on 28 November 2022, Monday.

React Leaderboard Previews

React Leaderboard - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>React Leaderboard</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="app"></div> <script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react-dom.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

React Leaderboard - Script Codes CSS Codes

body { font-family: 'Verdana', sans-serif; background: #222; text-align: center;
}
.container { width: 80%; margin: 0 auto;
}
h1 { font-size: 3em; font-weight: 700; padding: 0.5em; color: #0ec3f9;
}
table { width: 100%;
}
th { padding: 1em; background: #0ec3f9; color: #222; font-size: 1.5em; font-weight: 700;
}
.sortable { cursor: pointer; transition: ease-out 0.2s;
}
.sortable:hover { background: #fff;
}
tbody { color: #fff; background: #333; font-size: 1.2em;
}
tbody:hover { background: #000; transition: ease-out 0.2s;
}
tbody:nth-of-type(even) { background: #444;
}
tbody:nth-of-type(even):hover { background: #000; transition: ease-out 0.2s;
}
td { vertical-align: middle;
}
img { width: 4em; height: 4em; margin: 0.5em; border-radius: 50%; border: 0.25em solid #0ec3f9;
}

React Leaderboard - Script Codes JS Codes

"use strict";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var App = function (_React$Component) { _inherits(App, _React$Component); function App(props) { _classCallCheck(this, App); var _this = _possibleConstructorReturn(this, _React$Component.call(this, props)); _this.state = { data: [], list: 'recent', ascend: true }; return _this; } App.prototype.componentDidMount = function componentDidMount() { var _this2 = this; fetch("https://fcctop100.herokuapp.com/api/fccusers/top/recent").then(function (response) { return response.json(); }).then(function (json) { return _this2.setState({ data: json }); }); }; App.prototype.sort = function sort(list) { return function () { var _this3 = this; this.setState({ campers: this.state.data.sort(function (a, b) { return _this3.state.ascend ? a[list] - b[list] : b[list] - a[list]; }), list: list, ascend: !this.state.ascend }); }.bind(this); }; App.prototype.render = function render() { return React.createElement( "div", { className: "container" }, React.createElement( "h1", null, "FCC Camper Leaderboard" ), React.createElement( "table", null, React.createElement( "thead", null, React.createElement( "th", null, "Position" ), React.createElement("th", null), React.createElement( "th", null, "Camper" ), React.createElement( "th", { className: "sortable", onClick: this.sort("recent") }, "Recent" ), React.createElement( "th", { className: "sortable", onClick: this.sort("alltime") }, "All Time" ) ), this.state.data.map(function (camper, i) { return React.createElement( "tbody", null, React.createElement( "tr", null, React.createElement( "td", null, i + 1 ), React.createElement( "td", null, React.createElement("img", { src: camper.img }) ), React.createElement( "td", null, camper.username ), React.createElement( "td", null, camper.recent ), React.createElement( "td", null, camper.alltime ) ) ); }) ) ); }; return App;
}(React.Component);
ReactDOM.render(React.createElement(App, null), document.querySelector('.app'));
React Leaderboard - Script Codes
React Leaderboard - Script Codes
Home Page Home
Developer Adam
Username rzencoder
Uploaded November 28, 2022
Rating 3
Size 4,333 Kb
Views 10,120
Do you need developer help for React Leaderboard?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Adam (rzencoder) Script Codes
Create amazing video scripts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!