Skip to content
Source
Sign inSign up
fuko/trytanstackdb.com
Open History to see the last commit

deep-dive-page.tsx

51 lines1.9 KB

1import { Link } from "@tanstack/react-router";
2import { ArrowLeft } from "lucide-react";
3import type { ReactNode } from "react";
4​
5import { ThemeMenu } from "@/components/theme/theme-menu";
6import { ThemeToggle } from "@/components/theme/theme-toggle";
7import { useMediaQuery } from "@/hooks/use-media-query";
8​
9import { TanStackDbMark } from "./tanstack-db-mark";
10​
11/**
12 * A deep dive: a page of its own, outside the guide-and-app workspace. Same
13 * prose and code styles as the guide; code wraps on small screens.
14 */
15export function DeepDivePage({
16 title,
17 intro,
18 children,
19}: {
20 title: string;
21 intro: ReactNode;
22 children: ReactNode;
23}) {
24 const wide = useMediaQuery("(min-width: 768px)");
25​
26 return (
27 <div className="min-h-dvh bg-background">
28 <header className="sticky top-0 z-10 box-content flex h-14 items-center gap-2.5 border-b bg-background/90 px-4 pt-[env(safe-area-inset-top)] backdrop-blur">
29 <TanStackDbMark />
30 <Link
31 to="/"
32 className="inline-flex h-8 items-center gap-1.5 rounded-full px-2.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
33 >
34 <ArrowLeft className="size-4" aria-hidden />
35 Back to the guide
36 </Link>
37 <div className="ml-auto">{wide ? <ThemeToggle /> : <ThemeMenu />}</div>
38 </header>
39 <main data-wrap-code={wide ? undefined : ""}>
40 <article className="mx-auto w-full max-w-[68ch] px-5 pt-8 pb-24 sm:px-7">
41 <p className="text-xs font-semibold tracking-wide text-guide-accent uppercase">
42 Deep dive
43 </p>
44 <h1 className="mt-2 text-3xl font-bold tracking-tight text-balance">{title}</h1>
45 <div className="mt-3 text-[15px] leading-7 text-foreground/75">{intro}</div>
46 <div className="guide-prose mt-6">{children}</div>
47 </article>
48 </main>
49 </div>
50 );