Improve navbar styles. Create Page component with navbar and page structure.
This commit is contained in:
parent
702c0af33e
commit
4b3b6436a0
|
@ -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">
|
||||||
<Row className="mr-10">
|
<Row className="mr-6">
|
||||||
<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"
|
||||||
|
@ -147,7 +147,7 @@ function MyContractBets(props: { contract: Contract; bets: Bet[] }) {
|
||||||
</Col>
|
</Col>
|
||||||
|
|
||||||
<MyBetsSummary
|
<MyBetsSummary
|
||||||
className="flex-1 justify-end mr-8"
|
className="flex-1 justify-end mr-5 sm:mr-8"
|
||||||
contract={contract}
|
contract={contract}
|
||||||
bets={bets}
|
bets={bets}
|
||||||
/>
|
/>
|
||||||
|
@ -187,7 +187,7 @@ export function MyBetsSummary(props: {
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Row className={clsx('gap-6', className)}>
|
<Row className={clsx('gap-4 sm:gap-6', className)}>
|
||||||
<Col>
|
<Col>
|
||||||
<div className="text-sm text-gray-500 whitespace-nowrap">
|
<div className="text-sm text-gray-500 whitespace-nowrap">
|
||||||
Total bets
|
Total bets
|
||||||
|
|
|
@ -28,7 +28,7 @@ export function MenuButton(props: {
|
||||||
leaveFrom="transform opacity-100 scale-100"
|
leaveFrom="transform opacity-100 scale-100"
|
||||||
leaveTo="transform opacity-0 scale-95"
|
leaveTo="transform opacity-0 scale-95"
|
||||||
>
|
>
|
||||||
<Menu.Items className="origin-top-right absolute right-0 mt-2 w-48 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 py-1 focus:outline-none">
|
<Menu.Items className="origin-top-right absolute right-0 mt-2 w-40 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 py-1 focus:outline-none">
|
||||||
{menuItems.map((item) => (
|
{menuItems.map((item) => (
|
||||||
<Menu.Item key={item.name}>
|
<Menu.Item key={item.name}>
|
||||||
{({ active }) => (
|
{({ active }) => (
|
||||||
|
|
|
@ -7,9 +7,6 @@ import { firebaseLogin, User } from '../lib/firebase/users'
|
||||||
import { ManticLogo } from './mantic-logo'
|
import { ManticLogo } from './mantic-logo'
|
||||||
import { ProfileMenu } from './profile-menu'
|
import { ProfileMenu } from './profile-menu'
|
||||||
|
|
||||||
const hoverClasses =
|
|
||||||
'hover:underline hover:decoration-indigo-400 hover:decoration-2'
|
|
||||||
|
|
||||||
export function NavBar(props: {
|
export function NavBar(props: {
|
||||||
darkBackground?: boolean
|
darkBackground?: boolean
|
||||||
className?: string
|
className?: string
|
||||||
|
@ -19,19 +16,22 @@ export function NavBar(props: {
|
||||||
|
|
||||||
const user = useUser()
|
const user = useUser()
|
||||||
|
|
||||||
|
const hoverClasses =
|
||||||
|
'hover:underline hover:decoration-indigo-400 hover:decoration-2'
|
||||||
const themeClasses = clsx(darkBackground && 'text-white', hoverClasses)
|
const themeClasses = clsx(darkBackground && 'text-white', hoverClasses)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav
|
<nav
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'w-full flex flex-row justify-between md:justify-start pt-5 pb-4',
|
'w-full flex flex-row justify-center items-center p-4 shadow-sm mb-4',
|
||||||
|
!darkBackground && 'bg-white',
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
aria-label="Global"
|
aria-label="Global"
|
||||||
>
|
>
|
||||||
<ManticLogo darkBackground={darkBackground} />
|
<ManticLogo darkBackground={darkBackground} />
|
||||||
|
|
||||||
<Row className="gap-6 sm:gap-8 mt-1 md:ml-16">
|
<Row className="items-center gap-6 sm:gap-8 md:ml-16 lg:ml-40">
|
||||||
{children}
|
{children}
|
||||||
|
|
||||||
{user ? (
|
{user ? (
|
||||||
|
|
20
web/components/page.tsx
Normal file
20
web/components/page.tsx
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
import clsx from 'clsx'
|
||||||
|
import { NavBar } from './nav-bar'
|
||||||
|
|
||||||
|
export function Page(props: { wide?: boolean; children?: any }) {
|
||||||
|
const { wide, children } = props
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<NavBar />
|
||||||
|
<div
|
||||||
|
className={clsx(
|
||||||
|
'max-w-4xl px-4 pb-8 mx-auto w-full',
|
||||||
|
wide ? 'max-w-7xl' : 'max-w-4xl'
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
import { firebaseLogout, User } from '../lib/firebase/users'
|
import { firebaseLogout, User } from '../lib/firebase/users'
|
||||||
import { NavBar } from './nav-bar'
|
|
||||||
import { ContractsList } from './contracts-list'
|
import { ContractsList } from './contracts-list'
|
||||||
import { Title } from './title'
|
import { Title } from './title'
|
||||||
import { Row } from './layout/row'
|
import { Row } from './layout/row'
|
||||||
|
@ -7,6 +6,7 @@ import { formatMoney } from '../lib/util/format'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import { SEO } from './SEO'
|
import { SEO } from './SEO'
|
||||||
|
import { Page } from './page'
|
||||||
|
|
||||||
export function UserLink(props: { username: string; className?: string }) {
|
export function UserLink(props: { username: string; className?: string }) {
|
||||||
const { username, className } = props
|
const { username, className } = props
|
||||||
|
@ -70,20 +70,18 @@ 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 className="max-w-4xl px-4 pb-8 mx-auto">
|
<Page>
|
||||||
<SEO
|
<SEO
|
||||||
title={possesive + 'markets'}
|
title={possesive + 'markets'}
|
||||||
description={possesive + 'markets'}
|
description={possesive + 'markets'}
|
||||||
url={`/@${user.username}`}
|
url={`/@${user.username}`}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<NavBar />
|
|
||||||
|
|
||||||
{/* <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>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import clsx from 'clsx'
|
|
||||||
|
|
||||||
import { useContractWithPreload } from '../../hooks/use-contract'
|
import { useContractWithPreload } from '../../hooks/use-contract'
|
||||||
import { NavBar } from '../../components/nav-bar'
|
|
||||||
import { ContractOverview } from '../../components/contract-overview'
|
import { ContractOverview } from '../../components/contract-overview'
|
||||||
import { BetPanel } from '../../components/bet-panel'
|
import { BetPanel } from '../../components/bet-panel'
|
||||||
import { Col } from '../../components/layout/col'
|
import { Col } from '../../components/layout/col'
|
||||||
|
@ -15,6 +13,7 @@ import { Spacer } from '../../components/layout/spacer'
|
||||||
import { User } from '../../lib/firebase/users'
|
import { User } from '../../lib/firebase/users'
|
||||||
import { Contract, getContractFromSlug } from '../../lib/firebase/contracts'
|
import { Contract, getContractFromSlug } from '../../lib/firebase/contracts'
|
||||||
import { SEO } from '../../components/SEO'
|
import { SEO } from '../../components/SEO'
|
||||||
|
import { Page } from '../../components/page'
|
||||||
|
|
||||||
export async function getStaticProps(props: { params: any }) {
|
export async function getStaticProps(props: { params: any }) {
|
||||||
const { username, contractSlug } = props.params
|
const { username, contractSlug } = props.params
|
||||||
|
@ -52,20 +51,13 @@ export default function ContractPage(props: {
|
||||||
const isCreator = user?.id === creatorId
|
const isCreator = user?.id === creatorId
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Col
|
<Page wide={!isResolved}>
|
||||||
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}
|
||||||
url={`/${props.username}/${props.slug}`}
|
url={`/${props.username}/${props.slug}`}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<NavBar />
|
|
||||||
|
|
||||||
<Col className="w-full md:flex-row justify-between mt-6">
|
<Col className="w-full md:flex-row justify-between mt-6">
|
||||||
<div className="flex-[3]">
|
<div className="flex-[3]">
|
||||||
<ContractOverview contract={contract} />
|
<ContractOverview contract={contract} />
|
||||||
|
@ -86,7 +78,7 @@ export default function ContractPage(props: {
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Col>
|
</Col>
|
||||||
</Col>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
import { cloneElement } from 'react'
|
import { cloneElement } from 'react'
|
||||||
import { NavBar } from '../components/nav-bar'
|
import { Page } from '../components/page'
|
||||||
import { SEO } from '../components/SEO'
|
import { SEO } from '../components/SEO'
|
||||||
import styles from './about.module.css'
|
import styles from './about.module.css'
|
||||||
|
|
||||||
export default function About() {
|
export default function About() {
|
||||||
return (
|
return (
|
||||||
<div className="max-w-3xl px-4 mx-auto">
|
<Page>
|
||||||
<SEO title="About" description="About" url="/about" />
|
<SEO title="About" description="About" url="/about" />
|
||||||
<NavBar />
|
|
||||||
<Contents />
|
<Contents />
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { NavBar } from '../components/nav-bar'
|
import { Page } from '../components/page'
|
||||||
import { UserPage } from '../components/user-page'
|
import { UserPage } from '../components/user-page'
|
||||||
import { useUser } from '../hooks/use-user'
|
import { useUser } from '../hooks/use-user'
|
||||||
import { firebaseLogin } from '../lib/firebase/users'
|
import { firebaseLogin } from '../lib/firebase/users'
|
||||||
|
@ -34,9 +34,8 @@ export default function Account() {
|
||||||
return user ? (
|
return user ? (
|
||||||
<UserPage user={user} currentUser={user} />
|
<UserPage user={user} currentUser={user} />
|
||||||
) : (
|
) : (
|
||||||
<div className="max-w-4xl px-4 pb-8 mx-auto">
|
<Page>
|
||||||
<NavBar />
|
|
||||||
<SignInCard />
|
<SignInCard />
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { BetsList } from '../components/bets-list'
|
import { BetsList } from '../components/bets-list'
|
||||||
import { NavBar } from '../components/nav-bar'
|
import { Page } from '../components/page'
|
||||||
import { SEO } from '../components/SEO'
|
import { SEO } from '../components/SEO'
|
||||||
import { Title } from '../components/title'
|
import { Title } from '../components/title'
|
||||||
import { useUser } from '../hooks/use-user'
|
import { useUser } from '../hooks/use-user'
|
||||||
|
@ -8,11 +8,10 @@ export default function BetsPage() {
|
||||||
const user = useUser()
|
const user = useUser()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="max-w-4xl px-4 pb-8 mx-auto">
|
<Page>
|
||||||
<SEO title="Your bets" description="Your bets" url="/bets" />
|
<SEO title="Your bets" description="Your bets" url="/bets" />
|
||||||
<NavBar />
|
|
||||||
<Title text="Your bets" />
|
<Title text="Your bets" />
|
||||||
{user && <BetsList user={user} />}
|
{user && <BetsList user={user} />}
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,12 @@ import router from 'next/router'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
import { ContractsList } from '../components/contracts-list'
|
import { ContractsList } from '../components/contracts-list'
|
||||||
import { NavBar } from '../components/nav-bar'
|
|
||||||
import { Spacer } from '../components/layout/spacer'
|
import { Spacer } from '../components/layout/spacer'
|
||||||
import { Title } from '../components/title'
|
import { Title } from '../components/title'
|
||||||
import { useUser } from '../hooks/use-user'
|
import { useUser } from '../hooks/use-user'
|
||||||
import { path } from '../lib/firebase/contracts'
|
import { path } from '../lib/firebase/contracts'
|
||||||
import { createContract } from '../lib/service/create-contract'
|
import { createContract } from '../lib/service/create-contract'
|
||||||
|
import { Page } from '../components/page'
|
||||||
|
|
||||||
// Allow user to create a new contract
|
// Allow user to create a new contract
|
||||||
export default function NewContract() {
|
export default function NewContract() {
|
||||||
|
@ -42,9 +42,7 @@ export default function NewContract() {
|
||||||
if (!creator) return <></>
|
if (!creator) return <></>
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="max-w-4xl px-4 pb-8 mx-auto">
|
<Page>
|
||||||
<NavBar />
|
|
||||||
|
|
||||||
<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">
|
||||||
|
@ -122,6 +120,6 @@ export default function NewContract() {
|
||||||
<Title text="Your markets" />
|
<Title text="Your markets" />
|
||||||
|
|
||||||
{creator && <ContractsList creator={creator} />}
|
{creator && <ContractsList creator={creator} />}
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,24 +24,22 @@ export default function LandingPage() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function Hero() {
|
const scrollToAbout = () => {
|
||||||
const scrollToAbout = () => {
|
|
||||||
const aboutElem = document.getElementById('about')
|
const aboutElem = document.getElementById('about')
|
||||||
window.scrollTo({ top: aboutElem?.offsetTop, behavior: 'smooth' })
|
window.scrollTo({ top: aboutElem?.offsetTop, behavior: 'smooth' })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Hero() {
|
||||||
return (
|
return (
|
||||||
<div className="overflow-hidden h-screen bg-world-trading bg-cover bg-gray-900 bg-center lg:bg-left">
|
<div className="overflow-hidden h-screen bg-world-trading bg-cover bg-gray-900 bg-center lg:bg-left">
|
||||||
<div className="max-w-7xl w-full mx-auto">
|
<NavBar className="max-w-4xl" darkBackground>
|
||||||
<NavBar className="px-6 sm:px-8" darkBackground>
|
|
||||||
<div
|
<div
|
||||||
className="text-base font-medium text-white cursor-pointer hover:underline hover:decoration-teal-500 hover:decoration-2"
|
className="text-base font-medium text-white ml-8 cursor-pointer hover:underline hover:decoration-teal-500 hover:decoration-2"
|
||||||
onClick={scrollToAbout}
|
onClick={scrollToAbout}
|
||||||
>
|
>
|
||||||
About
|
About
|
||||||
</div>
|
</div>
|
||||||
</NavBar>
|
</NavBar>
|
||||||
</div>
|
|
||||||
<main>
|
<main>
|
||||||
<div className="pt-32 sm:pt-8 lg:pt-0 lg:pb-14 lg:overflow-hidden">
|
<div className="pt-32 sm:pt-8 lg:pt-0 lg:pb-14 lg:overflow-hidden">
|
||||||
<div className="mx-auto max-w-7xl lg:px-8">
|
<div className="mx-auto max-w-7xl lg:px-8">
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { SearchableGrid } from '../components/contracts-list'
|
import { SearchableGrid } from '../components/contracts-list'
|
||||||
import { NavBar } from '../components/nav-bar'
|
import { Page } from '../components/page'
|
||||||
import { useContracts } from '../hooks/use-contracts'
|
import { useContracts } from '../hooks/use-contracts'
|
||||||
import { Contract, listAllContracts } from '../lib/firebase/contracts'
|
import { Contract, listAllContracts } from '../lib/firebase/contracts'
|
||||||
|
|
||||||
|
@ -19,13 +19,12 @@ export default function Markets(props: { contracts: Contract[] }) {
|
||||||
const contracts = useContracts()
|
const contracts = useContracts()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="max-w-4xl px-4 pb-8 mx-auto">
|
<Page>
|
||||||
<NavBar />
|
|
||||||
{(props.contracts || contracts !== 'loading') && (
|
{(props.contracts || contracts !== 'loading') && (
|
||||||
<SearchableGrid
|
<SearchableGrid
|
||||||
contracts={contracts === 'loading' ? props.contracts : contracts}
|
contracts={contracts === 'loading' ? props.contracts : contracts}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { SearchableGrid } from '../../components/contracts-list'
|
import { SearchableGrid } from '../../components/contracts-list'
|
||||||
import { NavBar } from '../../components/nav-bar'
|
import { Page } from '../../components/page'
|
||||||
import { Title } from '../../components/title'
|
import { Title } from '../../components/title'
|
||||||
import { useContracts } from '../../hooks/use-contracts'
|
import { useContracts } from '../../hooks/use-contracts'
|
||||||
|
|
||||||
|
@ -19,10 +19,9 @@ export default function TagPage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="max-w-4xl px-4 pb-8 mx-auto">
|
<Page>
|
||||||
<NavBar />
|
|
||||||
<Title text={`#${tag}`} />
|
<Title text={`#${tag}`} />
|
||||||
<SearchableGrid contracts={contracts === 'loading' ? [] : contracts} />
|
<SearchableGrid contracts={contracts === 'loading' ? [] : contracts} />
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user