Compare commits
4 Commits
main
...
inga/prett
Author | SHA1 | Date | |
---|---|---|---|
|
99c04e3dfd | ||
|
b9108d6b82 | ||
|
dff00d1e9d | ||
|
32f0b4a847 |
|
@ -92,7 +92,7 @@ export function AnswerItem(props: {
|
||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'text-2xl',
|
'text-2xl',
|
||||||
tradingAllowed(contract) ? 'text-green-500' : 'text-gray-500'
|
tradingAllowed(contract) ? 'text-teal-500' : 'text-gray-500'
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{probPercent}
|
{probPercent}
|
||||||
|
|
|
@ -42,8 +42,9 @@ export function QuickBet(props: {
|
||||||
contract: BinaryContract | PseudoNumericContract
|
contract: BinaryContract | PseudoNumericContract
|
||||||
user: User
|
user: User
|
||||||
className?: string
|
className?: string
|
||||||
|
noProbBar?: boolean
|
||||||
}) {
|
}) {
|
||||||
const { contract, user, className } = props
|
const { contract, user, className, noProbBar } = props
|
||||||
const { mechanism, outcomeType } = contract
|
const { mechanism, outcomeType } = contract
|
||||||
const isCpmm = mechanism === 'cpmm-1'
|
const isCpmm = mechanism === 'cpmm-1'
|
||||||
|
|
||||||
|
@ -162,20 +163,24 @@ export function QuickBet(props: {
|
||||||
<TriangleFillIcon
|
<TriangleFillIcon
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'mx-auto h-5 w-5',
|
'mx-auto h-5 w-5',
|
||||||
upHover ? 'text-green-500' : 'text-gray-400'
|
upHover ? 'text-teal-500' : 'text-gray-400'
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<TriangleFillIcon
|
<TriangleFillIcon
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'mx-auto h-5 w-5',
|
'mx-auto h-5 w-5',
|
||||||
upHover ? 'text-green-500' : 'text-gray-200'
|
upHover ? 'text-teal-500' : 'text-gray-200'
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<QuickOutcomeView contract={contract} previewProb={previewProb} />
|
<QuickOutcomeView
|
||||||
|
contract={contract}
|
||||||
|
previewProb={previewProb}
|
||||||
|
noProbBar={noProbBar}
|
||||||
|
/>
|
||||||
|
|
||||||
{/* Down bet triangle */}
|
{/* Down bet triangle */}
|
||||||
{outcomeType !== 'BINARY' && outcomeType !== 'PSEUDO_NUMERIC' ? (
|
{outcomeType !== 'BINARY' && outcomeType !== 'PSEUDO_NUMERIC' ? (
|
||||||
|
@ -266,8 +271,9 @@ function QuickOutcomeView(props: {
|
||||||
contract: Contract
|
contract: Contract
|
||||||
previewProb?: number
|
previewProb?: number
|
||||||
caption?: 'chance' | 'expected'
|
caption?: 'chance' | 'expected'
|
||||||
|
noProbBar?: boolean
|
||||||
}) {
|
}) {
|
||||||
const { contract, previewProb, caption } = props
|
const { contract, previewProb, caption, noProbBar } = props
|
||||||
const { outcomeType } = contract
|
const { outcomeType } = contract
|
||||||
const isPseudoNumeric = outcomeType === 'PSEUDO_NUMERIC'
|
const isPseudoNumeric = outcomeType === 'PSEUDO_NUMERIC'
|
||||||
|
|
||||||
|
@ -305,7 +311,7 @@ function QuickOutcomeView(props: {
|
||||||
<Col className={clsx('items-center text-3xl', textColor)}>
|
<Col className={clsx('items-center text-3xl', textColor)}>
|
||||||
{override ?? display}
|
{override ?? display}
|
||||||
{caption && <div className="text-base">{caption}</div>}
|
{caption && <div className="text-base">{caption}</div>}
|
||||||
<ProbBar contract={contract} previewProb={previewProb} />
|
{!noProbBar && <ProbBar contract={contract} previewProb={previewProb} />}
|
||||||
</Col>
|
</Col>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import { track } from 'web/lib/service/analytics'
|
||||||
export function embedContractCode(contract: Contract) {
|
export function embedContractCode(contract: Contract) {
|
||||||
const title = contract.question
|
const title = contract.question
|
||||||
const src = `https://${DOMAIN}/embed${contractPath(contract)}`
|
const src = `https://${DOMAIN}/embed${contractPath(contract)}`
|
||||||
return `<iframe src="${src}" title="${title}" frameborder="0"></iframe>`
|
return `<iframe src="${src}" title="${title}"></iframe>`
|
||||||
}
|
}
|
||||||
|
|
||||||
export function embedContractGridCode(contracts: Contract[]) {
|
export function embedContractGridCode(contracts: Contract[]) {
|
||||||
|
|
|
@ -27,6 +27,10 @@ import {
|
||||||
tradingAllowed,
|
tradingAllowed,
|
||||||
} from 'web/lib/firebase/contracts'
|
} from 'web/lib/firebase/contracts'
|
||||||
import Custom404 from '../../404'
|
import Custom404 from '../../404'
|
||||||
|
import { useUser } from 'web/hooks/use-user'
|
||||||
|
import { QuickBet } from 'web/components/contract/quick-bet'
|
||||||
|
import { contractMetrics } from 'common/contract-details'
|
||||||
|
import Image from 'next/future/image'
|
||||||
|
|
||||||
export const getStaticProps = fromPropz(getStaticPropz)
|
export const getStaticProps = fromPropz(getStaticPropz)
|
||||||
export async function getStaticPropz(props: {
|
export async function getStaticPropz(props: {
|
||||||
|
@ -74,66 +78,87 @@ export function ContractEmbed(props: { contract: Contract; bets: Bet[] }) {
|
||||||
creatorId: contract.creatorId,
|
creatorId: contract.creatorId,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { creatorName, creatorUsername, creatorId, creatorAvatarUrl } = contract
|
||||||
|
const { resolvedDate } = contractMetrics(contract)
|
||||||
const isBinary = outcomeType === 'BINARY'
|
const isBinary = outcomeType === 'BINARY'
|
||||||
const isPseudoNumeric = outcomeType === 'PSEUDO_NUMERIC'
|
const isPseudoNumeric = outcomeType === 'PSEUDO_NUMERIC'
|
||||||
|
|
||||||
const href = `https://${DOMAIN}${contractPath(contract)}`
|
const href = `https://${DOMAIN}${contractPath(contract)}`
|
||||||
|
|
||||||
const { setElem, height: graphHeight } = useMeasureSize()
|
const { setElem, width: graphWidth, height: graphHeight } = useMeasureSize()
|
||||||
|
|
||||||
const [betPanelOpen, setBetPanelOpen] = useState(false)
|
const [betPanelOpen, setBetPanelOpen] = useState(false)
|
||||||
|
|
||||||
const [probAfter, setProbAfter] = useState<number>()
|
const [probAfter, setProbAfter] = useState<number>()
|
||||||
|
|
||||||
return (
|
const user = useUser()
|
||||||
<Col className="h-[100vh] w-full bg-white">
|
if (user && (isBinary || isPseudoNumeric)) {
|
||||||
<Row className="justify-between gap-4 px-2">
|
return (
|
||||||
<div className="text-xl text-indigo-700 md:text-2xl">
|
<Col className="border-greyscale-2 h-full w-full justify-between overflow-hidden rounded-lg border-2 bg-white p-4">
|
||||||
<SiteLink href={href}>{question}</SiteLink>
|
<Row className="mb-1 justify-between">
|
||||||
|
<MarketSubheader contract={contract} disabled />
|
||||||
|
<SiteLink href={href} className="mt-0">
|
||||||
|
<Image height={32} width={32} alt="Manifold logo" src="/logo.png" />
|
||||||
|
</SiteLink>
|
||||||
|
</Row>
|
||||||
|
<SiteLink href={href} className="text-md text-indigo-700 md:text-xl">
|
||||||
|
{question}
|
||||||
|
</SiteLink>
|
||||||
|
<Row>
|
||||||
|
<div className="min-h-150 mx-1 mb-2 h-full flex-1" ref={setElem}>
|
||||||
|
<ContractChart contract={contract} bets={bets} height={150} />
|
||||||
|
</div>
|
||||||
|
<QuickBet
|
||||||
|
user={user}
|
||||||
|
contract={contract}
|
||||||
|
noProbBar={true}
|
||||||
|
className="mx-auto -mr-5"
|
||||||
|
/>
|
||||||
|
</Row>
|
||||||
|
</Col>
|
||||||
|
)
|
||||||
|
} else
|
||||||
|
return (
|
||||||
|
<Col className="border-greyscale-2 h-full w-full justify-between overflow-hidden rounded-lg border-2 bg-white p-4">
|
||||||
|
<Row className="mb-1 justify-between">
|
||||||
|
<MarketSubheader contract={contract} disabled />
|
||||||
|
<SiteLink href={href} className="mt-0">
|
||||||
|
<Image height={32} width={32} alt="Manifold logo" src="/logo.png" />
|
||||||
|
</SiteLink>
|
||||||
|
</Row>
|
||||||
|
<Row className="justify-between gap-4">
|
||||||
|
<Col>
|
||||||
|
<div className="text-md text-indigo-700 md:text-xl">
|
||||||
|
<SiteLink href={href}>{question}</SiteLink>
|
||||||
|
</div>
|
||||||
|
</Col>
|
||||||
|
<Col>
|
||||||
|
{!user && isBinary && (
|
||||||
|
<BinaryResolutionOrChance
|
||||||
|
contract={contract}
|
||||||
|
probAfter={probAfter}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{!user && isPseudoNumeric && (
|
||||||
|
<PseudoNumericResolutionOrExpectation contract={contract} />
|
||||||
|
)}
|
||||||
|
|
||||||
|
{outcomeType === 'FREE_RESPONSE' && (
|
||||||
|
<FreeResponseResolutionOrChance
|
||||||
|
contract={contract}
|
||||||
|
truncate="long"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{outcomeType === 'NUMERIC' && (
|
||||||
|
<NumericResolutionOrExpectation contract={contract} />
|
||||||
|
)}
|
||||||
|
<Spacer h={3} />
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
<div className="mx-1 mb-2 min-h-0 flex-1" ref={setElem}>
|
||||||
|
<ContractChart contract={contract} bets={bets} height={150} />
|
||||||
</div>
|
</div>
|
||||||
{isBinary && (
|
</Col>
|
||||||
<BinaryResolutionOrChance contract={contract} probAfter={probAfter} />
|
)
|
||||||
)}
|
|
||||||
|
|
||||||
{isPseudoNumeric && (
|
|
||||||
<PseudoNumericResolutionOrExpectation contract={contract} />
|
|
||||||
)}
|
|
||||||
|
|
||||||
{outcomeType === 'FREE_RESPONSE' && (
|
|
||||||
<FreeResponseResolutionOrChance contract={contract} truncate="long" />
|
|
||||||
)}
|
|
||||||
|
|
||||||
{outcomeType === 'NUMERIC' && (
|
|
||||||
<NumericResolutionOrExpectation contract={contract} />
|
|
||||||
)}
|
|
||||||
</Row>
|
|
||||||
<Spacer h={3} />
|
|
||||||
<Row className="items-center justify-between gap-4 px-2">
|
|
||||||
<MarketSubheader contract={contract} disabled />
|
|
||||||
|
|
||||||
{(isBinary || isPseudoNumeric) &&
|
|
||||||
tradingAllowed(contract) &&
|
|
||||||
!betPanelOpen && (
|
|
||||||
<Button color="gradient" onClick={() => setBetPanelOpen(true)}>
|
|
||||||
Predict
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</Row>
|
|
||||||
|
|
||||||
<Spacer h={2} />
|
|
||||||
|
|
||||||
{(isBinary || isPseudoNumeric) && betPanelOpen && (
|
|
||||||
<BetInline
|
|
||||||
contract={contract as any}
|
|
||||||
setProbAfter={setProbAfter}
|
|
||||||
onClose={() => setBetPanelOpen(false)}
|
|
||||||
className="self-center"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="mx-1 mb-2 min-h-0 flex-1" ref={setElem}>
|
|
||||||
<ContractChart contract={contract} bets={bets} height={graphHeight} />
|
|
||||||
</div>
|
|
||||||
</Col>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user