From eb9716d39b6932b2990ab33c59214e1f276a3c68 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Thu, 25 Jun 2020 15:29:40 +0300
Subject: feat: transition rateline nicely

---
 src/components/PollCard/PollCard.tsx | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

(limited to 'src/components/PollCard/PollCard.tsx')

diff --git a/src/components/PollCard/PollCard.tsx b/src/components/PollCard/PollCard.tsx
index 40f5fd7..65b3da1 100644
--- a/src/components/PollCard/PollCard.tsx
+++ b/src/components/PollCard/PollCard.tsx
@@ -37,11 +37,15 @@ const useStyles = makeStyles(theme => ({
     position: 'relative',
     width: '100%',
     height: theme.spacing(2),
-    backgroundColor: theme.palette.primary.light
+    backgroundColor: theme.palette.primary.light,
+    transitionDuration: '0.5s'
+  },
+  highlight: {
+    backgroundColor: theme.palette.primary.main + ' !important'
   },
   fillRateLine: {
     height: theme.spacing(2),
-    backgroundColor: theme.palette.primary.main,
+    backgroundColor: theme.palette.primary.light,
     transitionDuration: '0.5s'
   }
 }));
@@ -68,11 +72,8 @@ const PollCard: React.FC<PropTypes> = ({ 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 (
@@ -95,23 +96,20 @@ const PollCard: React.FC<PropTypes> = ({ initialPoll, navigate }) => {
             className={classes.images}
             image={left.url}
           />
-          <PercentageBar value={percentage.left} which="left" like={userChoice === 'left'} />
+          <PercentageBar value={leftPercentage} which="left" like={userChoice === 'left'} />
         </CardActionArea>
         <CardActionArea onDoubleClick={handleRight}>
           <CardMedia
             className={classes.images}
             image={right.url}
           />
-          <PercentageBar value={percentage.right} which="right" like={userChoice === 'right'} />
+          <PercentageBar value={rightPercentage} which="right" like={userChoice === 'right'} />
         </CardActionArea>
       </div>
-      <div className={classes.rateLine}>
+      <div className={`${classes.rateLine} ${dominant === 'right' ? classes.highlight : ''}`}>
         <div
-          className={classes.fillRateLine}
-          style={{
-            width: `${percentage[dominant]}%`,
-            float: dominant
-          }}
+          className={`${classes.fillRateLine} ${dominant === 'left' ? classes.highlight : ''}`}
+          style={{ width: `${leftPercentage}%` }}
         />
       </div>
     </Card>
-- 
cgit v1.2.3


From f24ea161fd2aef6ba75418c965d444ccbfd53fac Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Thu, 25 Jun 2020 15:51:51 +0300
Subject: style: fix linting erros

---
 src/components/PollCard/PollCard.tsx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'src/components/PollCard/PollCard.tsx')

diff --git a/src/components/PollCard/PollCard.tsx b/src/components/PollCard/PollCard.tsx
index 65b3da1..f82091c 100644
--- a/src/components/PollCard/PollCard.tsx
+++ b/src/components/PollCard/PollCard.tsx
@@ -41,7 +41,7 @@ const useStyles = makeStyles(theme => ({
     transitionDuration: '0.5s'
   },
   highlight: {
-    backgroundColor: theme.palette.primary.main + ' !important'
+    backgroundColor: `${theme.palette.primary.main} !important`
   },
   fillRateLine: {
     height: theme.spacing(2),
@@ -72,7 +72,7 @@ const PollCard: React.FC<PropTypes> = ({ initialPoll, navigate }) => {
   const handleRight = () => vote('right');
 
   const leftPercentage = Math.round(100 * (left.votes / (left.votes + right.votes)));
-  const rightPercentage = 100 - leftPercentage
+  const rightPercentage = 100 - leftPercentage;
 
   const dominant: Which = left.votes >= right.votes ? 'left' : 'right';
 
-- 
cgit v1.2.3

