Skip to content

Commit

Permalink
fix(components): pass defaultOpen state to disclosure parent
Browse files Browse the repository at this point in the history
  • Loading branch information
mnlfischer committed Jan 11, 2024
1 parent 8603c7c commit 53cbfd9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
19 changes: 19 additions & 0 deletions src/components/disclosure/disclosure.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,22 @@ export const Stacked: Story = {
</div>
),
};

export const DefaultOpen: Story = {
render: () => (
<div className="w-96">
<Disclosure>
<Disclosure.Button>Disclosure Button</Disclosure.Button>
<Disclosure.Panel>Disclosure Content</Disclosure.Panel>
</Disclosure>
<Disclosure defaultOpen>
<Disclosure.Button>Disclosure Button</Disclosure.Button>
<Disclosure.Panel>Disclosure Content</Disclosure.Panel>
</Disclosure>
<Disclosure>
<Disclosure.Button>Disclosure Button</Disclosure.Button>
<Disclosure.Panel>Disclosure Content</Disclosure.Panel>
</Disclosure>
</div>
),
};
10 changes: 8 additions & 2 deletions src/components/disclosure/disclosure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ const DisclosureButton = ({ children, ...props }: DisclosureButtonProps) => {
);
};

const Disclosure = ({ children }: { children: React.ReactNode }) => {
return <HeadlessUiDisclosure>{children}</HeadlessUiDisclosure>;
const Disclosure = ({
children,
defaultOpen = false,
}: {
children: React.ReactNode;
defaultOpen?: boolean;
}) => {
return <HeadlessUiDisclosure defaultOpen={defaultOpen}>{children}</HeadlessUiDisclosure>;
};

Disclosure.Button = DisclosureButton;
Expand Down

0 comments on commit 53cbfd9

Please sign in to comment.