diff options
author | eug-vs <eug-vs@keemail.me> | 2020-06-07 16:44:29 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-06-07 16:44:29 +0300 |
commit | 6153da81564c95f21f01a296dcd21b89f062626d (patch) | |
tree | 5d8902f6fc9b9ef41a732bdd85625be28d4ae00a | |
parent | 48ece125761c4dce8175265c3b4de717a249eb0e (diff) | |
download | which-ui-6153da81564c95f21f01a296dcd21b89f062626d.tar.gz |
feat: move Poll type to separate file :label:
-rw-r--r-- | src/PollCard/PollCard.tsx | 21 | ||||
-rw-r--r-- | src/types.d.ts | 16 |
2 files changed, 19 insertions, 18 deletions
diff --git a/src/PollCard/PollCard.tsx b/src/PollCard/PollCard.tsx index ee81b7d..07449fb 100644 --- a/src/PollCard/PollCard.tsx +++ b/src/PollCard/PollCard.tsx @@ -7,29 +7,13 @@ import { Avatar, CardHeader } from '@material-ui/core/'; - -interface ImageData { - url: string; - votes: number; -} - -interface PropTypes { - author: { - name: string; - avatarUrl: string; - }; - contents: { - left: ImageData; - right: ImageData; - }; -} +import { Poll } from '../types'; interface PercentageBarPropTypes { value: number; which: 'left' | 'right'; } - const useStyles = makeStyles({ root: { maxWidth: 600, @@ -71,7 +55,7 @@ const PercentageBar: React.FC<PercentageBarPropTypes> = ({ value, which }) => { }; -const PollCard: React.FC<PropTypes> = ({ author, contents: { left, right } }) => { +const PollCard: React.FC<Poll> = ({ author, contents: { left, right } }) => { const classes = useStyles(); const leftPercentage = Math.round(100 * (left.votes / (left.votes + right.votes))); @@ -106,5 +90,6 @@ const PollCard: React.FC<PropTypes> = ({ author, contents: { left, right } }) => </Card> ); }; + export default PollCard; diff --git a/src/types.d.ts b/src/types.d.ts new file mode 100644 index 0000000..9b4d16a --- /dev/null +++ b/src/types.d.ts @@ -0,0 +1,16 @@ +interface ImageData { + url: string; + votes: number; +} + +export interface Poll { + author: { + name: string; + avatarUrl: string; + }; + contents: { + left: ImageData; + right: ImageData; + }; +} + |