From a204380f5744004f5877d30b65ba00ee49cf45d6 Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Tue, 24 May 2022 08:09:13 -0700 Subject: [PATCH] Animate the prob bar change too --- web/components/contract/contract-card.tsx | 1 - web/components/contract/quick-bet.tsx | 42 +++++++++++------------ 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/web/components/contract/contract-card.tsx b/web/components/contract/contract-card.tsx index e0f8c040..4881709f 100644 --- a/web/components/contract/contract-card.tsx +++ b/web/components/contract/contract-card.tsx @@ -94,7 +94,6 @@ export function ContractCard(props: { )} - ) diff --git a/web/components/contract/quick-bet.tsx b/web/components/contract/quick-bet.tsx index 6cd62cd1..013c94ea 100644 --- a/web/components/contract/quick-bet.tsx +++ b/web/components/contract/quick-bet.tsx @@ -51,24 +51,20 @@ export function QuickBet(props: { contract: Contract }) { const [upHover, setUpHover] = useState(false) const [downHover, setDownHover] = useState(false) - let override + let previewProb = undefined try { - override = upHover - ? formatPercent( - getOutcomeProbabilityAfterBet( - contract, - quickOutcome(contract, 'UP') || '', - 10 - ) + previewProb = upHover + ? getOutcomeProbabilityAfterBet( + contract, + quickOutcome(contract, 'UP') || '', + 10 ) : downHover - ? formatPercent( - 1 - - getOutcomeProbabilityAfterBet( - contract, - quickOutcome(contract, 'DOWN') || '', - 10 - ) + ? 1 - + getOutcomeProbabilityAfterBet( + contract, + quickOutcome(contract, 'DOWN') || '', + 10 ) : undefined } catch (e) { @@ -144,7 +140,7 @@ export function QuickBet(props: { contract: Contract }) { )} - + {/* Down bet triangle */}
@@ -172,10 +168,11 @@ export function QuickBet(props: { contract: Contract }) { ) } -export function ProbBar(props: { contract: Contract }) { - const { contract } = props +export function ProbBar(props: { contract: Contract; previewProb?: number }) { + const { contract, previewProb } = props + // TODO: Switch preview color as it changes from green to red const color = getColor(contract) - const prob = getProb(contract) + const prob = previewProb ?? getProb(contract) return ( <>
{outcomeType === 'BINARY' && ( @@ -235,6 +234,7 @@ export function QuickOutcomeView(props: { override={override} /> )} + ) }