|
| 1 | +import { Meta, Story } from '@storybook/react' |
| 2 | +import React, { ComponentProps } from 'react' |
| 3 | +import { Stack } from '.' |
| 4 | +import { CSS } from '../../stitches.config' |
| 5 | +import { ExampleComponent } from '../../utils/story-utils' |
| 6 | + |
| 7 | +export default { |
| 8 | + title: 'Components/Stack', |
| 9 | + component: Stack, |
| 10 | + argTypes: { |
| 11 | + spacing: { |
| 12 | + control: { |
| 13 | + type: 'select', |
| 14 | + options: ['small', 'default', 'large', 'responsive'], |
| 15 | + }, |
| 16 | + description: |
| 17 | + 'The spacing is available in 3 different sizes, and a responsive version.', |
| 18 | + }, |
| 19 | + align: { |
| 20 | + control: { |
| 21 | + type: 'select', |
| 22 | + options: ['left', 'center', 'right'], |
| 23 | + }, |
| 24 | + description: 'The horizontal alignment can be set using the align prop.', |
| 25 | + }, |
| 26 | + }, |
| 27 | +} as Meta |
| 28 | + |
| 29 | +export const Default: Story<ComponentProps<typeof Stack>> = (args) => ( |
| 30 | + <Stack {...args}> |
| 31 | + <ExampleComponent /> |
| 32 | + <ExampleComponent /> |
| 33 | + <ExampleComponent /> |
| 34 | + </Stack> |
| 35 | +) |
| 36 | + |
| 37 | +const Template: Story< |
| 38 | + ComponentProps<typeof Stack> & { height: CSS['height']; width: CSS['width'] } |
| 39 | +> = ({ height, width, ...args }) => ( |
| 40 | + <Stack {...args}> |
| 41 | + <ExampleComponent height={height} width={width} /> |
| 42 | + <ExampleComponent height={height} width={width} /> |
| 43 | + <ExampleComponent height={height} width={width} /> |
| 44 | + </Stack> |
| 45 | +) |
| 46 | + |
| 47 | +/** |
| 48 | + * `small` spacing can be used for the stacking of smaller components |
| 49 | + */ |
| 50 | +export const Small = Template.bind({}) |
| 51 | +Small.args = { |
| 52 | + spacing: 'small', |
| 53 | + height: '$6', |
| 54 | +} |
| 55 | + |
| 56 | +/** |
| 57 | + * `large` spacing can be used for the stacking of large components |
| 58 | + */ |
| 59 | +export const Large = Template.bind({}) |
| 60 | +Large.args = { |
| 61 | + spacing: 'large', |
| 62 | + height: '$10', |
| 63 | +} |
| 64 | + |
| 65 | +/** |
| 66 | + * `responsive` spacing can be used for stacks used across multiple display types |
| 67 | + */ |
| 68 | +export const Responsive = Template.bind({}) |
| 69 | +Responsive.args = { |
| 70 | + spacing: 'responsive', |
| 71 | +} |
| 72 | + |
| 73 | +/** |
| 74 | + * `left` alignment is the default |
| 75 | + */ |
| 76 | +export const Left = Template.bind({}) |
| 77 | +Left.args = { |
| 78 | + width: '25%', |
| 79 | + align: 'left', |
| 80 | +} |
| 81 | + |
| 82 | +/** |
| 83 | + * `center` alignment can be used to put items in the center of the stack |
| 84 | + */ |
| 85 | +export const Center = Template.bind({}) |
| 86 | +Center.args = { |
| 87 | + width: '25%', |
| 88 | + align: 'center', |
| 89 | +} |
| 90 | + |
| 91 | +/** |
| 92 | + * `right` alignment can be used to align items to the right of the stack |
| 93 | + */ |
| 94 | +export const Bottom = Template.bind({}) |
| 95 | +Bottom.args = { |
| 96 | + width: '25%', |
| 97 | + align: 'right', |
| 98 | +} |
0 commit comments