Compare commits
1 Commits
main
...
binary-ove
Author | SHA1 | Date | |
---|---|---|---|
|
9f1b7e8902 |
|
@ -2,7 +2,8 @@ import clsx from 'clsx'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { Row } from '../layout/row'
|
import { Row } from '../layout/row'
|
||||||
import { formatLargeNumber, formatPercent } from 'common/util/format'
|
import { formatLargeNumber, formatPercent } from 'common/util/format'
|
||||||
import { contractPath, getBinaryProbPercent } from 'web/lib/firebase/contracts'
|
import { getBinaryProb } from 'common/contract-details'
|
||||||
|
import { contractPath } from 'web/lib/firebase/contracts'
|
||||||
import { Col } from '../layout/col'
|
import { Col } from '../layout/col'
|
||||||
import {
|
import {
|
||||||
BinaryContract,
|
BinaryContract,
|
||||||
|
@ -200,13 +201,14 @@ export function BinaryResolutionOrChance(props: {
|
||||||
contract: BinaryContract
|
contract: BinaryContract
|
||||||
large?: boolean
|
large?: boolean
|
||||||
className?: string
|
className?: string
|
||||||
probAfter?: number // 0 to 1
|
probNow?: number
|
||||||
|
probAfter?: number
|
||||||
}) {
|
}) {
|
||||||
const { contract, large, className, probAfter } = props
|
const { contract, large, className, probNow, probAfter } = props
|
||||||
const { resolution } = contract
|
const { resolution } = contract
|
||||||
const textColor = `text-${getColor(contract)}`
|
const textColor = `text-${getColor(contract)}`
|
||||||
|
|
||||||
const before = getBinaryProbPercent(contract)
|
const before = formatPercent(probNow ?? getBinaryProb(contract))
|
||||||
const after = probAfter && formatPercent(probAfter)
|
const after = probAfter && formatPercent(probAfter)
|
||||||
const probChanged = before !== after
|
const probChanged = before !== after
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import React from 'react'
|
import React, { useState } from 'react'
|
||||||
|
|
||||||
import { tradingAllowed } from 'web/lib/firebase/contracts'
|
import { tradingAllowed } from 'web/lib/firebase/contracts'
|
||||||
import { Col } from '../layout/col'
|
import { Col } from '../layout/col'
|
||||||
|
@ -29,6 +29,7 @@ import {
|
||||||
BinaryContract,
|
BinaryContract,
|
||||||
} from 'common/contract'
|
} from 'common/contract'
|
||||||
import { ContractDetails } from './contract-details'
|
import { ContractDetails } from './contract-details'
|
||||||
|
import { useEvent } from 'web/hooks/use-event'
|
||||||
|
|
||||||
const OverviewQuestion = (props: { text: string }) => (
|
const OverviewQuestion = (props: { text: string }) => (
|
||||||
<Linkify className="text-lg text-indigo-700 sm:text-2xl" text={props.text} />
|
<Linkify className="text-lg text-indigo-700 sm:text-2xl" text={props.text} />
|
||||||
|
@ -73,6 +74,11 @@ const NumericOverview = (props: { contract: NumericContract }) => {
|
||||||
|
|
||||||
const BinaryOverview = (props: { contract: BinaryContract; bets: Bet[] }) => {
|
const BinaryOverview = (props: { contract: BinaryContract; bets: Bet[] }) => {
|
||||||
const { contract, bets } = props
|
const { contract, bets } = props
|
||||||
|
const [displayProb, setDisplayProb] = useState<number>()
|
||||||
|
const onChartMouseOver = useEvent((p: { y: number } | undefined) => {
|
||||||
|
setDisplayProb(p?.y)
|
||||||
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Col className="gap-1 md:gap-2">
|
<Col className="gap-1 md:gap-2">
|
||||||
<Col className="gap-1 px-2">
|
<Col className="gap-1 px-2">
|
||||||
|
@ -82,11 +88,16 @@ const BinaryOverview = (props: { contract: BinaryContract; bets: Bet[] }) => {
|
||||||
<BinaryResolutionOrChance
|
<BinaryResolutionOrChance
|
||||||
className="flex items-end"
|
className="flex items-end"
|
||||||
contract={contract}
|
contract={contract}
|
||||||
|
probNow={displayProb}
|
||||||
large
|
large
|
||||||
/>
|
/>
|
||||||
</Row>
|
</Row>
|
||||||
</Col>
|
</Col>
|
||||||
<BinaryContractChart contract={contract} bets={bets} />
|
<BinaryContractChart
|
||||||
|
contract={contract}
|
||||||
|
bets={bets}
|
||||||
|
onMouseOver={onChartMouseOver}
|
||||||
|
/>
|
||||||
<Row className="items-center justify-between gap-4 xl:hidden">
|
<Row className="items-center justify-between gap-4 xl:hidden">
|
||||||
{tradingAllowed(contract) && (
|
{tradingAllowed(contract) && (
|
||||||
<BinaryMobileBetting contract={contract} />
|
<BinaryMobileBetting contract={contract} />
|
||||||
|
|
Loading…
Reference in New Issue
Block a user