From 14b70c34a1b88c83e89f483399debd60560ed70b Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Sun, 14 Jun 2020 20:59:43 +0300
Subject: refactor: move PercentageBar to separate class

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

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

diff --git a/src/components/PollCard/PollCard.tsx b/src/components/PollCard/PollCard.tsx
index 8995a30..d5c99cc 100644
--- a/src/components/PollCard/PollCard.tsx
+++ b/src/components/PollCard/PollCard.tsx
@@ -8,16 +8,12 @@ import {
   CardHeader
 } from '@material-ui/core/';
 import { Poll } from '../../types';
+import PercentageBar from './PercentageBar';
 
 interface PropTypes {
   poll: Poll;
 }
 
-interface PercentageBarPropTypes {
-  value: number;
-  which: 'left' | 'right';
-}
-
 const useStyles = makeStyles(theme => ({
   root: {
     maxWidth: theme.spacing(75),
@@ -31,35 +27,9 @@ const useStyles = makeStyles(theme => ({
   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<PercentageBarPropTypes> = ({ value, which }) => {
-  const classes = useStyles();
-  const positionClassName = which === 'left' ? 'percentageLeft' : 'percentageRight';
-
-  return (
-    <div className={`${classes.percentage} ${classes[positionClassName]}`}>
-      {value}
-      %
-    </div>
-  );
-};
-
-
 const PollCard: React.FC<PropTypes> = ({ poll }) => {
   const classes = useStyles();
   const { author, contents } = poll;
@@ -96,5 +66,6 @@ const PollCard: React.FC<PropTypes> = ({ poll }) => {
   );
 };
 
+
 export default PollCard;
 
-- 
cgit v1.2.3


From c311c538a3442aed8d77449736f28be66feea57c Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Sun, 14 Jun 2020 22:42:52 +0300
Subject: feat: configure navigation

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

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

diff --git a/src/components/PollCard/PollCard.tsx b/src/components/PollCard/PollCard.tsx
index d5c99cc..7f587f3 100644
--- a/src/components/PollCard/PollCard.tsx
+++ b/src/components/PollCard/PollCard.tsx
@@ -5,13 +5,15 @@ import {
   CardActionArea,
   CardMedia,
   Avatar,
-  CardHeader
+  CardHeader,
+Link
 } from '@material-ui/core/';
 import { Poll } from '../../types';
 import PercentageBar from './PercentageBar';
 
 interface PropTypes {
   poll: Poll;
+  navigate: (prefix: string, id: string) => void;
 }
 
 const useStyles = makeStyles(theme => ({
@@ -30,19 +32,29 @@ const useStyles = makeStyles(theme => ({
 }));
 
 
-const PollCard: React.FC<PropTypes> = ({ poll }) => {
+const PollCard: React.FC<PropTypes> = ({ poll, navigate }) => {
   const classes = useStyles();
   const { author, contents } = poll;
 
+  const handleNavigate = () => {
+    navigate('profile', poll.author._id);
+  };
+
   const leftPercentage = Math.round(100 * (contents.left.votes / (contents.left.votes + contents.right.votes)));
   const rightPercentage = 100 - leftPercentage;
 
-
   return (
     <Card className={classes.root}>
       <CardHeader
         avatar={(
-          <Avatar aria-label="avatar" src={author.avatarUrl} alt={author.name[0].toUpperCase()} />
+          <Link href="#">
+            <Avatar
+              aria-label="avatar"
+              src={author.avatarUrl}
+              alt={author.name[0].toUpperCase()}
+              onClick={handleNavigate}
+            />
+          </Link>
         )}
         title={author.name}
       />
-- 
cgit v1.2.3


From 2a65284a385915818ca5f3e3b7354554e19af9cb Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Mon, 15 Jun 2020 15:52:40 +0300
Subject: style: fix eslint errors

---
 src/components/PollCard/PollCard.tsx | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

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

diff --git a/src/components/PollCard/PollCard.tsx b/src/components/PollCard/PollCard.tsx
index 7f587f3..23dc342 100644
--- a/src/components/PollCard/PollCard.tsx
+++ b/src/components/PollCard/PollCard.tsx
@@ -5,8 +5,7 @@ import {
   CardActionArea,
   CardMedia,
   Avatar,
-  CardHeader,
-Link
+  CardHeader
 } from '@material-ui/core/';
 import { Poll } from '../../types';
 import PercentageBar from './PercentageBar';
@@ -28,7 +27,7 @@ const useStyles = makeStyles(theme => ({
   },
   imagesBlock: {
     display: 'flex'
-  },
+  }
 }));
 
 
@@ -47,14 +46,12 @@ const PollCard: React.FC<PropTypes> = ({ poll, navigate }) => {
     <Card className={classes.root}>
       <CardHeader
         avatar={(
-          <Link href="#">
-            <Avatar
-              aria-label="avatar"
-              src={author.avatarUrl}
-              alt={author.name[0].toUpperCase()}
-              onClick={handleNavigate}
-            />
-          </Link>
+          <Avatar
+            aria-label="avatar"
+            src={author.avatarUrl}
+            alt={author.name[0].toUpperCase()}
+            onClick={handleNavigate}
+          />
         )}
         title={author.name}
       />
-- 
cgit v1.2.3

