From 9502bc67b2c327a564f19157893d88ba79a6ff72 Mon Sep 17 00:00:00 2001 From: Szymon Szlachtowicz <38212223+Szymx95@users.noreply.github.com> Date: Fri, 17 Sep 2021 11:08:42 +0200 Subject: [PATCH] Fix vote chart (#77) --- .../components/ProposalVoteCard/VoteChart.tsx | 97 ++++++++++--------- .../src/components/VotePropose.tsx | 8 +- 2 files changed, 56 insertions(+), 49 deletions(-) diff --git a/packages/proposal-components/src/components/ProposalVoteCard/VoteChart.tsx b/packages/proposal-components/src/components/ProposalVoteCard/VoteChart.tsx index ddcbe65..516feb9 100644 --- a/packages/proposal-components/src/components/ProposalVoteCard/VoteChart.tsx +++ b/packages/proposal-components/src/components/ProposalVoteCard/VoteChart.tsx @@ -46,52 +46,22 @@ export function VoteChart({ votingRoom, proposingAmount, selectedVote, isAnimati - - - {' '} - {isAnimation && proposingAmount && selectedVote && selectedVote === 0 ? ( - - ) : ( - addCommas(votingRoom.totalVotesAgainst.toNumber()) - )}{' '} - ABC - - + voteType={2} + mobileVersion={mobileVersion} + totalVotes={votingRoom.totalVotesAgainst.toNumber()} + won={voteWinner === 2} + selected={isAnimation && selectedVote === 0} + proposingAmount={proposingAmount} + /> {!voteWinner && {formatTimeLeft(timeLeft)}} - - - {' '} - {isAnimation && proposingAmount && selectedVote && selectedVote === 1 ? ( - - ) : ( - addCommas(votingRoom.totalVotesFor.toNumber()) - )}{' '} - ABC - - + voteType={1} + mobileVersion={mobileVersion} + totalVotes={votingRoom.totalVotesFor.toNumber()} + won={voteWinner === 1} + selected={isAnimation && selectedVote === 1} + proposingAmount={proposingAmount} + /> + + + {' '} + {proposingAmount && selected ? ( + + ) : ( + addCommas(totalVotes) + )}{' '} + ABC + + + ) +} + const Votes = styled.div` display: flex; flex-direction: column; @@ -135,7 +142,7 @@ const VotesChart = styled.div` } ` -const VoteBox = styled.div` +const VoteBoxWrapper = styled.div` display: flex; flex-direction: column; justify-content: space-between; diff --git a/packages/proposal-components/src/components/VotePropose.tsx b/packages/proposal-components/src/components/VotePropose.tsx index 920540b..c51929d 100644 --- a/packages/proposal-components/src/components/VotePropose.tsx +++ b/packages/proposal-components/src/components/VotePropose.tsx @@ -12,7 +12,6 @@ export interface VoteProposingProps { export function VotePropose({ availableAmount, proposingAmount, setProposingAmount }: VoteProposingProps) { const [inputFocused, setInputFocused] = useState(false) - const disabled = useMemo(() => availableAmount === 0, [availableAmount]) const step = useMemo( () => (availableAmount < 100 ? 1 : 10 ** (Math.floor(Math.log10(availableAmount)) - 2)), [availableAmount] @@ -57,9 +56,10 @@ export function VotePropose({ availableAmount, proposingAmount, setProposingAmou value={proposingAmount} onChange={sliderChange} style={{ - background: disabled - ? '#EDF1FF' - : `linear-gradient(90deg, #0F3595 0% ${progress}, #EDF1FF ${progress} 100%)`, + background: + availableAmount === 0 + ? '#EDF1FF' + : `linear-gradient(90deg, #0F3595 0% ${progress}, #EDF1FF ${progress} 100%)`, }} />