Standardize spacing across pages.

This commit is contained in:
jahooma 2021-12-18 17:40:39 -06:00
parent d8dfd103b9
commit 5be7ce5f8f
13 changed files with 125 additions and 149 deletions

View File

@ -96,10 +96,7 @@ export function BetPanel(props: { contract: Contract; className?: string }) {
return ( return (
<Col <Col
className={clsx( className={clsx('bg-gray-100 shadow-xl px-8 py-6 rounded-md', className)}
'bg-gray-100 shadow-xl px-8 py-6 rounded-md w-full md:w-auto',
className
)}
> >
<Title className="!mt-0 whitespace-nowrap" text="Place a bet" /> <Title className="!mt-0 whitespace-nowrap" text="Place a bet" />

View File

@ -114,7 +114,7 @@ function MyContractBets(props: { contract: Contract; bets: Bet[] }) {
> >
<Row className="flex-wrap gap-4"> <Row className="flex-wrap gap-4">
<Col className="flex-[2] gap-1"> <Col className="flex-[2] gap-1">
<div> <Row>
<Link href={path(contract)}> <Link href={path(contract)}>
<a <a
className="font-medium text-indigo-700 hover:underline hover:decoration-indigo-400 hover:decoration-2" className="font-medium text-indigo-700 hover:underline hover:decoration-indigo-400 hover:decoration-2"
@ -123,7 +123,13 @@ function MyContractBets(props: { contract: Contract; bets: Bet[] }) {
{contract.question} {contract.question}
</a> </a>
</Link> </Link>
</div>
{/* Show carrot for collapsing. Hack the positioning. */}
<div
className="collapse-title flex-1 p-0 pr-8 relative w-0 h-0 min-h-0"
style={{ top: -10, right: -20 }}
/>
</Row>
<Row className="gap-2 text-gray-500 text-sm"> <Row className="gap-2 text-gray-500 text-sm">
<div> <div>
@ -140,19 +146,11 @@ function MyContractBets(props: { contract: Contract; bets: Bet[] }) {
</Row> </Row>
</Col> </Col>
<Row className="flex-nowrap">
<MyBetsSummary <MyBetsSummary
className="flex-1 justify-end" className="flex-1 justify-end"
contract={contract} contract={contract}
bets={bets} bets={bets}
/> />
{/* Show carrot for collapsing. Hack the positioning. */}
<div
className="collapse-title p-0 pr-8 relative w-0 h-0 min-h-0"
style={{ top: -10, right: -20 }}
/>
</Row>
</Row> </Row>
<div className="collapse-content" style={{ backgroundColor: 'white' }}> <div className="collapse-content" style={{ backgroundColor: 'white' }}>

View File

@ -145,7 +145,7 @@ export const ContractOverview = (props: {
<Col className={className}> <Col className={className}>
<Col className="justify-between md:flex-row"> <Col className="justify-between md:flex-row">
<Col> <Col>
<div className="text-3xl text-indigo-700 mt-2 mb-4"> <div className="text-3xl text-indigo-700 mb-4">
{contract.question} {contract.question}
</div> </div>
@ -153,12 +153,12 @@ export const ContractOverview = (props: {
</Col> </Col>
{resolution ? ( {resolution ? (
<Col className="text-4xl mt-4 md:mt-2 md:ml-4 md:mr-6 items-end self-center md:self-start"> <Col className="text-4xl mt-8 md:mt-0 md:ml-4 md:mr-6 items-end self-center md:self-start">
<div className="text-xl text-gray-500">Resolved</div> <div className="text-xl text-gray-500">Resolved</div>
<div className={resolutionColor}>{resolution}</div> <div className={resolutionColor}>{resolution}</div>
</Col> </Col>
) : ( ) : (
<Col className="text-4xl mt-4 md:mt-2 md:ml-4 md:mr-6 text-primary items-end self-center md:self-start"> <Col className="text-4xl mt-8 md:mt-0 md:ml-4 md:mr-6 text-primary items-end self-center md:self-start">
{probPercent} {probPercent}
<div className="text-xl">chance</div> <div className="text-xl">chance</div>
</Col> </Col>

View File

@ -57,7 +57,7 @@ function ContractCard(props: { contract: Contract }) {
<li className="col-span-1 bg-white hover:bg-gray-100 shadow-xl rounded-lg divide-y divide-gray-200"> <li className="col-span-1 bg-white hover:bg-gray-100 shadow-xl rounded-lg divide-y divide-gray-200">
<div className="card"> <div className="card">
<div className="card-body p-6"> <div className="card-body p-6">
<Row className="justify-between gap-2 mb-2"> <Row className="justify-between gap-4 mb-2">
<p className="font-medium text-indigo-700"> <p className="font-medium text-indigo-700">
{contract.question} {contract.question}
</p> </p>
@ -88,7 +88,7 @@ function ContractsGrid(props: { contracts: Contract[] }) {
if (contracts.length === 0) { if (contracts.length === 0) {
return ( return (
<p> <p className="mx-4">
No markets found. Would you like to{' '} No markets found. Would you like to{' '}
<Link href="/create"> <Link href="/create">
<a className="text-green-500 hover:underline hover:decoration-2"> <a className="text-green-500 hover:underline hover:decoration-2">
@ -105,7 +105,6 @@ function ContractsGrid(props: { contracts: Contract[] }) {
{contracts.map((contract) => ( {contracts.map((contract) => (
<ContractCard contract={contract} key={contract.id} /> <ContractCard contract={contract} key={contract.id} />
))} ))}
{/* TODO: Show placeholder if empty */}
</ul> </ul>
) )
} }

View File

@ -53,7 +53,7 @@ function SignedInHeaders(props: { user: User; themeClasses?: string }) {
<Link href="/create"> <Link href="/create">
<a <a
className={clsx( className={clsx(
'text-base font-medium hidden md:block', 'text-base font-medium hidden md:block whitespace-nowrap',
themeClasses themeClasses
)} )}
> >
@ -64,7 +64,7 @@ function SignedInHeaders(props: { user: User; themeClasses?: string }) {
<Link href="/bets"> <Link href="/bets">
<a <a
className={clsx( className={clsx(
'text-base font-medium hidden md:block', 'text-base font-medium hidden md:block whitespace-nowrap',
themeClasses themeClasses
)} )}
> >
@ -111,7 +111,7 @@ export function Header(props: { darkBackground?: boolean; children?: any }) {
return ( return (
<nav <nav
className="max-w-7xl w-full flex flex-row justify-between md:justify-start mx-auto pt-5 px-4 sm:px-6" className="max-w-7xl w-full flex flex-row justify-between md:justify-start pt-5 pb-4"
aria-label="Global" aria-label="Global"
> >
<Link href="/"> <Link href="/">

View File

@ -28,8 +28,10 @@ export function ResolutionPanel(props: {
const resolve = async () => { const resolve = async () => {
setIsSubmitting(true) setIsSubmitting(true)
const result = await resolveMarket({ outcome, contractId: contract.id }) const result = await resolveMarket({
.then(r => r.data as any) outcome,
contractId: contract.id,
}).then((r) => r.data as any)
console.log('resolved', outcome, 'result:', result) console.log('resolved', outcome, 'result:', result)
@ -50,10 +52,7 @@ export function ResolutionPanel(props: {
return ( return (
<Col <Col
className={clsx( className={clsx('bg-gray-100 shadow-xl px-8 py-6 rounded-md', className)}
'bg-gray-100 shadow-xl px-8 py-6 rounded-md w-full md:w-auto',
className
)}
> >
<Title className="mt-0" text="Your market" /> <Title className="mt-0" text="Your market" />
@ -68,7 +67,6 @@ export function ResolutionPanel(props: {
<Spacer h={3} /> <Spacer h={3} />
<div> <div>
{outcome === 'YES' ? ( {outcome === 'YES' ? (
<> <>
@ -87,12 +85,9 @@ export function ResolutionPanel(props: {
)} )}
</div> </div>
<Spacer h={3} /> <Spacer h={3} />
{!!error && {!!error && <div className="text-red-500">{error}</div>}
<div className='text-red-500'>{error}</div>
}
<ConfirmationButton <ConfirmationButton
id="resolution-modal" id="resolution-modal"

View File

@ -5,7 +5,7 @@ export function Title(props: { text: string; className?: string }) {
return ( return (
<h1 <h1
className={clsx( className={clsx(
'text-3xl font-major-mono text-indigo-700 inline-block mt-6 mb-4', 'text-3xl font-major-mono text-indigo-700 inline-block my-6',
className className
)} )}
> >

View File

@ -29,7 +29,7 @@ export function UserLink(props: { username: string; className?: string }) {
function UserCard(props: { user: User; showPrivateInfo?: boolean }) { function UserCard(props: { user: User; showPrivateInfo?: boolean }) {
const { user, showPrivateInfo } = props const { user, showPrivateInfo } = props
return ( return (
<Row className="card glass lg:card-side shadow-xl hover:shadow-xl text-neutral-content bg-green-600 hover:bg-green-600 transition-all max-w-sm mx-auto my-12"> <Row className="card glass lg:card-side shadow-xl hover:shadow-xl text-neutral-content bg-green-600 hover:bg-green-600 transition-all max-w-sm my-12">
<div className="p-4"> <div className="p-4">
{user?.avatarUrl && ( {user?.avatarUrl && (
<img <img
@ -70,7 +70,7 @@ export function UserPage(props: { user: User; currentUser?: User }) {
const possesive = isCurrentUser ? 'Your ' : `${user.username}'s ` const possesive = isCurrentUser ? 'Your ' : `${user.username}'s `
return ( return (
<div> <div className="max-w-4xl px-4 pb-8 mx-auto">
<SEO <SEO
title={possesive + 'markets'} title={possesive + 'markets'}
description={possesive + 'markets'} description={possesive + 'markets'}
@ -79,15 +79,11 @@ export function UserPage(props: { user: User; currentUser?: User }) {
<Header /> <Header />
<div className="max-w-4xl pt-8 pb-0 sm:pb-8 mx-auto">
<div>
<UserCard user={user} showPrivateInfo={isCurrentUser} /> <UserCard user={user} showPrivateInfo={isCurrentUser} />
<Title text={possesive + 'markets'} /> <Title text={possesive + 'markets'} />
<ContractsList creator={user} /> <ContractsList creator={user} />
</div> </div>
</div>
</div>
) )
} }

View File

@ -52,7 +52,12 @@ export default function ContractPage(props: {
const isCreator = user?.id === creatorId const isCreator = user?.id === creatorId
return ( return (
<Col className="max-w-7xl mx-auto sm:px-6 lg:px-8"> <Col
className={clsx(
'px-4 pb-8 mx-auto',
isResolved ? 'max-w-4xl' : 'max-w-7xl'
)}
>
<SEO <SEO
title={contract.question} title={contract.question}
description={contract.description} description={contract.description}
@ -61,22 +66,17 @@ export default function ContractPage(props: {
<Header /> <Header />
<Col <Col className="w-full md:flex-row justify-between mt-6">
className={clsx( <div className="flex-[3]">
'w-full items-start md:flex-row mt-4', <ContractOverview contract={contract} />
isResolved ? 'md:justify-center' : 'md:justify-between'
)}
>
<div className="max-w-4xl w-full ">
<ContractOverview contract={contract} className="p-4" />
<BetsSection contract={contract} user={user ?? null} /> <BetsSection contract={contract} user={user ?? null} />
</div> </div>
{!isResolved && ( {!isResolved && (
<> <>
<div className="mt-12 md:mt-0 md:ml-8" /> <div className="md:ml-8" />
<Col className="w-full sm:w-auto"> <Col className="flex-1">
<BetPanel contract={contract} /> <BetPanel contract={contract} />
{isCreator && user && ( {isCreator && user && (
@ -104,12 +104,13 @@ function BetsSection(props: { contract: Contract; user: User | null }) {
if (!userBets || userBets.length === 0) return <></> if (!userBets || userBets.length === 0) return <></>
return ( return (
<div className="p-4"> <div>
<Spacer h={6} />
<Title text="Your bets" /> <Title text="Your bets" />
<MyBetsSummary contract={contract} bets={userBets} /> <MyBetsSummary contract={contract} bets={userBets} />
<Spacer h={6} /> <Spacer h={6} />
<ContractBetsTable contract={contract} bets={userBets} /> <ContractBetsTable contract={contract} bets={userBets} />
<Spacer h={6} /> <Spacer h={12} />
</div> </div>
) )
} }

View File

@ -5,7 +5,7 @@ import { firebaseLogin } from '../lib/firebase/users'
function SignInCard() { function SignInCard() {
return ( return (
<div className="card glass lg:card-side shadow-xl hover:shadow-xl text-neutral-content bg-green-600 hover:bg-green-600 transition-all max-w-sm mx-auto my-12"> <div className="card glass sm:card-side shadow-xl hover:shadow-xl text-neutral-content bg-green-600 hover:bg-green-600 transition-all max-w-sm mx-4 sm:mx-auto my-12">
<div className="p-4"> <div className="p-4">
<img <img
src="/logo-icon-white-bg.png" src="/logo-icon-white-bg.png"

View File

@ -8,17 +8,11 @@ export default function BetsPage() {
const user = useUser() const user = useUser()
return ( return (
<div> <div className="max-w-4xl px-4 pb-8 mx-auto">
<SEO title="Your bets" description="Your bets" url="/bets" /> <SEO title="Your bets" description="Your bets" url="/bets" />
<Header /> <Header />
<div className="max-w-4xl pt-8 pb-0 sm:pb-8 mx-auto">
<div>
<Title text="Your bets" /> <Title text="Your bets" />
{user && <BetsList user={user} />} {user && <BetsList user={user} />}
</div> </div>
</div>
</div>
) )
} }

View File

@ -42,10 +42,9 @@ export default function NewContract() {
if (!creator) return <></> if (!creator) return <></>
return ( return (
<div> <div className="max-w-4xl px-4 pb-8 mx-auto">
<Header /> <Header />
<div className="max-w-4xl py-12 lg:mx-auto px-4">
<Title text="Create a new prediction market" /> <Title text="Create a new prediction market" />
<div className="w-full bg-gray-100 rounded-lg shadow-xl px-6 py-4"> <div className="w-full bg-gray-100 rounded-lg shadow-xl px-6 py-4">
@ -124,6 +123,5 @@ export default function NewContract() {
{creator && <ContractsList creator={creator} />} {creator && <ContractsList creator={creator} />}
</div> </div>
</div>
) )
} }

View File

@ -6,11 +6,9 @@ export default function Markets() {
const contracts = useContracts() const contracts = useContracts()
return ( return (
<div> <div className="max-w-4xl px-4 pb-8 mx-auto">
<Header /> <Header />
<div className="max-w-4xl py-8 mx-auto">
<SearchableGrid contracts={contracts === 'loading' ? [] : contracts} /> <SearchableGrid contracts={contracts === 'loading' ? [] : contracts} />
</div> </div>
</div>
) )
} }