| 1 | import { ChevronDownIcon, ChevronRightIcon } from "@heroicons/react/24/outline"; |
| 2 | import { ReactNode, useState } from "react"; |
| 3 | |
| 4 | export interface ExpanderProps { |
| 5 | label: string; |
| 6 | children: ReactNode; |
| 7 | } |
| 8 | |
| 9 | export default function Expander({ label, children }: ExpanderProps) { |
| 10 | const [expanded, setExpanded] = useState(false); |
| 11 | |
| 12 | return ( |
| 13 | <div> |
| 14 | <div className="text-base" onClick={() => setExpanded(!expanded)}> |
| 15 | {expanded ? ( |
| 16 | <ChevronDownIcon className="h-[16px] w-[16px]" /> |
| 17 | ) : ( |
| 18 | <ChevronRightIcon className="h-[16px] w-[16px]" /> |
| 19 | )}{" "} |
| 20 | <span className="align-top text-sm font-bold">{label}</span> |
| 21 | </div> |
| 22 | {expanded && <div>{children}</div>} |
| 23 | </div> |
| 24 | ); |
| 25 | } |