|
| 1 | +import type { Meta, Story } from '@metamask/snaps-storybook'; |
| 2 | + |
| 3 | +import { Address } from './Address'; |
| 4 | +import type { RowProps } from './Row'; |
| 5 | +import { Row } from './Row'; |
| 6 | +import { Text } from './Text'; |
| 7 | + |
| 8 | +const meta: Meta<typeof Row> = { |
| 9 | + title: 'Row', |
| 10 | + component: Row, |
| 11 | + argTypes: { |
| 12 | + label: { |
| 13 | + description: 'The label of the row, shown on the left.', |
| 14 | + table: { |
| 15 | + type: { summary: 'string' }, |
| 16 | + }, |
| 17 | + }, |
| 18 | + |
| 19 | + children: { |
| 20 | + description: |
| 21 | + 'The children of the row, shown on the right. This can be an address, an image, value, or text.', |
| 22 | + table: { |
| 23 | + type: { |
| 24 | + summary: 'AddressElement | ImageElement | TextElement | ValueElement', |
| 25 | + }, |
| 26 | + }, |
| 27 | + }, |
| 28 | + |
| 29 | + variant: { |
| 30 | + description: 'The variant of the row.', |
| 31 | + options: ['default', 'warning', 'critical'], |
| 32 | + control: { |
| 33 | + type: 'select', |
| 34 | + }, |
| 35 | + table: { |
| 36 | + type: { summary: '"default" | "warning" | "critical"' }, |
| 37 | + defaultValue: { summary: '"default"' }, |
| 38 | + }, |
| 39 | + }, |
| 40 | + |
| 41 | + tooltip: { |
| 42 | + description: 'The tooltip text to show on hover.', |
| 43 | + control: { |
| 44 | + type: 'text', |
| 45 | + }, |
| 46 | + table: { |
| 47 | + type: { summary: 'string' }, |
| 48 | + }, |
| 49 | + }, |
| 50 | + }, |
| 51 | +}; |
| 52 | + |
| 53 | +export default meta; |
| 54 | + |
| 55 | +/** |
| 56 | + * The default row, with a label and children. |
| 57 | + */ |
| 58 | +export const Default: Story<RowProps> = { |
| 59 | + render: (props) => <Row {...props} />, |
| 60 | + args: { |
| 61 | + label: 'Label', |
| 62 | + children: <Text>Row text</Text>, |
| 63 | + }, |
| 64 | +}; |
| 65 | + |
| 66 | +/** |
| 67 | + * A warning row, which indicates a warning. It renders the row with a yellow |
| 68 | + * background. |
| 69 | + */ |
| 70 | +export const Warning: Story<RowProps> = { |
| 71 | + render: (props) => <Row {...props} />, |
| 72 | + args: { |
| 73 | + label: 'Label', |
| 74 | + children: <Text>Warning text</Text>, |
| 75 | + variant: 'warning', |
| 76 | + }, |
| 77 | +}; |
| 78 | + |
| 79 | +/** |
| 80 | + * A critical row, which indicates a critical issue. It renders the row with a |
| 81 | + * red background. |
| 82 | + */ |
| 83 | +export const Critical: Story<RowProps> = { |
| 84 | + render: (props) => <Row {...props} />, |
| 85 | + args: { |
| 86 | + label: 'Label', |
| 87 | + children: <Text>Critical text</Text>, |
| 88 | + variant: 'critical', |
| 89 | + }, |
| 90 | +}; |
| 91 | + |
| 92 | +/** |
| 93 | + * A row with a tooltip, which shows the tooltip text on hover. It shows a |
| 94 | + * different icon depending on the variant. |
| 95 | + */ |
| 96 | +export const Tooltip: Story<RowProps> = { |
| 97 | + name: 'With tooltip', |
| 98 | + render: (props) => <Row {...props} />, |
| 99 | + args: { |
| 100 | + label: 'Label', |
| 101 | + children: <Text>Row text</Text>, |
| 102 | + tooltip: 'Tooltip text', |
| 103 | + }, |
| 104 | +}; |
| 105 | + |
| 106 | +/** |
| 107 | + * A row with an address. |
| 108 | + */ |
| 109 | +export const WithAddress: Story<RowProps> = { |
| 110 | + name: 'With address', |
| 111 | + render: (props) => <Row {...props} />, |
| 112 | + args: { |
| 113 | + label: 'Label', |
| 114 | + children: <Address address="0x4bbeEB066eD09B7AEd07bF39EEe0460DFa261520" />, |
| 115 | + }, |
| 116 | +}; |
0 commit comments