The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { T } from "gt-react"; |
| 2 | import { ChevronRightIcon } from "lucide-react"; |
| 3 | import { type ReactNode, useState } from "react"; |
| 4 | |
| 5 | import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "../ui/collapsible"; |
| 6 | import { useSettingsSearchTargetId } from "./settingsLayout"; |
| 7 | |
| 8 | /** |
| 9 | * Folds power-user rows at the end of a section. `targetIds` names the search targets inside, so a |
| 10 | * search jump opens the fold before its row mounts. |
| 11 | */ |
| 12 | export function AdvancedSettings({ |
| 13 | targetIds, |
| 14 | children, |
| 15 | }: { |
| 16 | readonly targetIds: ReadonlyArray<string>; |
| 17 | readonly children: ReactNode; |
| 18 | }) { |
| 19 | const [open, setOpen] = useState(false); |
| 20 | const searchTargetId = useSettingsSearchTargetId(); |
| 21 | const [seenSearchTargetId, setSeenSearchTargetId] = useState<string | null>(null); |
| 22 | if (seenSearchTargetId !== searchTargetId) { |
| 23 | setSeenSearchTargetId(searchTargetId); |
| 24 | if (searchTargetId !== null && targetIds.includes(searchTargetId)) setOpen(true); |
| 25 | } |
| 26 | |
| 27 | return ( |
| 28 | <Collapsible open={open} onOpenChange={setOpen}> |
| 29 | <CollapsibleTrigger className="group flex min-h-10 w-full items-center gap-1.5 rounded-b-xl px-3 text-left text-xs font-medium text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring data-panel-open:rounded-none sm:px-4"> |
| 30 | <ChevronRightIcon |
| 31 | aria-hidden |
| 32 | className="size-3.5 shrink-0 transition-transform duration-150 group-data-panel-open:rotate-90 motion-reduce:transition-none" |
| 33 | /> |
| 34 | <T>Advanced</T> |
| 35 | </CollapsibleTrigger> |
| 36 | <CollapsiblePanel> |
| 37 | <div className="border-t border-border/50 *:not-first:border-t *:not-first:border-border/50"> |
| 38 | {children} |
| 39 | </div> |
| 40 | </CollapsiblePanel> |
| 41 | </Collapsible> |
| 42 | ); |
| 43 | } |