📝(react) add documentation for Button component
Let's leverage the power of Storybook ! Use MDX file to create a top notch documentation.
This commit is contained in:
53
packages/react/src/components/Button/index.stories.mdx
Normal file
53
packages/react/src/components/Button/index.stories.mdx
Normal file
@@ -0,0 +1,53 @@
|
||||
import { Canvas, Meta, Story, Source, ArgsTable } from '@storybook/addon-docs';
|
||||
import { Button } from "./index";
|
||||
|
||||
<Meta title="Button/Default" component={Button}/>
|
||||
|
||||
export const Template = (args) => <Button {...args} />;
|
||||
|
||||
# Button
|
||||
|
||||
The Cunningham Button behaves the same as the native html `<button>` element, but with a few extra features.
|
||||
|
||||
<Canvas>
|
||||
<Story id="button--primary"/>
|
||||
<Story id="button--secondary"/>
|
||||
<Story id="button--tertiary"/>
|
||||
</Canvas>
|
||||
|
||||
<Source
|
||||
language='ts'
|
||||
dark
|
||||
format={false}
|
||||
code={`import { Button } from "@openfun/cunningham-react";`}
|
||||
/>
|
||||
|
||||
|
||||
## Disabled
|
||||
|
||||
The button can be disabled. The disabled button will render the same no matter what color is used.
|
||||
|
||||
> Keep in the mind that a disabled button will never call `onClick` if it is provided.
|
||||
|
||||
<Canvas withSource="open">
|
||||
<Story id="button--disabled"/>
|
||||
</Canvas>
|
||||
|
||||
## Props
|
||||
|
||||
You can use all the props of the native html `<button>` element props plus the following.
|
||||
|
||||
<ArgsTable of={Button} />
|
||||
|
||||
|
||||
|
||||
## Design tokens
|
||||
|
||||
Here a the custom design tokens defined by the button.
|
||||
|
||||
| Token | Description |
|
||||
|--------------- |----------------------------- |
|
||||
| border-radius | Border radius of the button |
|
||||
| height | Height of the button |
|
||||
| font-size | Font size of the label |
|
||||
| font-weight | Font weight of the label |
|
||||
@@ -11,25 +11,25 @@ const Template: ComponentStory<typeof Button> = (args) => <Button {...args} />;
|
||||
|
||||
export const Primary = Template.bind({});
|
||||
Primary.args = {
|
||||
children: "Label",
|
||||
children: "Primary",
|
||||
color: "primary",
|
||||
};
|
||||
|
||||
export const Secondary = Template.bind({});
|
||||
Secondary.args = {
|
||||
children: "Label",
|
||||
children: "Secondary",
|
||||
color: "secondary",
|
||||
};
|
||||
|
||||
export const Tertiary = Template.bind({});
|
||||
Tertiary.args = {
|
||||
children: "Label",
|
||||
children: "Tertiary",
|
||||
color: "tertiary",
|
||||
};
|
||||
|
||||
export const Disabled = Template.bind({});
|
||||
Disabled.args = {
|
||||
children: "Label",
|
||||
children: "Disabled",
|
||||
color: "primary",
|
||||
disabled: true,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user