| 1 | import { Collapsible as Primitive } from "radix-ui"; |
| 2 | import type { ComponentProps } from "react"; |
| 3 | |
| 4 | import { cn } from "../../lib/cn"; |
| 5 | |
| 6 | // shadcn/ui's collapsible, styled with g1t's tokens: a region that opens |
| 7 | // and closes under a trigger, for a panel whose state a page controls |
| 8 | // (`open`/`onOpenChange`). A disclosure that should work before the page |
| 9 | // hydrates, such as a section of a long form, stays a native <details>. |
| 10 | |
| 11 | export const Collapsible = Primitive.Root; |
| 12 | |
| 13 | export function CollapsibleTrigger({ className, ...props }: ComponentProps<typeof Primitive.Trigger>) { |
| 14 | return ( |
| 15 | <Primitive.Trigger |
| 16 | data-slot="collapsible-trigger" |
| 17 | className={cn("group/collapsible inline-flex items-center gap-1.5 text-sm text-muted outline-none hover:text-fg focus-visible:ring-2 focus-visible:ring-accent [&_svg]:transition-transform data-[state=open]:[&_svg]:rotate-90", className)} |
| 18 | {...props} |
| 19 | /> |
| 20 | ); |
| 21 | } |
| 22 | |
| 23 | export function CollapsibleContent({ className, ...props }: ComponentProps<typeof Primitive.Content>) { |
| 24 | return <Primitive.Content data-slot="collapsible-content" className={cn("outline-none", className)} {...props} />; |
| 25 | } |