@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
tsx 54 lines 1.76 KB
Raw
1 import type { ComponentProps, ReactNode } from "react";
2 import { ChevronDownIcon } from "lucide-react";
3 import { cn } from "../../lib/utils";
4
5 const tones = {
6 muted: { label: "text-sidebar-muted-foreground", line: "bg-sidebar-border/50" },
7 emphasized: { label: "text-sidebar-foreground/80", line: "bg-sidebar-foreground/25" },
8 accent: { label: "text-primary", line: "bg-primary/50" },
9 } as const;
10
11 export function CollapsibleSectionHeader({
12 children,
13 expanded,
14 tone = "muted",
15 variant = "default",
16 accessory,
17 ...buttonProps
18 }: Omit<ComponentProps<"button">, "className" | "style" | "aria-expanded"> & {
19 expanded: boolean;
20 tone?: keyof typeof tones;
21 variant?: "default" | "panel";
22 accessory?: ReactNode;
23 }) {
24 return (
25 <button
26 {...buttonProps}
27 type="button"
28 aria-expanded={expanded}
29 className={cn(
30 "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",
31 variant === "panel" ? "ps-2 pe-2.5" : "px-2",
32 tones[tone].label,
33 )}
34 >
35 <span className="min-w-0 truncate">{children}</span>
36 <span
37 aria-hidden
38 // A header with a trailing count drops its rule so it doesn't read as a leader.
39 className={cn("h-px min-w-2 flex-1", tones[tone].line, accessory && "invisible")}
40 />
41 {accessory}
42 <ChevronDownIcon
43 aria-hidden
44 className={cn("size-3 shrink-0 transition-transform", !expanded && "-rotate-90")}
45 />
46 </button>
47 );
48 }
49
50 export function SectionHeaderStatus({ children }: { children: ReactNode }) {
51 return (
52 <span className="shrink-0 text-3xs leading-none text-destructive-foreground">{children}</span>
53 );
54 }