summaryrefslogtreecommitdiffstats
path: root/src/components/atoms/buttons/button.stories.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-03-31 14:25:12 +0200
committerArmand Philippot <git@armandphilippot.com>2022-03-31 15:25:41 +0200
commitd7d453f7333def28007b94b9c9d872f89224fc91 (patch)
tree13d5f88b1d39d3eb46b7ba1c7003d11f827255e6 /src/components/atoms/buttons/button.stories.tsx
parent6640cdd35cab960237b3011d7badc5b9b2eaa5bd (diff)
chore: add a button component
Diffstat (limited to 'src/components/atoms/buttons/button.stories.tsx')
-rw-r--r--src/components/atoms/buttons/button.stories.tsx120
1 files changed, 120 insertions, 0 deletions
diff --git a/src/components/atoms/buttons/button.stories.tsx b/src/components/atoms/buttons/button.stories.tsx
new file mode 100644
index 0000000..5af61bd
--- /dev/null
+++ b/src/components/atoms/buttons/button.stories.tsx
@@ -0,0 +1,120 @@
+import { ComponentMeta, ComponentStory } from '@storybook/react';
+import ButtonComponent from './button';
+
+export default {
+ title: 'Atoms/Buttons',
+ component: ButtonComponent,
+ args: {
+ disabled: false,
+ kind: 'secondary',
+ type: 'button',
+ },
+ argTypes: {
+ 'aria-label': {
+ control: {
+ type: 'text',
+ },
+ description: 'An accessible label.',
+ table: {
+ category: 'Accessibility',
+ },
+ type: {
+ name: 'string',
+ required: false,
+ },
+ },
+ children: {
+ control: {
+ type: 'text',
+ },
+ description: 'The button body.',
+ type: {
+ name: 'string',
+ required: true,
+ },
+ },
+ disabled: {
+ control: {
+ type: 'boolean',
+ },
+ description: 'Render button as disabled.',
+ table: {
+ category: 'Options',
+ defaultValue: { summary: false },
+ },
+ type: {
+ name: 'boolean',
+ required: false,
+ },
+ },
+ kind: {
+ control: {
+ type: 'select',
+ },
+ description: 'Button kind.',
+ options: ['primary', 'secondary', 'tertiary'],
+ table: {
+ category: 'Options',
+ defaultValue: { summary: 'secondary' },
+ },
+ type: {
+ name: 'string',
+ required: false,
+ },
+ },
+ onClick: {
+ control: {
+ type: null,
+ },
+ description: 'A callback function to handle click.',
+ table: {
+ category: 'Events',
+ },
+ type: {
+ name: 'function',
+ required: false,
+ },
+ },
+ type: {
+ control: {
+ type: 'select',
+ },
+ description: 'Button type attribute.',
+ options: ['button', 'reset', 'submit'],
+ table: {
+ category: 'Options',
+ defaultValue: { summary: 'button' },
+ },
+ type: {
+ name: 'string',
+ required: false,
+ },
+ },
+ },
+} as ComponentMeta<typeof ButtonComponent>;
+
+const Template: ComponentStory<typeof ButtonComponent> = (args) => {
+ const { children, type, ...props } = args;
+
+ const getBody = () => {
+ if (children) return children;
+
+ switch (type) {
+ case 'reset':
+ return 'Reset';
+ case 'submit':
+ return 'Submit';
+ case 'button':
+ default:
+ return 'Button';
+ }
+ };
+
+ return (
+ <ButtonComponent type={type} {...props}>
+ {getBody()}
+ </ButtonComponent>
+ );
+};
+
+export const Button = Template.bind({});