diff --git a/lib/components/display/accordion.jsx b/lib/components/display/accordion.jsx index 822b4b6..df524c3 100644 --- a/lib/components/display/accordion.jsx +++ b/lib/components/display/accordion.jsx @@ -1,4 +1,8 @@ -import { Disclosure } from "@headlessui/react"; +import { + Disclosure, + DisclosureButton, + DisclosurePanel, +} from "@headlessui/react"; import { VscChevronRight, VscChevronDown } from "react-icons/vsc"; import gwMerge from "../../gw-merge"; @@ -7,26 +11,34 @@ function Accordion({ defaultOpen = false, unmountOnClose = false, className, + isOpen, + onToggle, children, + ...props }) { return ( {({ open }) => { + const isExpanded = isOpen ?? open; return ( <> - {heading} {open ? : } - - + + {children} - + ); }} diff --git a/src/app-pages/documentation/display/accordion.jsx b/src/app-pages/documentation/display/accordion.jsx index cf27c9c..d0d2236 100644 --- a/src/app-pages/documentation/display/accordion.jsx +++ b/src/app-pages/documentation/display/accordion.jsx @@ -1,4 +1,5 @@ import { UsaceBox, Code, Text, Accordion, Badge } from "../../../../lib"; +import Link from "../../../../lib/components/navigation/link"; import { CodeExample } from "../../../app-components/code-example"; import PropsTable from "../../../app-components/props-table"; import DocsPage from "../_docs-page"; @@ -38,6 +39,47 @@ const componentProps = [ default: "false", desc: "Whether to unmount the content when the accordion is closed. False will cause the content to be hidden but still in the DOM.", }, + { + name: "className", + type: "string", + default: "undefined", + desc: "Additional classes to apply to the accordion header.", + }, + { + name: "isOpen", + type: "boolean", + default: "undefined", + desc: "Whether the accordion is open. If provided, this will override the defaultOpen prop and the open state will be controlled by the parent component.", + }, + { + name: "onToggle", + type: "function", + default: "undefined", + desc: "Callback function to call when the accordion is toggled.", + }, + { + name: "children", + type: "node", + default: "undefined", + desc: "The content of the accordion when expanded.", + }, + { + name: "props", + type: "object", + default: "undefined", + desc: ( + <> + Additional props to pass to the accordion components. See{" "} + + Headless UI Disclosure + {" "} + docs for more info. + + ), + }, ]; function AccordionDocs() {