|
| 1 | +import { Button } from '#src/core/button' |
1 | 2 | import { ButtonGroup } from './button-group' |
2 | | -import { DeprecatedButton } from '../../deprecated/button' |
3 | | -import { Meta } from '@storybook/react-vite' |
4 | | -import { figmaDesignUrls } from '../../storybook/figma' |
5 | | -import { DeprecatedIcon } from '../../deprecated/icon' |
6 | 3 |
|
7 | | -const meta: Meta<typeof ButtonGroup> = { |
| 4 | +import type { Meta, StoryObj } from '@storybook/react-vite' |
| 5 | + |
| 6 | +const meta = { |
8 | 7 | title: 'Core/ButtonGroup', |
9 | 8 | component: ButtonGroup, |
10 | | -} |
| 9 | + argTypes: { |
| 10 | + children: { |
| 11 | + control: 'radio', |
| 12 | + options: ['Secondary', 'Primary action', 'Mixed buttons'], |
| 13 | + mapping: { |
| 14 | + Secondary: ( |
| 15 | + <> |
| 16 | + <Button size="medium" variant="secondary"> |
| 17 | + Button 1 |
| 18 | + </Button> |
| 19 | + <Button size="medium" variant="secondary"> |
| 20 | + Button 2 |
| 21 | + </Button> |
| 22 | + <Button size="medium" variant="secondary"> |
| 23 | + Button 3 |
| 24 | + </Button> |
| 25 | + </> |
| 26 | + ), |
| 27 | + 'Primary action': ( |
| 28 | + <> |
| 29 | + <Button size="medium" variant="secondary"> |
| 30 | + Button 1 |
| 31 | + </Button> |
| 32 | + <Button size="medium" variant="secondary"> |
| 33 | + Button 2 |
| 34 | + </Button> |
| 35 | + <Button size="medium" variant="primary"> |
| 36 | + Button 3 |
| 37 | + </Button> |
| 38 | + </> |
| 39 | + ), |
| 40 | + 'Mixed buttons': ( |
| 41 | + <> |
| 42 | + <Button size="medium" variant="tertiary"> |
| 43 | + Button 1 |
| 44 | + </Button> |
| 45 | + <Button size="medium" variant="secondary"> |
| 46 | + Button 2 |
| 47 | + </Button> |
| 48 | + <Button size="medium" variant="primary"> |
| 49 | + Button 3 |
| 50 | + </Button> |
| 51 | + </> |
| 52 | + ), |
| 53 | + }, |
| 54 | + }, |
| 55 | + }, |
| 56 | +} satisfies Meta<typeof ButtonGroup> |
11 | 57 |
|
12 | 58 | export default meta |
| 59 | +type Story = StoryObj<typeof ButtonGroup> |
13 | 60 |
|
14 | | -export const Default = { |
15 | | - render: ({}) => ( |
16 | | - <ButtonGroup> |
17 | | - <DeprecatedButton>Button 1</DeprecatedButton> |
18 | | - <DeprecatedButton>Button 2</DeprecatedButton> |
19 | | - <DeprecatedButton>Button 3</DeprecatedButton> |
20 | | - <DeprecatedButton>Button 4</DeprecatedButton> |
21 | | - <DeprecatedButton>Button 5</DeprecatedButton> |
22 | | - </ButtonGroup> |
23 | | - ), |
24 | | - parameters: { |
25 | | - design: { |
26 | | - type: 'figma', |
27 | | - url: figmaDesignUrls.buttonGroup, |
28 | | - allowFullscreen: true, |
29 | | - }, |
| 61 | +/** |
| 62 | + * Quite often, all buttons within the button group will be the same variant, but this is not strictly |
| 63 | + * required. What is strictly required is that button groups have at least one button, and all buttons |
| 64 | + * with the group share the same size. |
| 65 | + */ |
| 66 | +export const Example: Story = { |
| 67 | + args: { |
| 68 | + children: 'Secondary', |
30 | 69 | }, |
31 | 70 | } |
32 | 71 |
|
33 | | -export const WithPrimaryButton = { |
34 | | - render: ({}) => ( |
35 | | - <ButtonGroup> |
36 | | - <DeprecatedButton>Button 1</DeprecatedButton> |
37 | | - <DeprecatedButton>Button 2</DeprecatedButton> |
38 | | - <DeprecatedButton>Button 3</DeprecatedButton> |
39 | | - <DeprecatedButton>Button 4</DeprecatedButton> |
40 | | - <DeprecatedButton variant="primary">Button 5</DeprecatedButton> |
41 | | - </ButtonGroup> |
42 | | - ), |
43 | | - parameters: { |
44 | | - design: { |
45 | | - type: 'figma', |
46 | | - url: figmaDesignUrls.buttonGroup, |
47 | | - allowFullscreen: true, |
48 | | - }, |
| 72 | +/** |
| 73 | + * It is common for one button to be a primary action. This is often the case with button groups used in |
| 74 | + * forms and dialogs. |
| 75 | + */ |
| 76 | +export const Primary = { |
| 77 | + args: { |
| 78 | + children: 'Primary action', |
49 | 79 | }, |
50 | 80 | } |
51 | 81 |
|
52 | | -export const WithIconOnlyButton = { |
53 | | - render: ({}) => ( |
54 | | - <ButtonGroup> |
55 | | - <DeprecatedButton>Button 1</DeprecatedButton> |
56 | | - <DeprecatedButton>Button 2</DeprecatedButton> |
57 | | - <DeprecatedButton>Button 3</DeprecatedButton> |
58 | | - <DeprecatedButton>Button 4</DeprecatedButton> |
59 | | - <DeprecatedButton iconLeft={<DeprecatedIcon icon="more" fontSize="1rem" />} /> |
60 | | - </ButtonGroup> |
61 | | - ), |
62 | | - parameters: { |
63 | | - design: { |
64 | | - type: 'figma', |
65 | | - url: figmaDesignUrls.buttonGroup, |
66 | | - allowFullscreen: true, |
67 | | - }, |
| 82 | +/** |
| 83 | + * Of course, where appropriate, any valid button variant can be used within a button group. |
| 84 | + */ |
| 85 | +export const Mixed = { |
| 86 | + args: { |
| 87 | + children: 'Mixed buttons', |
68 | 88 | }, |
69 | 89 | } |
0 commit comments