From 1a7e205b615c4ba51aeb79a7c75cfc77290ba063 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 25 Jun 2020 14:38:23 +0300 Subject: feat: highlight rateline correctly --- src/components/PollCard/PollCard.tsx | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/components/PollCard/PollCard.tsx b/src/components/PollCard/PollCard.tsx index 06d33d5..6b5f456 100644 --- a/src/components/PollCard/PollCard.tsx +++ b/src/components/PollCard/PollCard.tsx @@ -8,6 +8,7 @@ import { CardHeader } from '@material-ui/core/'; import { Which, Poll } from 'which-types'; +import _ from 'lodash'; import PercentageBar from './PercentageBar'; import { post } from '../../requests'; @@ -35,7 +36,6 @@ const useStyles = makeStyles(theme => ({ }, rateLine: { position: 'relative', - margin: '0 auto', width: '100%', height: theme.spacing(2), backgroundColor: theme.palette.primary.light @@ -69,7 +69,12 @@ const PollCard: React.FC = ({ initialPoll, navigate }) => { const handleRight = () => vote('right'); const leftPercentage = Math.round(100 * (left.votes / (left.votes + right.votes))); - const rightPercentage = 100 - leftPercentage; + + const percentage = { + left: leftPercentage, + right: 100 - leftPercentage + }; + const dominant: Which = left.votes >= right.votes ? 'left' : 'right'; return ( @@ -91,18 +96,24 @@ const PollCard: React.FC = ({ initialPoll, navigate }) => { className={classes.images} image={left.url} /> - + - +
-
+
); -- cgit v1.2.3