|
| 1 | +'use memo'; |
| 2 | + |
| 3 | +import BAISelectionLabel from './BAISelectionLabel'; |
| 4 | +import type { Meta, StoryObj } from '@storybook/react-vite'; |
| 5 | +import { action } from 'storybook/actions'; |
| 6 | + |
| 7 | +const meta: Meta<typeof BAISelectionLabel> = { |
| 8 | + title: 'DataDisplay/BAISelectionLabel', |
| 9 | + component: BAISelectionLabel, |
| 10 | + tags: ['autodocs'], |
| 11 | + parameters: { |
| 12 | + layout: 'padded', |
| 13 | + docs: { |
| 14 | + description: { |
| 15 | + component: ` |
| 16 | +**BAISelectionLabel** displays the number of selected items with an optional clear-all button. |
| 17 | +
|
| 18 | +## Props |
| 19 | +| Prop | Type | Default | Description | |
| 20 | +|------|------|---------|-------------| |
| 21 | +| \`count\` | \`number\` | — | Number of selected items. Renders nothing when \`count <= 0\`. | |
| 22 | +| \`onClearSelection\` | \`() => void\` | — | Callback when the clear icon is clicked. Icon is hidden when omitted. | |
| 23 | + `, |
| 24 | + }, |
| 25 | + }, |
| 26 | + }, |
| 27 | + argTypes: { |
| 28 | + count: { |
| 29 | + control: { type: 'number', min: 0, max: 100 }, |
| 30 | + description: 'Number of selected items. Renders nothing when 0.', |
| 31 | + table: { |
| 32 | + type: { summary: 'number' }, |
| 33 | + }, |
| 34 | + }, |
| 35 | + onClearSelection: { |
| 36 | + description: |
| 37 | + 'Callback fired when the clear icon is clicked. Icon is hidden when omitted.', |
| 38 | + table: { |
| 39 | + type: { summary: '() => void' }, |
| 40 | + }, |
| 41 | + }, |
| 42 | + }, |
| 43 | +}; |
| 44 | + |
| 45 | +export default meta; |
| 46 | +type Story = StoryObj<typeof BAISelectionLabel>; |
| 47 | + |
| 48 | +export const Default: Story = { |
| 49 | + name: 'Basic', |
| 50 | + args: { |
| 51 | + count: 3, |
| 52 | + onClearSelection: action('onClearSelection'), |
| 53 | + }, |
| 54 | +}; |
| 55 | + |
| 56 | +export const WithoutClearButton: Story = { |
| 57 | + parameters: { |
| 58 | + docs: { |
| 59 | + description: { |
| 60 | + story: |
| 61 | + 'When `onClearSelection` is not provided, the clear icon is hidden.', |
| 62 | + }, |
| 63 | + }, |
| 64 | + }, |
| 65 | + args: { |
| 66 | + count: 5, |
| 67 | + }, |
| 68 | +}; |
| 69 | + |
| 70 | +export const Comparison: Story = { |
| 71 | + parameters: { |
| 72 | + docs: { |
| 73 | + description: { |
| 74 | + story: |
| 75 | + 'Side-by-side comparison: with and without the clear button, and different counts.', |
| 76 | + }, |
| 77 | + }, |
| 78 | + }, |
| 79 | + render: () => ( |
| 80 | + <div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}> |
| 81 | + <BAISelectionLabel count={1} onClearSelection={action('clear-1')} /> |
| 82 | + <BAISelectionLabel count={10} onClearSelection={action('clear-10')} /> |
| 83 | + <BAISelectionLabel count={99} onClearSelection={action('clear-99')} /> |
| 84 | + <BAISelectionLabel count={5} /> |
| 85 | + <BAISelectionLabel count={0} onClearSelection={action('clear-0')} /> |
| 86 | + </div> |
| 87 | + ), |
| 88 | +}; |
0 commit comments