File size: 6,646 Bytes
0c52aa7 d56270d 0c52aa7 d56270d 0c52aa7 d56270d 0c52aa7 d56270d 0c52aa7 d56270d 0c52aa7 d56270d 0c52aa7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | "use client";
import {
BarChart3,
BookOpen,
Columns3,
FileSearch,
Github,
Inbox,
Menu,
Network,
ReceiptText,
ScanLine,
X,
} from "lucide-react";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { useEffect, useState } from "react";
import { QuickJump } from "./QuickJump";
import { GITHUB_URL } from "@/lib/site";
// The app: what an everyday user needs.
const MAIN = [
{ href: "/", label: "Scan receipt", icon: ScanLine },
{ href: "/queue/", label: "Receipt inbox", icon: Inbox },
{ href: "/search/", label: "Filing search", icon: FileSearch },
];
// How the models were built and measured, for technical readers.
const WORKSPACE = [
{ href: "/results/", label: "Model results", icon: BarChart3 },
{ href: "/receipts/", label: "Before vs after", icon: ReceiptText },
{ href: "/compare/", label: "Search methods", icon: Columns3 },
{ href: "/architecture/", label: "Architecture", icon: Network },
{ href: "/about/", label: "Data & licences", icon: BookOpen },
];
function isActive(path: string, href: string) {
if (href === "/") return path === "/";
const root = href.split("/")[1];
return path.startsWith(`/${root}`);
}
function Logo() {
return (
<Link href="/" className="flex items-center gap-3 px-2">
<span className="grid h-10 w-10 place-items-center rounded-full text-[17px] font-bold text-white ring-1 ring-white/35">Σ</span>
<span className="leading-tight">
<span className="block text-[18px] font-semibold text-white">SumProof</span>
<span className="block text-[12.5px] text-nav-muted">Receipt AI · filing search</span>
</span>
</Link>
);
}
function NavList({ items, path, onNavigate }: { items: typeof MAIN; path: string; onNavigate?: () => void }) {
return (
<ul className="flex flex-col gap-1">
{items.map(({ href, label, icon: Icon }) => {
const active = isActive(path, href);
return (
<li key={href}>
<Link
href={href}
onClick={onNavigate}
aria-current={active ? "page" : undefined}
className={`flex items-center gap-3 rounded-lg px-3 py-2 text-[14.5px] transition-colors ${
active ? "bg-white/10 font-semibold text-white ring-1 ring-white/15" : "text-nav-ink hover:bg-white/5 hover:text-white"
}`}
>
<Icon size={18} strokeWidth={1.8} className={active ? "text-white" : "text-nav-muted"} />
{label}
</Link>
</li>
);
})}
</ul>
);
}
function Sidebar({ path, onNavigate }: { path: string; onNavigate?: () => void }) {
return (
<div className="flex min-h-full flex-col gap-5 px-4 py-5">
<Logo />
<nav aria-label="App" className="flex flex-col gap-2 border-t border-white/10 pt-5">
<p className="px-3 text-[11.5px] font-medium tracking-[0.1em] text-nav-muted uppercase">App</p>
<NavList items={MAIN} path={path} onNavigate={onNavigate} />
</nav>
<nav aria-label="Model results" className="flex flex-col gap-2 border-t border-white/10 pt-5">
<p className="px-3 text-[11.5px] font-medium tracking-[0.1em] text-nav-muted uppercase">Under the hood</p>
<NavList items={WORKSPACE} path={path} onNavigate={onNavigate} />
<a
href={GITHUB_URL}
target="_blank"
rel="noreferrer"
className="flex items-center gap-3 rounded-lg px-3 py-2 text-[14.5px] text-nav-ink hover:bg-white/5 hover:text-white"
>
<Github size={18} strokeWidth={1.8} className="text-nav-muted" />
Source code
</a>
</nav>
<div className="mt-auto rounded-xl bg-white/5 p-4 ring-1 ring-white/10">
<p className="text-[13.5px] font-semibold text-white">Online demo</p>
<p className="mt-1 text-[12.5px] leading-relaxed text-nav-muted">
Sample receipts show real model outputs. Reading your own photos needs the reader running on a GPU.
</p>
<p className="mt-2.5 text-[12.5px] font-semibold text-white">$0 · open models</p>
</div>
</div>
);
}
export function Shell({ children }: { children: React.ReactNode }) {
const path = usePathname() || "/";
const [open, setOpen] = useState(false);
useEffect(() => setOpen(false), [path]);
return (
<div className="flex min-h-screen">
<aside className="hidden w-[248px] shrink-0 bg-nav lg:block">
<div className="sticky top-0 h-screen overflow-y-auto">
<Sidebar path={path} />
</div>
</aside>
{open && (
<div className="fixed inset-0 z-40 lg:hidden" role="dialog" aria-modal="true" aria-label="Navigation">
<button className="absolute inset-0 bg-black/40" aria-label="Close navigation" onClick={() => setOpen(false)} />
<div className="relative h-full w-[272px] overflow-y-auto bg-nav">
<button
onClick={() => setOpen(false)}
aria-label="Close navigation"
className="absolute top-6 right-3 grid h-9 w-9 place-items-center rounded-full text-nav-muted hover:text-white"
>
<X size={18} />
</button>
<Sidebar path={path} onNavigate={() => setOpen(false)} />
</div>
</div>
)}
<div className="flex min-w-0 flex-1 flex-col">
<header className="flex items-center gap-3 px-4 pt-5 sm:px-8">
<button
type="button"
onClick={() => setOpen(true)}
aria-label="Open navigation"
className="grid h-10 w-10 shrink-0 place-items-center rounded-lg border border-line bg-surface-solid text-ink lg:hidden"
>
<Menu size={18} />
</button>
<QuickJump />
<div className="ml-auto flex items-center gap-4">
<a
href={GITHUB_URL}
target="_blank"
rel="noreferrer"
aria-label="Source code on GitHub"
className="grid h-10 w-10 place-items-center rounded-lg border border-line bg-surface-solid text-ink hover:border-accent hover:text-accent"
>
<Github size={18} />
</a>
</div>
</header>
<main className="min-w-0 flex-1 px-4 pt-6 pb-10 sm:px-8">
<div className="mx-auto max-w-[1280px]">{children}</div>
</main>
</div>
</div>
);
}
|