Skip to content

Instantly share code, notes, and snippets.

@shalvah
Created August 26, 2017 14:06
Show Gist options
  • Save shalvah/51fdabcb6371b5e5814421138dbe3969 to your computer and use it in GitHub Desktop.
Save shalvah/51fdabcb6371b5e5814421138dbe3969 to your computer and use it in GitHub Desktop.
Card.js
import React from 'react';
class Card extends React.Component {
constructor() {
super();
this.state = {
colors: ['blue-grey', 'red', 'brown' ]
}
}
render() {
let color = this.state.colors[Math.floor(Math.random()* this.state.colors.length)];
let className = `card darken-1 ${color}`;
return (
<div className="row">
<div className="col s12 m6">
<div className={className}>
<div className="card-content white-text">
<p>{this.props.text}</p>
</div>
</div>
</div>
</div>
);
}
}
export default Card;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment