Open History to see the last commit
1import type { ComponentProps, ReactNode } from "react";
2import { ChevronDownIcon } from "lucide-react";
3import { cn } from "../../lib/utils";
4
5const tones = {
6 muted: { label: "text-sidebar-muted-foreground/60", line: "bg-sidebar-border/60" },
7 info: { label: "text-blue-600 dark:text-blue-400", line: "bg-blue-500/20 dark:bg-blue-400/15" },
8 emphasized: { label: "text-sidebar-foreground/80", line: "bg-sidebar-foreground/25" },
9 accent: { label: "text-primary", line: "bg-primary/50" },
10} as const;
11
12export function CollapsibleSectionHeader({
13 children,
14 expanded,
15 tone = "muted",
16 variant = "default",
17 accessory,
18 ...buttonProps
19}: Omit<ComponentProps<"button">, "className" | "style" | "aria-expanded"> & {
20 expanded: boolean;
21 tone?: keyof typeof tones;
22 variant?: "default" | "panel";
23 accessory?: ReactNode;
24}) {
25 return (
26 <button
27 {...buttonProps}
28 type="button"
29 aria-expanded={expanded}
30 className={cn(
31 "flex h-8 w-full cursor-pointer items-center gap-2 rounded-md text-left text-xs font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70",
32 variant === "panel" ? "ps-2 pe-2.5" : "px-2",
33 tones[tone].label,
34 )}
35 >
36 <span className="shrink-0">{children}</span>
37 <span aria-hidden className={cn("h-px min-w-2 flex-1", tones[tone].line)} />
38 {accessory}
39 <ChevronDownIcon
40 aria-hidden
41 className={cn("size-3 shrink-0 transition-transform", !expanded && "rotate-180")}
42 />
43 </button>
44 );
45}
46
47export function SectionHeaderStatus({ children }: { children: ReactNode }) {
48 return (
49 <span className="shrink-0 text-3xs leading-none text-destructive-foreground">{children}</span>
50 );
51}