#app
View Compiled
/* Base */
body {
background: #F3F3F3;
padding: 20px;
font-family: "Open Sans", sans-serif;
}
/* Container */
.container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
width: 90%;
max-width: 960px;
margin: 0 auto;
}
/* Column */
.column {
flex-basis: percentage(1/3);
width: percentage(1/3);
padding: 0 10px;
box-sizing: border-box;
@media (max-width: 900px) {
& {
flex-basis: 50%;
width: 50%;
}
}
@media (max-width: 600px) {
& {
flex-basis: 100%;
width: 100%;
}
}
}
/* Article (Component) */
.article {
background: #FFF;
margin: 0 0 20px;
padding: 20px;
border-radius: 2px;
box-shadow: 0 2px 4px rgba(#000, 0.2);
cursor: pointer;
transition: 0.3s ease;
&:hover {
box-shadow: 0 2px 4px rgba(#000, 0.2),
0 4px 8px rgba(#000, 0.2);
}
&:active {
box-shadow: none;
transform-origin: center;
transform: scale(0.98);
}
&__category {
display: inline-block;
// background: #212121;
padding: 8px 10px;
margin: 0 0 10px;
color: #FFF;
font-size: 0.75rem;
font-weight: 600;
letter-spacing: 0.075rem;
text-transform: uppercase;
}
&__date {}
&__excerpt {
color: #666;
line-height: 1.5rem;
font-size: 0.875rem;
}
&__title {
margin: 0 0 10px;
color: #444;
font-size: 1.25rem;
font-weight: 600;
line-height: 1.75rem;
}
}
View Compiled
/*
App
<App />
*/
var App = React.createClass({
getInitialState: function () {
return {
articles: {
'article': {
"color": "FEC006",
"title": "Snow in Turkey Brings Travel Woes",
"thumbnail": "",
"category": "News",
"excerpt": "Heavy snowstorm in Turkey creates havoc as hundreds of villages left without power, and hundreds of roads closed",
"date": new Date()
},
'article-1': {
"color": "2196F3",
"title": "Landslide Leaving Thousands Homeless",
"thumbnail": "",
"category": "News",
"excerpt": "An aburt landslide in the Silcon Valley has left thousands homeless and on the streets.",
"date": new Date()
},
'article-2': {
"color": "FE5621",
"title": "Hail the size of baseballs in New York",
"thumbnail": "",
"category": "News",
"excerpt": "A rare and unexpected event occurred today as hail the size of snowball hits New York citizens.",
"date": new Date()
},
'article-3': {
"color": "673AB7",
"title": "Earthquake destorying San Fransisco",
"thumbnail": "",
"category": "News",
"excerpt": "A massive earthquake just hit San Fransisco leaving behind a giant crater.",
"date": new Date()
}
}
}
},
renderArticle: function (key) {
return (
<div className="column">
<Article key={key} index={key} details={this.state.articles[key]} />
</div>
)
},
render: function () {
return (
<div className="app">
<div className="container">
{Object.keys(this.state.articles).map(this.renderArticle)}
</div>
</div>
)
}
});
/*
Article
<Article />
*/
var Article = React.createClass({
render: function () {
var details = this.props.details,
styles = {
backgroundColor: '#' + details.color
};
return (
<article className="article">
<h3 className="article__category" style={styles}>{details.category}</h3>
<h2 className="article__title">{details.title}</h2>
<p className="article__excerpt">{details.excerpt}</p>
</article>
)
}
});
ReactDOM.render(<App />, document.querySelector('#app'));
View Compiled
This Pen doesn't use any external CSS resources.