diff --git a/src/components/disclosure/disclosure.stories.tsx b/src/components/disclosure/disclosure.stories.tsx new file mode 100644 index 00000000..ec7477c9 --- /dev/null +++ b/src/components/disclosure/disclosure.stories.tsx @@ -0,0 +1,46 @@ +import type { Meta, StoryObj } from "@storybook/react"; +import React from "react"; +import { Disclosure } from "./disclosure"; + +const meta: Meta = { + title: "Disclosure", + component: Disclosure, + parameters: { + options: { + showPanel: false, + }, + }, +}; + +export default meta; +type Story = StoryObj; + +export const Default: Story = { + render: () => ( +
+ + Disclosure Button + Disclosure Content + +
+ ), +}; + +export const Stacked: Story = { + render: () => ( +
+ + Disclosure Button + Disclosure Content + + + Disclosure Button + Disclosure Content + + + Disclosure Button + Disclosure Content + +
+ ), +}; diff --git a/src/components/disclosure/disclosure.tsx b/src/components/disclosure/disclosure.tsx new file mode 100644 index 00000000..01c9b9e2 --- /dev/null +++ b/src/components/disclosure/disclosure.tsx @@ -0,0 +1,43 @@ +import React from "react"; +import { Disclosure as HeadlessUiDisclosure } from "@headlessui/react"; +import { ChevronDownIcon } from "../../icons"; +import { classNames } from "../../util/class-names"; + +interface DisclosurePanelProps extends React.ComponentPropsWithoutRef<"div"> { + children: React.ReactNode; +} + +const DisclosurePanel = ({ children, ...props }: DisclosurePanelProps) => { + return {children}; +}; + +interface DisclosureButtonProps extends React.ComponentPropsWithoutRef<"button"> { + children: React.ReactNode; +} + +const DisclosureButton = ({ children, ...props }: DisclosureButtonProps) => { + return ( + + {({ open }) => ( + <> + {children} + + + )} + + ); +}; + +const Disclosure = ({ children }: { children: React.ReactNode }) => { + return {children}; +}; + +Disclosure.Button = DisclosureButton; +Disclosure.Panel = DisclosurePanel; + +export { Disclosure }; diff --git a/src/components/disclosure/index.tsx b/src/components/disclosure/index.tsx new file mode 100644 index 00000000..b1969328 --- /dev/null +++ b/src/components/disclosure/index.tsx @@ -0,0 +1 @@ +export { Disclosure } from "./disclosure"; diff --git a/src/components/index.ts b/src/components/index.ts index 3e5d9489..127369c9 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -28,3 +28,4 @@ export { Toast } from "./toast"; export { Toggle } from "./toggle"; export { Tooltip } from "./tooltip"; export { TopBar } from "./top-bar"; +export { Disclosure } from "./disclosure";