Working tree is now the canonical repo. Off-chain play-money + trustless on-chain (FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution, mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
31 lines
920 B
TypeScript
31 lines
920 B
TypeScript
import { ArrowLeftIcon } from '@heroicons/react/solid'
|
|
import { useState, useEffect } from 'react'
|
|
import { useRouter } from 'next/navigation'
|
|
import clsx from 'clsx'
|
|
import { Button, SizeType } from 'web/components/buttons/button'
|
|
|
|
export function BackButton(props: { className?: string; size?: SizeType }) {
|
|
const { className, size } = props
|
|
const router = useRouter()
|
|
const [canGoBack, setCanGoBack] = useState(false)
|
|
|
|
// Can't put this in a useMemo to avoid the page jump else we'll get hydration errors.
|
|
useEffect(() => {
|
|
setCanGoBack(typeof window !== 'undefined' && window.history.length > 1)
|
|
}, [])
|
|
|
|
if (!canGoBack) return null
|
|
|
|
return (
|
|
<Button
|
|
className={clsx('rounded', className)}
|
|
onClick={router.back}
|
|
color={'gray-white'}
|
|
size={size}
|
|
>
|
|
<ArrowLeftIcon className="h-5 w-5" aria-hidden />
|
|
<div className="sr-only">Back</div>
|
|
</Button>
|
|
)
|
|
}
|