Include "Buy" tag inside buttons

This commit is contained in:
Austin Chen 2022-01-26 16:28:57 -06:00
parent 8e51f68430
commit c047365bb4
4 changed files with 16 additions and 9 deletions

View File

@ -5,9 +5,13 @@ import { Contract } from '../lib/firebase/contracts'
import { BetPanel } from './bet-panel' import { BetPanel } from './bet-panel'
import { Row } from './layout/row' import { Row } from './layout/row'
import { YesNoSelector } from './yes-no-selector' import { YesNoSelector } from './yes-no-selector'
import clsx from 'clsx'
// Inline version of a bet panel. Opens BetPanel in a new modal. // Inline version of a bet panel. Opens BetPanel in a new modal.
export default function BetRow(props: { contract: Contract }) { export default function BetRow(props: {
contract: Contract
className?: string
}) {
const [open, setOpen] = useState(false) const [open, setOpen] = useState(false)
const [betChoice, setBetChoice] = useState<'YES' | 'NO' | undefined>( const [betChoice, setBetChoice] = useState<'YES' | 'NO' | undefined>(
undefined undefined
@ -15,11 +19,10 @@ export default function BetRow(props: { contract: Contract }) {
return ( return (
<> <>
<div className="-mt-2 text-xl -mx-4"> <div className={clsx(props.className)}>
<Row className="items-center gap-2 justify-center"> <Row className="items-center gap-2 justify-center">
Buy
<YesNoSelector <YesNoSelector
className="w-72" className="w-60"
onSelect={(choice) => { onSelect={(choice) => {
setOpen(true) setOpen(true)
setBetChoice(choice) setBetChoice(choice)
@ -50,7 +53,7 @@ export function Modal(props: {
<Transition.Root show={open} as={Fragment}> <Transition.Root show={open} as={Fragment}>
<Dialog <Dialog
as="div" as="div"
className="fixed z-10 inset-0 overflow-y-auto" className="fixed z-40 inset-0 overflow-y-auto"
onClose={setOpen} onClose={setOpen}
> >
<div className="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0"> <div className="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">

View File

@ -697,7 +697,9 @@ export function ContractFeed(props: {
</li> </li>
))} ))}
</ul> </ul>
{tradingAllowed(contract) && <BetRow contract={contract} />} {tradingAllowed(contract) && (
<BetRow contract={contract} className="-mt-2 -mx-4" />
)}
</div> </div>
) )
} }

View File

@ -22,7 +22,7 @@ export function YesNoSelector(props: {
)} )}
onClick={() => onSelect('YES')} onClick={() => onSelect('YES')}
> >
YES Buy YES
</button> </button>
<button <button
className={clsx( className={clsx(
@ -33,7 +33,7 @@ export function YesNoSelector(props: {
)} )}
onClick={() => onSelect('NO')} onClick={() => onSelect('NO')}
> >
NO Buy NO
</button> </button>
</Row> </Row>
) )

View File

@ -112,7 +112,9 @@ export default function ContractPage(props: {
<div className="md:ml-8" /> <div className="md:ml-8" />
<Col className="flex-1"> <Col className="flex-1">
{allowTrade && <BetPanel contract={contract} />} {allowTrade && (
<BetPanel className="hidden lg:inline" contract={contract} />
)}
{allowResolve && ( {allowResolve && (
<ResolutionPanel creator={user} contract={contract} /> <ResolutionPanel creator={user} contract={contract} />
)} )}