Skip to content

Commit

Permalink
Merge pull request #88 from abusix/ahq2-23-pass-defaultopen-prop-to-d…
Browse files Browse the repository at this point in the history
…isclosure-parent

fix(components): pass defaultOpen state to disclosure parent
  • Loading branch information
mnlfischer authored Jan 11, 2024
2 parents 8603c7c + 53cbfd9 commit cc78db5
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 cc78db5

Please sign in to comment.