JSFiddle - React, Tailwind, and code Playground
by Matthew Vasallo
HTML
<div id="app"></div>
CSS
body {
background: #20262E;
padding: 20px;
font-family: Helvetica;
}
#app {
background: #fff;
border-radius: 4px;
padding: 20px;
transition: all 0.2s;
height: 100vh;
}
h2 {
font-weight: bold;
margin-bottom: 15px;
}
React
const WeatherCard = ({tempMin, tempMax, description}) => {
return (
<div className="weather-card">
<div>
Low of {tempMin}, high of {tempMax}
</div>
<div>
{description}
</div>
</div>
)
}
class WeatherApp extends React.Component {
constructor(props) {
super(props)
this.state = {
weather: {
tempMin: 59,
tempMax: 65,
description: "Cold, clear"
}
}
}
render() {
return (
<div className="weather-app-body">
<div className="weather-card">
<h2>Weather:</h2>
<WeatherCard {...this.state.weather}/>
</div>
</div>
)
}
}
ReactDOM.render(<WeatherApp />, document.querySelector("#app"))