fabro/apps/fabro-web/app/components/collapsible-file.tsx
Bryan Helmkamp 5370a64f96
refactor(web): drop light mode, go dark-only
Removes the light/dark toggle infrastructure in favor of a single dark
theme. Deletes the theme context, boot script, light-mode CSS overrides,
logotype-light asset, and the pierre-light diff theme. Collapses
graph-theme into a single constant. Adds scheme-only-dark on <html> so
native controls and the server-injected Graphviz @media query render
dark.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 09:27:08 -04:00

44 lines
1.4 KiB
TypeScript

import { useState } from "react";
import { ChevronRightIcon } from "@heroicons/react/20/solid";
import type { FileContents } from "@pierre/diffs";
import { File } from "@pierre/diffs/react";
export function CollapsibleFile({
file,
defaultOpen = true,
}: {
file: FileContents;
defaultOpen?: boolean;
}) {
const [open, setOpen] = useState(defaultOpen);
const lines = file.contents.split("\n");
const lineCount = lines.length;
const loc = lines.filter((l) => l.trim().length > 0).length;
return (
<div className="rounded-md border border-line bg-panel/50 overflow-hidden">
<button
type="button"
onClick={() => setOpen((v) => !v)}
className="flex w-full items-center gap-2 px-4 py-2.5 text-left hover:bg-overlay transition-colors"
>
<ChevronRightIcon
className={`size-4 text-fg-muted transition-transform duration-150 ${open ? "rotate-90" : ""}`}
/>
<span className="font-mono text-xs text-fg-muted">{file.name}</span>
<span className="ml-auto font-mono text-xs text-fg-muted/60">
{lineCount} lines ({loc} loc)
</span>
</button>
<div className={open ? "" : "hidden"}>
<div className="border-t border-line" />
<File
file={file}
options={{ theme: "pierre-dark", disableFileHeader: true }}
/>
</div>
</div>
);
}