|
| 1 | +import { PropsWithChildren } from "react"; |
| 2 | + |
| 3 | +import { tv } from "tailwind-variants"; |
| 4 | + |
| 5 | +import { Button } from "@/primitives"; |
| 6 | + |
| 7 | +const PRE_TITLE = "ERM... THIS IS AWKWARD"; |
| 8 | +const TITLE = "Page not found"; |
| 9 | +const DESCRIPTION = "Looks like the page you are looking for has been moved or removed."; |
| 10 | + |
| 11 | +const variants = tv({ |
| 12 | + slots: { |
| 13 | + container: "flex h-screen flex-col items-center justify-center", |
| 14 | + content: "flex max-w-[80%] flex-col gap-2 md:max-w-[60%] lg:max-w-[40%]", |
| 15 | + preTitle: "font-ui-mono text-xs/[20px] font-medium sm:text-sm/[24px]", |
| 16 | + title: "font-ui-sans text-3xl font-semibold sm:text-5xl", |
| 17 | + description: "font-ui-sans text-base font-medium sm:text-lg", |
| 18 | + }, |
| 19 | + variants: { |
| 20 | + description: { |
| 21 | + default: "font-ui-sans text-5xl font-semibold", |
| 22 | + }, |
| 23 | + }, |
| 24 | +}); |
| 25 | + |
| 26 | +export interface NotFoundPageProps extends PropsWithChildren { |
| 27 | + description?: string; |
| 28 | + button?: { |
| 29 | + label: string; |
| 30 | + onClick: () => void; |
| 31 | + }; |
| 32 | +} |
| 33 | + |
| 34 | +export const NotFoundPage = ({ |
| 35 | + description = DESCRIPTION, |
| 36 | + button, |
| 37 | + children, |
| 38 | +}: NotFoundPageProps) => { |
| 39 | + const { container, content, preTitle, title, description: descriptionStyle } = variants(); |
| 40 | + |
| 41 | + return ( |
| 42 | + <div className={container()}> |
| 43 | + <div className={content()}> |
| 44 | + <div className={preTitle()}>{PRE_TITLE}</div> |
| 45 | + <div className={title()}>{TITLE}</div> |
| 46 | + {description && <div className={descriptionStyle()}>{description}</div>} |
| 47 | + {children} |
| 48 | + {button && ( |
| 49 | + <Button className="w-fit" size="lg" onClick={button.onClick} value={button.label} /> |
| 50 | + )} |
| 51 | + </div> |
| 52 | + </div> |
| 53 | + ); |
| 54 | +}; |
0 commit comments