JSFiddle - React, Tailwind, and code Playground
by debtitor
HTML
<body>
<div id="container">Loading...</div>
<script src="./vendor/react.js"></script>
<script src="./vendor/react-dom.js"></script>
<script src="./vendor/babel-browser.min.js"></script>
<script type="text/babel" src="./app.jsx"></script>
</body>
CSS
body {
background: #d5d5d5;
font-family: arial;
color: #FAFAFA;
text-transform: uppercase;
}
.scoreboard {
background: #333;
width: 700px;
margin: 70px auto;
box-shadow: 0 4px 0px #333;
border-radius: 15px;
}
.header {
padding: 5px 10px;
text-align: center;
display: flex;
align-items: center;
background-color: #222;
border-radius: 15px 15px 0 0;
border-bottom: solid 2px #444;
}
.header h1 {
flex-grow: 1;
font-size: 1.5em;
letter-spacing: 3px;
font-weight: normal;
}
.header .stats,
.header .stopwatch {
width: 170px;
}
.stats {
margin-top: 0;
font-weight: normal;
}
.stats td:first-child {
text-align: right;
font-weight: normal;
letter-spacing: 2px;
color: #666;
font-size: .7em;
}
.stats td:last-child {
text-align: left;
}
.stopwatch {
padding: 15px 10px 5px 10px;
margin: -5px -10px -5px 10px;
background: #2f2f2f;
border-radius: 0 15px 0 0;
}
.stopwatch-time {
font-family: monospace;
font-size: 2em;
}
.stopwatch button {
margin: 8px 5px;
background-color: #222;
border-radius: 5px;
padding: 7px 8px;
border: none;
color: #999;
letter-spacing: 2px;
font-weight: bold;
text-shadow: none;
text-transform: uppercase;
}
.stopwatch button:hover {
background: #4b71b5;
color: #fafafa;
cursor: pointer;
}
.stopwatch h2 {
font-size: .6em;
margin: 0;
font-weight: normal;
letter-spacing: 2px;
color: #666;
}
.player {
display: flex;
font-size: 1.2em;
border-bottom: solid 2px #444;
letter-spacing: 2px;
}
.remove-player {
visibility: hidden;
margin-right: 10px;
color: #e57373;
cursor: pointer;
}
.player-name:hover .remove-player {
visibility: visible;
}
.player-name {
flex-grow: 1;
padding: 20px 10px 10px 10px;
}
.player-score {
width: 190px;
background: blue;
}
.counter {
display: flex;
}
.counter-action {
...
JavaScript
function Header(props){
return (
<div className="header">
<h1>{props.title}</h1>
</div>
);
}
Header.propTypes = {
title: React.PropTypes.string.isRequired,
};
function Player(props){
return(
<div className="player">
<div className="player-name">
{props.name}
</div>
<div className="player-score">
<div className="counter">
<button className="counter-action decrement"> - </button>
<div className="counter-score"> {props.score} </div>
<button className="counter-action increment"> + </button>
</div>
</div>
);
}
Player.propTypes = {
name: React.PropTypes.string.isRequired,
score: React.PropTypes.number.isRequired,
};
function Application(props) {
return (
<div className="scoreboard">
<Header title={props.title}/>
<Player name="Jim Hoskins" score={31}>
</div>
);
}
Application.propTypes = {
title: React.PropTypes.string,
};
Application.defaultProps = {
title: "Scoreboard",
}
ReactDOM.render(<Application />, document.getElementById('container'));