aboutsummaryrefslogtreecommitdiff
path: root/src/PollCard
diff options
context:
space:
mode:
authorilyayudovin <46264063+ilyayudovin@users.noreply.github.com>2020-06-07 20:21:59 +0300
committerGitHub <noreply@github.com>2020-06-07 20:21:59 +0300
commitfa3f95443c47541e9a7061ea1d3fd079c40b1fa8 (patch)
treeff56c75b023fa166781275adfd65ea917d275968 /src/PollCard
parentb8b848dfd6e3843c6b455c8344320dcd187b72da (diff)
parent98442762c1bbdf4e4aff317ca8ec660b6817418f (diff)
downloadwhich-ui-fa3f95443c47541e9a7061ea1d3fd079c40b1fa8.tar.gz
Merge pull request #12 from ilyayudovin/feed
Add Feed and fucntionality for creating polls
Diffstat (limited to 'src/PollCard')
-rw-r--r--src/PollCard/PollCard.tsx26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/PollCard/PollCard.tsx b/src/PollCard/PollCard.tsx
index 07449fb..588714a 100644
--- a/src/PollCard/PollCard.tsx
+++ b/src/PollCard/PollCard.tsx
@@ -9,20 +9,24 @@ import {
} from '@material-ui/core/';
import { Poll } from '../types';
+interface PropTypes {
+ poll: Poll;
+}
+
interface PercentageBarPropTypes {
value: number;
which: 'left' | 'right';
}
-const useStyles = makeStyles({
+const useStyles = makeStyles(theme => ({
root: {
- maxWidth: 600,
- height: 500,
+ maxWidth: theme.spacing(75),
+ height: theme.spacing(63),
margin: '20px auto'
},
images: {
- height: 400,
- width: 300
+ height: theme.spacing(50),
+ width: theme.spacing(38)
},
imagesBlock: {
display: 'flex'
@@ -39,7 +43,7 @@ const useStyles = makeStyles({
percentageRight: {
right: 30
}
-});
+}));
const PercentageBar: React.FC<PercentageBarPropTypes> = ({ value, which }) => {
@@ -55,12 +59,14 @@ const PercentageBar: React.FC<PercentageBarPropTypes> = ({ value, which }) => {
};
-const PollCard: React.FC<Poll> = ({ author, contents: { left, right } }) => {
+const PollCard: React.FC<PropTypes> = ({ poll }) => {
const classes = useStyles();
+ const { author, contents } = poll;
- const leftPercentage = Math.round(100 * (left.votes / (left.votes + right.votes)));
+ const leftPercentage = Math.round(100 * (contents.left.votes / (contents.left.votes + contents.right.votes)));
const rightPercentage = 100 - leftPercentage;
+
return (
<Card className={classes.root}>
<CardHeader
@@ -75,14 +81,14 @@ const PollCard: React.FC<Poll> = ({ author, contents: { left, right } }) => {
<CardActionArea>
<CardMedia
className={classes.images}
- image={left.url}
+ image={contents.left.url}
/>
<PercentageBar value={leftPercentage} which="left" />
</CardActionArea>
<CardActionArea>
<CardMedia
className={classes.images}
- image={right.url}
+ image={contents.right.url}
/>
<PercentageBar value={rightPercentage} which="right" />
</CardActionArea>