diff options
author | Eugene <eug-vs@keemail.me> | 2020-01-11 14:21:42 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-11 14:21:42 +0000 |
commit | e78ecf560a0c6f4cf59a3c4341884996464c7923 (patch) | |
tree | 0929172f24748ec041c861035e9c48e60e38bade /src/components/TimerPage/TimerPage.js | |
parent | 2a501e2877ee82a9d2cad4c714083b1d190d2aa2 (diff) | |
parent | ecc6b5e6a2974502ed94cc33a70f388575bfa9ec (diff) | |
download | chrono-cube-ui-e78ecf560a0c6f4cf59a3c4341884996464c7923.tar.gz |
Merge pull request #32 from Eug-VS/window
Create Window component and refactor existing pages to use it
Diffstat (limited to 'src/components/TimerPage/TimerPage.js')
-rw-r--r-- | src/components/TimerPage/TimerPage.js | 62 |
1 files changed, 40 insertions, 22 deletions
diff --git a/src/components/TimerPage/TimerPage.js b/src/components/TimerPage/TimerPage.js index f304b46..22781bc 100644 --- a/src/components/TimerPage/TimerPage.js +++ b/src/components/TimerPage/TimerPage.js @@ -1,19 +1,22 @@ import React from 'react'; -import { Grid, Box } from "@material-ui/core"; -import { makeStyles } from "@material-ui/core/styles"; +import { post } from '../../requests'; -import Timer from "../Timer/Timer"; +import Window from "../Window/Window"; +import ContentSection from "../ContentSection/ContentSection"; +import Timer from "./Timer/Timer"; +import SmartList from "../SmartList/SmartList"; import SolutionCard from "../SolutionCard/SolutionCard"; -import { post } from '../../requests'; +import { Typography, makeStyles } from "@material-ui/core"; const useStyles = makeStyles(theme => ({ - root: { - display: 'flex', - justifyContent: 'space-between', - padding: theme.spacing(5, 4, 4, 4), + primary: { + padding: theme.spacing(4), + }, + cell: { + padding: theme.spacing(5), }, })); @@ -36,21 +39,36 @@ const TimerPage = ({ recentSolutions, setRecentSolutions }) => { setRecentSolutions(recentSolutions.filter((solution => solution.id !== id))); }; + const renderItem = ({ index, style }) => { + const solution = recentSolutions[index]; + return ( + <div style={style} className={classes.cell}> + <SolutionCard data={solution} removeThisCard={removeSolution} /> + </div> + ); + }; + return ( - <Box className={classes.root}> - <Grid container direction="row" justify="space-around" spacing={8}> - <Grid item xs={6}> - <Timer registerResult={registerResult} style={{ position: 'fixed' }}/> - </Grid> - <Grid item xs={4} container direction="column" spacing={5}> - {recentSolutions.slice(0, 3).map(solution => ( - <Grid item key={solution.id}> - <SolutionCard data={solution} removeThisCard={removeSolution}/> - </Grid> - ))} - </Grid> - </Grid> - </Box> + <> + <Window type="primary"> + <div className={classes.primary}> + <ContentSection sectionName="Welcome to ChronoCube!"> + <Typography> + Here is some text about how cool this application is, why you should use it + and how to make it better! + </Typography> + </ContentSection> + <Timer registerResult={registerResult} /> + </div> + </Window> + <Window type="secondary" name="Recent solutions"> + <SmartList + itemSize={270} + itemCount={recentSolutions.length} + renderItem={renderItem} + /> + </Window> + </> ); }; |