import React from 'react'; import 'typeface-roboto'; import MGrid from '@material-ui/core/Grid'; import orange from '@material-ui/core/colors/orange'; import blue from '@material-ui/core/colors/blue'; import { Theme, withStyles, StyleRules } from '@material-ui/core/styles'; import Color from 'color'; const styles = (theme: Theme): StyleRules => ({ gridRow: { height: 24, textAlign: 'center' }, gridCell: { height: 20, width: 20, margin: 2, display: 'inline-block' } }); interface GridProps { classes: { gridRow: string, gridCell: string }, data: {d: number[], col: number}[][] } class Grid extends React.Component { static getColor(s: {d: number[], col: number}) { const color = [orange[300], blue[300]]; let {d, col} = s; return Color(color[col]).darken(Math.min(d[col] / 10, 0.6)).hex(); } render() { const { classes, data } = this.props; return (
{ data.map((row, i) => (
{ row.map((cell, j) => (
)) }
)) }
); } } export default withStyles(styles)(Grid);