'use client'; import * as React from 'react'; import { cva, type VariantProps } from '@/lib/cva'; import { ChevronDownIcon } from '@/icons'; import * as AccordionPrimitive from 'radix-ui/accordion'; import { cn } from '@/lib/utils'; import { colorPalettes, disabledState, focusRing } from '@/lib/cva-presets'; const accordionVariants = cva('group/accordion flex flex-col', { variants: { variant: { /** * CBAR's shape: each section is its own bordered card with space between * them, rather than rows sharing a rule. */ card: 'gap-4', /** The kit's pre-CBAR shape — flush rows separated by a divider. */ list: '', }, colorPalette: colorPalettes, }, defaultVariants: { variant: 'card', /* Only the chevron carries palette colour, and CBAR draws it turquoise. */ colorPalette: 'secondary', }, }); /* * An intersection rather than an `interface … extends`: Radix's Root props are * a discriminated union (`type="single"` carries `collapsible`, `type="multiple"` * does not), and extending a union in an interface flattens it into one object * that demands every member's required keys. */ export type AccordionProps = React.ComponentProps & VariantProps; export type AccordionItemProps = React.ComponentProps; /** * Vertically stacked sections that expand one at a time (`type="single"`) or * independently (`type="multiple"`). * * Collapsed content is removed from the accessibility tree, so never hide * something a user might search the page for. */ function Accordion({ className, variant = 'card', colorPalette, ...props }: AccordionProps) { return ( ); } function AccordionItem({ className, ...props }: AccordionItemProps) { return ( ); } function AccordionTrigger({ className, children, ...props }: React.ComponentProps) { return ( svg]:rotate-180 [&[data-state=open]>svg]:text-(--ctl-fg)', focusRing, disabledState, className )} {...props} > {children} ); } function AccordionContent({ className, children, ...props }: React.ComponentProps) { return ( {/* CBAR sets 8px between the title and the body, and 16px below it. */}
{children}
); } export { Accordion, AccordionItem, AccordionTrigger, AccordionContent, accordionVariants };