From d1fab9937fdab2458d6a13f0840006dc44b0db3c Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Sat, 21 May 2022 13:26:34 -0700 Subject: [PATCH] Align bet icons with the percentages --- web/components/contract/contract-card.tsx | 107 ++++++++++--------- web/components/contract/contract-details.tsx | 106 +++++++++++------- 2 files changed, 122 insertions(+), 91 deletions(-) diff --git a/web/components/contract/contract-card.tsx b/web/components/contract/contract-card.tsx index 42585b25..7ecb3b6d 100644 --- a/web/components/contract/contract-card.tsx +++ b/web/components/contract/contract-card.tsx @@ -25,7 +25,11 @@ import { OUTCOME_TO_COLOR, } from '../outcome-label' import { getOutcomeProbability, getTopAnswer } from 'common/calculate' -import { AbbrContractDetails } from './contract-details' +import { + AbbrContractDetails, + AvatarDetails, + MiscDetails, +} from './contract-details' import { getExpectedValue, getValueFromBucket } from 'common/calculate-dpm' import { ArrowCircleUpIcon, @@ -33,6 +37,7 @@ import { StarIcon, PaperAirplaneIcon, } from '@heroicons/react/outline' +import { PaperAirplaneIcon as SolidPlaneIcon } from '@heroicons/react/solid' // Return a number from 0 to 1 for this contract // Resolved contracts are set to 1, for coloring purposes (even if NO) @@ -56,6 +61,9 @@ function getNumericScale(contract: NumericContract) { } function getColor(contract: Contract) { + // TODO: Not sure why eg green-400 doesn't work here; try upgrading Tailwind + // TODO: Try injecting a gradient here + // return 'primary' const { resolution } = contract if (resolution) { return ( @@ -103,66 +111,64 @@ export function ContractCard(props: { - - +

{question}

- - {outcomeType === 'BINARY' && ( - - )} + - {outcomeType === 'NUMERIC' && ( - - )} + + {contract.createdTime % 3 == 0 ? ( + + ) : ( + + )} + + {outcomeType === 'BINARY' && ( + + )} + + {outcomeType === 'NUMERIC' && ( + + )} + + {outcomeType === 'FREE_RESPONSE' && ( + } + truncate="long" + /> + )} + + {contract.createdTime % 3 == 2 ? ( + + ) : ( + + )} +
- {outcomeType === 'FREE_RESPONSE' && ( - } - truncate="long" - /> - )} - - {/* Show a row with 3 clickable icons: star, upvote, downvote */} -
- - - -
-
) : ( <> -
+
{formatLargeNumber(getExpectedValue(contract))}
-
expected
+
expected
)} diff --git a/web/components/contract/contract-details.tsx b/web/components/contract/contract-details.tsx index 6a8f5c9f..fd5e6968 100644 --- a/web/components/contract/contract-details.tsx +++ b/web/components/contract/contract-details.tsx @@ -5,7 +5,9 @@ import { PencilIcon, CurrencyDollarIcon, TrendingUpIcon, + StarIcon, } from '@heroicons/react/outline' +import { StarIcon as SolidStarIcon } from '@heroicons/react/solid' import { Row } from '../layout/row' import { formatMoney } from 'common/util/format' import { UserLink } from '../user-page' @@ -26,20 +28,13 @@ import NewContractBadge from '../new-contract-badge' import { CATEGORY_LIST } from 'common/categories' import { TagsList } from '../tags-list' -export function AbbrContractDetails(props: { +export function MiscDetails(props: { contract: Contract showHotVolume?: boolean showCloseTime?: boolean }) { const { contract, showHotVolume, showCloseTime } = props - const { - volume, - volume24Hours, - creatorName, - creatorUsername, - closeTime, - tags, - } = contract + const { volume, volume24Hours, closeTime, tags } = contract const { volumeLabel } = contractMetrics(contract) // Show at most one category that this contract is tagged by const categories = CATEGORY_LIST.filter((category) => @@ -47,39 +42,68 @@ export function AbbrContractDetails(props: { ).slice(0, 1) return ( - + + {contract.createdTime % 3 == 1 ? ( + + ) : ( + + )} + + {categories.length > 0 && ( + + )} + + {showHotVolume ? ( + + {formatMoney(volume24Hours)} + + ) : showCloseTime ? ( + + + {(closeTime || 0) < Date.now() ? 'Closed' : 'Closes'}{' '} + {fromNow(closeTime || 0)} + + ) : volume > 0 ? ( + {volumeLabel} + ) : ( + + )} + + ) +} + +export function AvatarDetails(props: { contract: Contract }) { + const { contract } = props + const { creatorName, creatorUsername } = contract + + return ( + + + + + ) +} + +export function AbbrContractDetails(props: { + contract: Contract + showHotVolume?: boolean + showCloseTime?: boolean +}) { + const { contract, showHotVolume, showCloseTime } = props + return ( + - - - - + - - {categories.length > 0 && ( - - )} - - {showHotVolume ? ( - - {' '} - {formatMoney(volume24Hours)} - - ) : showCloseTime ? ( - - - {(closeTime || 0) < Date.now() ? 'Closed' : 'Closes'}{' '} - {fromNow(closeTime || 0)} - - ) : volume > 0 ? ( - {volumeLabel} - ) : ( - - )} - + ) @@ -93,7 +117,7 @@ export function ContractDetails(props: { }) { const { contract, bets, isCreator, disabled } = props const { closeTime, creatorName, creatorUsername } = contract - const { volumeLabel, createdDate, resolvedDate } = contractMetrics(contract) + const { volumeLabel, resolvedDate } = contractMetrics(contract) return (