diff --git a/packages/storybook/src/stories/Button.stories.tsx b/packages/storybook/src/stories/Button.stories.tsx index e3a2654..7a4f6f5 100644 --- a/packages/storybook/src/stories/Button.stories.tsx +++ b/packages/storybook/src/stories/Button.stories.tsx @@ -3,6 +3,7 @@ import type { Meta, StoryObj } from "storybook-solidjs"; import { Button } from "@codeui/kit"; import { For } from "solid-js"; import { ShareIcon } from "./components/ShareIcon.jsx"; +import { DocsItemsContainer, DocsMultipleItemsContainer } from "./components/Section.jsx"; const buttonThemes = ["primary", "secondary", "tertiary", "negative", "caution"] as const; @@ -137,10 +138,10 @@ export const Ghost: Story = { export const Loading: Story = { render: () => ( -
+ {theme => ( -
+ {size => ( )} -
+ )}
-
+ ), }; diff --git a/packages/storybook/src/stories/Checkbox.stories.tsx b/packages/storybook/src/stories/Checkbox.stories.tsx index daed96d..32aefff 100644 --- a/packages/storybook/src/stories/Checkbox.stories.tsx +++ b/packages/storybook/src/stories/Checkbox.stories.tsx @@ -2,6 +2,7 @@ import type { Meta, StoryObj } from "storybook-solidjs"; import { Checkbox, CheckBoxProps } from "@codeui/kit"; import { For } from "solid-js"; +import { DocsMultipleItemsContainer } from "./components/Section.jsx"; const checkboxSizes = ["xs", "sm", "md", "lg", "xl"] as const; @@ -43,7 +44,7 @@ export const CheckboxDefault: Story = { export const Sizes: Story = { render: props => ( -
+ {size => ( )} -
+ ), }; export const Validation: Story = { render: props => ( -
+ {size => ( )} -
+ ), }; diff --git a/packages/storybook/src/stories/Dialog.stories.tsx b/packages/storybook/src/stories/Dialog.stories.tsx index 28a883f..8461664 100644 --- a/packages/storybook/src/stories/Dialog.stories.tsx +++ b/packages/storybook/src/stories/Dialog.stories.tsx @@ -2,6 +2,7 @@ import type { Meta, StoryObj } from "storybook-solidjs"; import { Button, Dialog, DialogPanelContent, DialogPanelFooter } from "@codeui/kit"; import { createSignal, For } from "solid-js"; +import { DocsItemsContainer } from "./components/Section.jsx"; // More on how to set up stories at: https://storybook.js.org/docs/7.0/solid/writing-stories/introduction const meta = { @@ -12,11 +13,12 @@ const meta = { } satisfies Meta; export default meta; + type Story = StoryObj; export const Sizes: Story = { render: () => ( -
+ {size => { const [open, setOpen] = createSignal(false); @@ -42,7 +44,7 @@ export const Sizes: Story = { ); }} -
+ ), }; @@ -50,7 +52,7 @@ export const OverflowContent: Story = { render: () => { const [open, setOpen] = createSignal(false); return ( -
+ @@ -94,7 +96,7 @@ export const OverflowContent: Story = { -
+ ); }, }; diff --git a/packages/storybook/src/stories/IconButton.stories.tsx b/packages/storybook/src/stories/IconButton.stories.tsx index 23a8e04..8aac035 100644 --- a/packages/storybook/src/stories/IconButton.stories.tsx +++ b/packages/storybook/src/stories/IconButton.stories.tsx @@ -1,8 +1,9 @@ import type { Meta, StoryObj } from "storybook-solidjs"; -import { Button, IconButton } from "@codeui/kit"; +import { IconButton } from "@codeui/kit"; import { For } from "solid-js"; import { ShareIcon } from "./components/ShareIcon.jsx"; +import { DocsItemsContainer, DocsMultipleItemsContainer } from "./components/Section.jsx"; const buttonThemes = ["primary", "secondary", "tertiary", "negative", "caution"] as const; @@ -12,7 +13,7 @@ const buttonSizes = ["xs", "sm", "md", "lg", "xl"] as const; const meta = { title: "DesignSystem/IconButton", component: props => ( - + ), @@ -37,7 +38,7 @@ const meta = { // argTypes: { // backgroundColor: { control: "color" }, // }, -} satisfies Meta; +} satisfies Meta; export default meta; type Story = StoryObj; @@ -122,10 +123,10 @@ export const Pill: Story = { export const Loading: Story = { render: () => ( -
+ {theme => ( -
+ {size => ( @@ -133,9 +134,9 @@ export const Loading: Story = { )} -
+ )}
-
+ ), }; diff --git a/packages/storybook/src/stories/RadioList.stories.tsx b/packages/storybook/src/stories/RadioList.stories.tsx index 0940a81..c126bcc 100644 --- a/packages/storybook/src/stories/RadioList.stories.tsx +++ b/packages/storybook/src/stories/RadioList.stories.tsx @@ -2,6 +2,7 @@ import type { Meta, StoryObj } from "storybook-solidjs"; import { RadioList, RadioListItem, RadioListProps } from "@codeui/kit"; import { For } from "solid-js"; +import { DocsMultipleItemsContainer } from "./components/Section.jsx"; const radioSizes = ["xs", "sm", "md", "lg", "xl"] as const; @@ -63,7 +64,7 @@ export const RadioListVertical: Story = { export const Sizes: Story = { render: (props: RadioListProps) => ( -
+ {size => ( )} -
+ ), }; export const Validation: Story = { render: (props: RadioListProps) => ( -
+ {size => ( )} -
+ ), }; diff --git a/packages/storybook/src/stories/SegmentedControl.stories.tsx b/packages/storybook/src/stories/SegmentedControl.stories.tsx new file mode 100644 index 0000000..b0bdb02 --- /dev/null +++ b/packages/storybook/src/stories/SegmentedControl.stories.tsx @@ -0,0 +1,208 @@ +import type { Meta, StoryObj } from "storybook-solidjs"; + +import { Button, SegmentedControl, SegmentedControlItem } from "@codeui/kit"; +import { createSignal, For } from "solid-js"; +import { DocsItemsContainer } from "./components/Section.jsx"; + +const sizes = ["xs", "sm", "md", "lg", "xl"] as const; + +// More on how to set up stories at: https://storybook.js.org/docs/7.0/solid/writing-stories/introduction +const meta = { + title: "DesignSystem/SegmentedControl", + component: SegmentedControl, + tags: ["autodocs"], + argTypes: { + size: { + options: sizes, + control: { type: "select" }, + }, + variant: { + options: ["solid", "bordered"], + control: { type: "inline-radio" }, + }, + pill: { + type: "boolean", + }, + theme: { + defaultValue: "neutral", + options: ["neutral", "primary"], + control: { type: "inline-radio" }, + }, + }, +} satisfies Meta; + +export default meta; + +type Story = StoryObj; + +const SegmentedControlSizesTemplate: Story = { + render: props => { + return ( + + + {size => ( + + Left + Center + Right + + )} + + + ); + }, +}; + +export const SegmentedControlStory: Story = { + name: "SegmentedControl", + render: props => ( + + Left + Center + Right + + ), + args: { + variant: "solid", + size: "md", + }, +}; + +export const SolidStyle: Story = { + ...SegmentedControlSizesTemplate, + args: { + variant: "solid", + }, +}; + +export const BorderedStyle: Story = { + ...SegmentedControlSizesTemplate, + args: { + variant: "bordered", + }, +}; + +export const PillStyleSolidVariant: Story = { + ...SegmentedControlSizesTemplate, + name: "Pill - Solid Variant", + args: { + variant: "solid", + pill: true, + }, +}; + +export const PillStyleBorderedVariant: Story = { + ...SegmentedControlSizesTemplate, + name: "Pill - Bordered Variant", + args: { + variant: "bordered", + pill: true, + }, +}; + +export const ThemePrimary: Story = { + name: "Theme Primary", + render: props => ( + + Left + Center + Right + + ), + args: { + theme: "primary", + }, +}; + +export const DisabledSegmentedControl: Story = { + name: "Disabled Segmented Control", + render: props => ( + + + Left + Center + Right + + + + Left + Center + Right + + + ), +}; + +export const DisabledSegmentedItem: Story = { + name: "Disabled Segmented Item", + render: props => ( + + + Left + + Center + + Right + + + Left + + Center + + Right + + + ), +}; + +export const FluidWidth: Story = { + name: "Adapt to container size", + render: props => { + const [toggled, setToggled] = createSignal(true); + const [width, setWidth] = createSignal(100); + const [height, setHeight] = createSignal(60); + + function toggle() { + if (toggled()) { + setWidth(70); + setHeight(40); + } else { + setWidth(100); + setHeight(60); + } + setToggled(v => !v); + } + + return ( +
+
+
    +
  • Width: {width()}%
  • +
  • Height: {height()}px
  • +
+
+ +
+
+ + + + Left + + Center + + Right + + +
+ ); + }, +}; diff --git a/packages/storybook/src/stories/components/Section.tsx b/packages/storybook/src/stories/components/Section.tsx new file mode 100644 index 0000000..b9e65cf --- /dev/null +++ b/packages/storybook/src/stories/components/Section.tsx @@ -0,0 +1,9 @@ +import { JSX } from "solid-js"; + +export function DocsItemsContainer(props: JSX.IntrinsicElements["div"]) { + return
; +} + +export function DocsMultipleItemsContainer(props: JSX.IntrinsicElements["div"]) { + return
; +}