From 9240cd3d1c533402f0431d7ca5fb78bc8781c6d0 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Wed, 13 Jul 2022 18:23:03 -0500 Subject: [PATCH] Bet panel: Quick vs Limit pill buttons. Also, pill buttons for Yes vs No. --- web/components/bet-panel.tsx | 67 +++++++++++++++++--------- web/components/buttons/pill-button.tsx | 27 +++++++++++ web/components/yes-no-selector.tsx | 62 ------------------------ 3 files changed, 71 insertions(+), 85 deletions(-) create mode 100644 web/components/buttons/pill-button.tsx diff --git a/web/components/bet-panel.tsx b/web/components/bet-panel.tsx index c8356a06..bd2bfebb 100644 --- a/web/components/bet-panel.tsx +++ b/web/components/bet-panel.tsx @@ -8,7 +8,6 @@ import { CPMMBinaryContract, PseudoNumericContract } from 'common/contract' import { Col } from './layout/col' import { Row } from './layout/row' import { Spacer } from './layout/spacer' -import { YesNoSelector } from './yes-no-selector' import { formatMoney, formatMoneyWithDecimals, @@ -41,6 +40,7 @@ import { removeUndefinedProps } from 'common/util/object' import { useUnfilledBets } from 'web/hooks/use-bets' import { LimitBets } from './limit-bets' import { BucketInput } from './bucket-input' +import { PillButton } from './buttons/pill-button' export function BetPanel(props: { contract: CPMMBinaryContract | PseudoNumericContract @@ -54,10 +54,6 @@ export function BetPanel(props: { const { sharesOutcome } = useSaveBinaryShares(contract, userBets) const [isLimitOrder, setIsLimitOrder] = useState(false) - const toggleLimitOrder = () => { - setIsLimitOrder(!isLimitOrder) - track('toggle limit order') - } const showLimitOrders = (isLimitOrder && unfilledBets.length > 0) || yourUnfilledBets.length > 0 @@ -71,21 +67,33 @@ export function BetPanel(props: { /> - -
- {isLimitOrder ? <>Limit order : <>Place your bet} -
- + +
Bet
+ + { + setIsLimitOrder(false) + track('select quick order') + }} + > + Quick + + { + setIsLimitOrder(true) + track('select limit order') + }} + > + Limit + +
- onBetChoice(choice)} - isPseudoNumeric={isPseudoNumeric} - /> +
Direction
+ + onBetChoice('YES')} + big + color="bg-primary" + > + {isPseudoNumeric ? 'Higher' : 'Yes'} + + onBetChoice('NO')} + big + color="bg-red-400" + > + {isPseudoNumeric ? 'Lower' : 'No'} + + +
Amount
void + color?: string + big?: boolean + children: ReactNode +}) { + const { children, selected, onSelect, color, big } = props + + return ( + + ) +} diff --git a/web/components/yes-no-selector.tsx b/web/components/yes-no-selector.tsx index 3b3cc21d..dda97c0c 100644 --- a/web/components/yes-no-selector.tsx +++ b/web/components/yes-no-selector.tsx @@ -5,68 +5,6 @@ import { Col } from './layout/col' import { Row } from './layout/row' import { resolution } from 'common/contract' -export function YesNoSelector(props: { - selected?: 'YES' | 'NO' - onSelect: (selected: 'YES' | 'NO') => void - className?: string - btnClassName?: string - replaceYesButton?: React.ReactNode - replaceNoButton?: React.ReactNode - isPseudoNumeric?: boolean -}) { - const { - selected, - onSelect, - className, - btnClassName, - replaceNoButton, - replaceYesButton, - isPseudoNumeric, - } = props - - const commonClassNames = - 'inline-flex items-center justify-center rounded-3xl border-2 p-2' - - return ( - - {replaceYesButton ? ( - replaceYesButton - ) : ( - - )} - {replaceNoButton ? ( - replaceNoButton - ) : ( - - )} - - ) -} - export function YesNoCancelSelector(props: { selected: resolution | undefined onSelect: (selected: resolution) => void