1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
| import React from 'react'; import { Meta, StoryObj } from '@storybook/react'; import { Button } from '@hardyhu-ui/core';
const meta: Meta<typeof Button> = { title: 'Components/Button', component: Button, argTypes: { variant: { control: { type: 'select' }, options: ['primary', 'secondary', 'outline', 'text'], description: 'Button variant style', table: { type: { summary: 'string' }, defaultValue: { summary: 'primary' }, }, }, size: { control: { type: 'select' }, options: ['small', 'medium', 'large'], description: 'Button size', table: { type: { summary: 'string' }, defaultValue: { summary: 'medium' }, }, }, disabled: { control: 'boolean', description: 'Disables the button', table: { type: { summary: 'boolean' }, defaultValue: { summary: 'false' }, }, }, loading: { control: 'boolean', description: 'Shows loading state', table: { type: { summary: 'boolean' }, defaultValue: { summary: 'false' }, }, }, fullWidth: { control: 'boolean', description: 'Makes button full width', table: { type: { summary: 'boolean' }, defaultValue: { summary: 'false' }, }, }, onClick: { action: 'clicked' }, }, parameters: { docs: { description: { component: 'A customizable button component with different variants and sizes.', }, }, }, };
export default meta; type Story = StoryObj<typeof Button>;
export const Primary: Story = { args: { variant: 'primary', children: 'Primary Button', }, };
export const Secondary: Story = { args: { variant: "secondary", children: 'Secondary Button', }, };
export const Outline: Story = { args: { variant: 'outline', children: 'Outline Button', }, };
export const Text: Story = { args: { variant: 'text', children: 'Text Button', }, };
export const Sizes: Story = { render: (args) => ( <div style={{ display: 'flex', gap: '1rem', alignItems: 'center' }}> <Button size="small" onClick={args.onClick}>Small</Button> <Button size="medium" onClick={args.onClick}>Medium</Button> <Button size="large" onClick={args.onClick}>Large</Button> </div> ), };
export const Loading: Story = { args: { loading: true, children: 'Loading...', }, };
export const Disabled: Story = { args: { disabled: true, children: 'Disabled Button', }, };
export const FullWidth: Story = { args: { fullWidth: true, children: 'Full Width Button', }, };
export const WithIcons: Story = { render: (args) => ( <div style={{ display: 'flex', gap: '1rem', flexDirection: 'column' }}> <Button leftIcon={<span style={{ fontSize: '1.2em' }}>🔍</span>} onClick={args.onClick} > Search </Button> <Button rightIcon={<span style={{ fontSize: '1.2em' }}>→</span>} onClick={args.onClick} > Next </Button> <Button leftIcon={<span style={{ fontSize: '1.2em' }}>🔄</span>} rightIcon={<span style={{ fontSize: '1.2em' }}>↓</span>} onClick={args.onClick} > Refresh </Button> </div> ), };
|