'use client' import type { ElementType, ReactNode } from 'react' import { ChevronDown } from 'lucide-react' import Card from './card' import IconBubble, { type IconBubbleTone } from './iconBubble' import PulseDot from './pulseDot' import Button from '@components/buttons/button' type PulseVariant = 'online' | 'offline' | 'warning' | 'unknown' type ExpandableCardProps = { icon: ElementType iconTone?: IconBubbleTone title: string subtitle?: ReactNode pulse?: { variant: PulseVariant; label: string } trailing?: ReactNode isExpanded: boolean onToggle: () => void children?: ReactNode } export default function ExpandableCard({ icon, iconTone = 'orange', title, subtitle, pulse, trailing, isExpanded, onToggle, children, }: ExpandableCardProps) { return (
{ if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); onToggle() } }} aria-expanded={isExpanded} className='group flex cursor-pointer select-none items-center gap-4 px-5 py-4' >
{title} {pulse && ( {pulse.label} )}
{subtitle &&
{subtitle}
}
{trailing && (
e.stopPropagation()}> {trailing}
)}
{isExpanded && children && (
{children}
)}
) }