diff --git a/.changeset/sharp-years-tan.md b/.changeset/sharp-years-tan.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/sharp-years-tan.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/components/src/Button/Button/_docs/Button.mdx b/packages/components/src/Button/Button/_docs/Button.mdx index 9fcff39afd1..37bd152c1c4 100644 --- a/packages/components/src/Button/Button/_docs/Button.mdx +++ b/packages/components/src/Button/Button/_docs/Button.mdx @@ -1,5 +1,5 @@ -import { Canvas, Controls, DocsStory, Meta } from "@storybook/blocks" -import { ResourceLinks, KaioNotification, Installation } from "~storybook/components" +import { Canvas, Controls, Meta } from "@storybook/blocks" +import { ResourceLinks, KaioNotification, Installation, LinkTo } from "~storybook/components" import * as ButtonStories from "./Button.stories" @@ -23,26 +23,75 @@ import * as ButtonStories from "./Button.stories" ## Overview Buttons perform actions. +If it needs to navigate somewhere and can be opened in a new tab, use a link instead. ## API - +### Variants - +`Default`, `Primary`, `Destructive`, `Secondary` +If no `variant` is specified, a `Default` button will be rendered. - + - +#### Reversed - + - +### Disabled - +A disabled Button prevents user interaction. It doesn't appear in the tab order, can't receive focus, and may not read aloud by a screenreader. - + - +### Icon + +Use any Icon component in the `icon` prop. + + + +#### Icon position + +Change the icon placement with the `iconPosition` prop. +Default position is `start`. + + + +### Badge + +You can display a `Badge` component within the button using the `badge` prop. + + + +### Full width + +Buttons can be stretched to fill the full width of their container. + + + +### Working + +The `working` prop should be used in situations where a button action triggers a change in UI state but needs to wait for a server response, such as submitting a form. + +In conjuction use the `workingLabel` prop to update the label of the button when the working state is triggered. + +Alternatively use the `workingLabelHidden` prop to hide the button label all together. + + + +### Loading + +Use the LoadingInput component for button placeholders. + + + +### Native `form` attribute + +Button extends native HTML "form" attributes for `button`. + +You can use this to submit a `form` using `Button` with a matching form id. + + diff --git a/packages/components/src/Button/Button/_docs/Button.stories.tsx b/packages/components/src/Button/Button/_docs/Button.stories.tsx index deb5836efe7..bbbe38a08c0 100644 --- a/packages/components/src/Button/Button/_docs/Button.stories.tsx +++ b/packages/components/src/Button/Button/_docs/Button.stories.tsx @@ -1,8 +1,8 @@ -import React, { ReactNode } from "react" +import React from "react" import { StoryObj, Meta } from "@storybook/react" import { TextField } from "@kaizen/draft-form" -import { LoadingInput } from "@kaizen/loading-skeleton" import { AddIcon, ArrowRightIcon } from "~components/Icon" +import { LoadingInput } from "~components/Loading" import { Button } from "../index" const meta = { @@ -17,9 +17,6 @@ export default meta type Story = StoryObj -/** - * Buttons perform actions. If it needs to navigate somewhere and can be opened in a new tab, use a link instead. - */ export const Playground: Story = { parameters: { docs: { @@ -30,13 +27,9 @@ export const Playground: Story = { }, } -/** - *

`Default`, `Primary`, `Destructive`, `Secondary`

- *

If no `variant` is specified, a `Default` button will be rendered.

- */ export const Variants: Story = { render: ({ reversed }) => ( -
+ <>
+ ), + decorators: [ + Story => ( +
+ +
+ ), + ], parameters: { controls: { disable: true } }, } @@ -58,37 +58,32 @@ export const Reversed: Story = { }, } -/** - * A disabled Button prevents user interaction. It doesn’t appear in the tab order, can’t receive focus, and may not read aloud by a screenreader. - */ export const Disabled: Story = { args: { disabled: true }, } -/** - *

When a Button is supplied to the `icon` prop, it displays an icon.

- *

`import trashIcon from "@kaizen/component-library/icons/trash.icon.svg"`

- *

Once the icons are imported, you can pass them directly into the Button component.

- *

IconPosition

- *

The consumer can specify the icon placement with the iconPosition prop, default position is start.

- */ +const sourceCodeIcon = ` +import { Button, AddIcon } from "@kaizen/components" + +