From c7f2999ee797ea5e3bfb29517a4f13206162cc6f Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sun, 14 Jun 2020 19:52:35 +0300 Subject: refactor: use lowercase in folder names --- src/components/PollCard/PollCard.tsx | 100 +++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 src/components/PollCard/PollCard.tsx (limited to 'src/components/PollCard/PollCard.tsx') diff --git a/src/components/PollCard/PollCard.tsx b/src/components/PollCard/PollCard.tsx new file mode 100644 index 0000000..8995a30 --- /dev/null +++ b/src/components/PollCard/PollCard.tsx @@ -0,0 +1,100 @@ +import React from 'react'; +import { makeStyles } from '@material-ui/core/styles'; +import { + Card, + CardActionArea, + CardMedia, + Avatar, + CardHeader +} from '@material-ui/core/'; +import { Poll } from '../../types'; + +interface PropTypes { + poll: Poll; +} + +interface PercentageBarPropTypes { + value: number; + which: 'left' | 'right'; +} + +const useStyles = makeStyles(theme => ({ + root: { + maxWidth: theme.spacing(75), + height: theme.spacing(63), + margin: '20px auto' + }, + images: { + height: theme.spacing(50), + width: theme.spacing(38) + }, + imagesBlock: { + display: 'flex' + }, + percentage: { + position: 'absolute', + color: 'white', + top: '86%', + fontSize: 20, + textShadow: '0 0 3px black' + }, + percentageLeft: { + left: 30 + }, + percentageRight: { + right: 30 + } +})); + + +const PercentageBar: React.FC = ({ value, which }) => { + const classes = useStyles(); + const positionClassName = which === 'left' ? 'percentageLeft' : 'percentageRight'; + + return ( +
+ {value} + % +
+ ); +}; + + +const PollCard: React.FC = ({ poll }) => { + const classes = useStyles(); + const { author, contents } = poll; + + const leftPercentage = Math.round(100 * (contents.left.votes / (contents.left.votes + contents.right.votes))); + const rightPercentage = 100 - leftPercentage; + + + return ( + + + )} + title={author.name} + /> +
+ + + + + + + + +
+
+ ); +}; + +export default PollCard; + -- cgit v1.2.3