Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Accordion Example MDS-855 #13

Merged
merged 13 commits into from
Dec 14, 2023
Binary file added docs/app/client/accordion/accordion.webp
Binary file not shown.
3 changes: 3 additions & 0 deletions docs/app/client/accordion/descriptions/ControlOutside.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
title: Open/Close all items programmatically
---
59 changes: 59 additions & 0 deletions docs/app/client/accordion/examples/ControlOutside.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"use client";

import React from "react";
import Accordion from "@heathmont/moon-core-tw/lib/es/accordion/Accordion";
import Button from "@heathmont/moon-core-tw/lib/es/button/Button";
import { ControlsChevronDownSmall } from "@heathmont/moon-icons-tw";

export const ControlOutside = () => {
const items = ["item-1", "item-2"];
const [values, setValues] = React.useState(["item-1"]);
const toggleAll = () =>
values.length === 0 ? setValues(items) : setValues([]);

return (
<div className="flex flex-col gap-4 w-full">
<Button className="w-32" onClick={toggleAll}>
Toggle All
</Button>
<Accordion value={values} onValueChange={setValues}>
<Accordion.Item value="item-1">
<Accordion.Header className="moon-open:[&_svg]:rotate-180">
<Accordion.Button>
<span>Default</span>
<ControlsChevronDownSmall className="text-trunks text-moon-24 transition duration-200 moon-open:text-bulma" />
</Accordion.Button>
</Accordion.Header>
<Accordion.Content>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.
</Accordion.Content>
</Accordion.Item>
<Accordion.Item value="item-2">
<Accordion.Header className="moon-open:[&_svg]:rotate-180">
<Accordion.Button>
<span>Test accordion</span>
<ControlsChevronDownSmall className="text-trunks text-moon-24 transition duration-200 moon-open:text-bulma" />
</Accordion.Button>
</Accordion.Header>
<Accordion.Content>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.
</Accordion.Content>
</Accordion.Item>
</Accordion>
</div>
);
};

export default ControlOutside;
31 changes: 31 additions & 0 deletions docs/app/client/accordion/examples/Customization.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"use client";

import React from "react";
import Accordion from "@heathmont/moon-core-tw/lib/es/accordion/Accordion";
import { ControlsChevronDownSmall } from "@heathmont/moon-icons-tw";

export const Customization = () => (
<>
<Accordion>
<Accordion.Item value="item-1">
<Accordion.Header className="moon-open:[&_svg]:rotate-180 bg-beerus">
<Accordion.Button>
<span>Test accordion with background</span>
<ControlsChevronDownSmall className="text-trunks text-moon-24 transition duration-200 moon-open:text-bulma" />
</Accordion.Button>
</Accordion.Header>
<Accordion.Content className="bg-beerus">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.
</Accordion.Content>
</Accordion.Item>
</Accordion>
</>
);

export default Customization;
2 changes: 2 additions & 0 deletions docs/app/client/accordion/examples/Default.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ export const Default = () => (
</Accordion.Item>
</Accordion>
);

export default Default;
29 changes: 29 additions & 0 deletions docs/app/client/accordion/examples/Disabled.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"use client";

import React from "react";
import Accordion from "@heathmont/moon-core-tw/lib/es/accordion/Accordion";
import { ControlsChevronDownSmall } from "@heathmont/moon-icons-tw";

export const Disabled = () => (
<Accordion>
<Accordion.Item disabled value="item-1">
<Accordion.Header className="moon-open:[&_svg]:rotate-180" disabled>
<Accordion.Button>
<span>Test accordion</span>
<ControlsChevronDownSmall className="text-trunks text-moon-24 transition duration-200 moon-open:text-bulma" />
</Accordion.Button>
</Accordion.Header>
<Accordion.Content>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum.
</Accordion.Content>
</Accordion.Item>
</Accordion>
);

export default Disabled;
43 changes: 43 additions & 0 deletions docs/app/client/accordion/examples/HeaderContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"use client";

import React from "react";
import Accordion from "@heathmont/moon-core-tw/lib/es/accordion/Accordion";
import {
ChatChat,
ChatComment,
ChatCommentAdd,
ChatDoubleBubble,
ControlsChevronDownSmall,
} from "@heathmont/moon-icons-tw";

export const HeaderContent = () => (
<Accordion>
<Accordion.Item value="item-3">
<Accordion.Header>
<Accordion.Button className="moon-open:[&_span_svg]:rotate-180">
<span className="grow">Test accordion</span>
<div className="flex text-moon-24 text-trunks items-center">
<ChatChat />
<ChatComment />
<ChatCommentAdd />
<ChatDoubleBubble />
</div>
<span className="flex justify-center w-6">
<ControlsChevronDownSmall className="text-trunks text-moon-24 transition duration-200 moon-open:text-bulma" />
</span>
</Accordion.Button>
</Accordion.Header>
<Accordion.Content>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum.
</Accordion.Content>
</Accordion.Item>
</Accordion>
);

export default HeaderContent;
29 changes: 29 additions & 0 deletions docs/app/client/accordion/examples/OpenByDefault.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"use client";

import React from "react";
import Accordion from "@heathmont/moon-core-tw/lib/es/accordion/Accordion";
import { ControlsChevronDownSmall } from "@heathmont/moon-icons-tw";

export const OpenByDefault = () => (
<Accordion defaultValue="item-1">
<Accordion.Item value="item-1">
<Accordion.Header className="moon-open:[&_svg]:rotate-180">
<Accordion.Button>
<span>Test accordion</span>
<ControlsChevronDownSmall className="text-trunks text-moon-24 transition duration-200 moon-open:text-bulma" />
</Accordion.Button>
</Accordion.Header>
<Accordion.Content>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum.
</Accordion.Content>
</Accordion.Item>
</Accordion>
);

export default OpenByDefault;
46 changes: 46 additions & 0 deletions docs/app/client/accordion/examples/SingleOpen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"use client";

import React from "react";
import Accordion from "@heathmont/moon-core-tw/lib/es/accordion/Accordion";
import { ControlsChevronDownSmall } from "@heathmont/moon-icons-tw";

export const SingleOpen = () => (
<Accordion singleOpen>
<Accordion.Item value="item-1">
<Accordion.Header className="moon-open:[&_svg]:rotate-180">
<Accordion.Button>
<span>Test accordion</span>
<ControlsChevronDownSmall className="text-trunks text-moon-24 transition duration-200 moon-open:text-bulma" />
</Accordion.Button>
</Accordion.Header>
<Accordion.Content>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum.
</Accordion.Content>
</Accordion.Item>
<Accordion.Item value="item-2">
<Accordion.Header className="moon-open:[&_svg]:rotate-180">
<Accordion.Button>
<span>Test accordion</span>
<ControlsChevronDownSmall className="text-trunks text-moon-24 transition duration-200 moon-open:text-bulma" />
</Accordion.Button>
</Accordion.Header>
<Accordion.Content>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum.
</Accordion.Content>
</Accordion.Item>
</Accordion>
);

export default SingleOpen;
88 changes: 88 additions & 0 deletions docs/app/client/accordion/examples/Sizes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
"use client";

import React from "react";
import Accordion from "@heathmont/moon-core-tw/lib/es/accordion/Accordion";
import { ControlsChevronDownSmall } from "@heathmont/moon-icons-tw";

export const Sizes = () => (
<>
<Accordion itemSize="xl">
<Accordion.Item value="item-1">
<Accordion.Header className="moon-open:[&_svg]:rotate-180">
<Accordion.Button>
<span>X Large (xl)</span>
<ControlsChevronDownSmall className="text-trunks text-moon-24 transition duration-200 moon-open:text-bulma" />
</Accordion.Button>
</Accordion.Header>
<Accordion.Content>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.
</Accordion.Content>
</Accordion.Item>
</Accordion>
<Accordion itemSize="lg">
<Accordion.Item value="item-1">
<Accordion.Header className="moon-open:[&_svg]:rotate-180">
<Accordion.Button>
<span>Large (lg)</span>
<ControlsChevronDownSmall className="text-trunks text-moon-24 transition duration-200 moon-open:text-bulma" />
</Accordion.Button>
</Accordion.Header>
<Accordion.Content>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.
</Accordion.Content>
</Accordion.Item>
</Accordion>
<Accordion>
<Accordion.Item value="item-2">
<Accordion.Header className="moon-open:[&_svg]:rotate-180">
<Accordion.Button>
<span>Medium is default (md)</span>
<ControlsChevronDownSmall className="text-trunks text-moon-24 transition duration-200 moon-open:text-bulma" />
</Accordion.Button>
</Accordion.Header>
<Accordion.Content>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.
</Accordion.Content>
</Accordion.Item>
</Accordion>
<Accordion itemSize="sm">
<Accordion.Item value="item-3">
<Accordion.Header className="moon-open:[&_svg]:rotate-180">
<Accordion.Button>
<span>Small (sm)</span>
<ControlsChevronDownSmall className="text-trunks text-moon-16 transition duration-200 moon-open:text-bulma" />
</Accordion.Button>
</Accordion.Header>
<Accordion.Content>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.
</Accordion.Content>
</Accordion.Item>
</Accordion>
</>
);

export default Sizes;
Loading