|
1 | 1 | import React from 'react'; |
2 | | -import { Table, TableProps } from './table'; |
3 | | -import { Meta, StoryFn } from '@storybook/react'; |
| 2 | +import { Table } from './table'; |
| 3 | +import { Meta } from '@storybook/react'; |
4 | 4 | import TableDataHeader from '../table-data-header/table-data-header'; |
5 | 5 | import TableRow from '../table-row/table-row'; |
6 | 6 | import TableData from '../table-data/table-data'; |
7 | 7 | import BodyText from '../body-text/body-text'; |
8 | 8 | import { PrecisionCase } from '../../utils/currency'; |
9 | 9 | import CSPR from '../cspr/cspr'; |
10 | 10 | import PageTile from '../page-tile/page-tile'; |
| 11 | +import TableHead from '../table-head/table-head'; |
| 12 | +import { StoryObj } from '@storybook/react-vite'; |
| 13 | +import { TableLoader } from '../paginated-table/table-loader'; |
11 | 14 |
|
12 | 15 | const mockedData = [ |
13 | 16 | { rank: 1, motes: '50000000000000', owner: 'konrad.cspr' }, |
14 | 17 | { rank: 2, motes: '482900000000000', owner: 'victoria.cspr' }, |
15 | 18 | { rank: 3, motes: '1000000', owner: 'ab.cspr' }, |
16 | 19 | ]; |
17 | 20 |
|
18 | | -export default { |
| 21 | +const meta = { |
19 | 22 | component: Table, |
20 | 23 | title: 'Components/Display/Table', |
| 24 | + subcomponents: { TableDataHeader, TableRow, TableData, TableHead }, |
21 | 25 | args: { |
22 | 26 | renderDataHeaders: () => ( |
23 | 27 | <TableRow> |
@@ -51,16 +55,47 @@ export default { |
51 | 55 | }, |
52 | 56 | } as Meta<typeof Table>; |
53 | 57 |
|
54 | | -const Template: StoryFn<typeof Table> = (args: TableProps) => { |
55 | | - return ( |
| 58 | +export default meta; |
| 59 | + |
| 60 | +type Story = StoryObj<typeof meta>; |
| 61 | + |
| 62 | +export const WithHeader: Story = { |
| 63 | + render: (args) => ( |
56 | 64 | <PageTile> |
57 | 65 | <Table |
| 66 | + {...args} |
58 | 67 | renderDataHeaders={args.renderDataHeaders} |
59 | 68 | renderData={args.renderData} |
60 | 69 | renderFooter={args.renderFooter} |
| 70 | + renderHeader={() => <h3>Main table header</h3>} |
61 | 71 | /> |
62 | 72 | </PageTile> |
63 | | - ); |
| 73 | + ), |
64 | 74 | }; |
65 | 75 |
|
66 | | -export const Primary = Template.bind({}); |
| 76 | +export const WithFooter: Story = { |
| 77 | + render: (args) => ( |
| 78 | + <PageTile> |
| 79 | + <Table |
| 80 | + {...args} |
| 81 | + renderDataHeaders={args.renderDataHeaders} |
| 82 | + renderData={args.renderData} |
| 83 | + renderFooter={() => <h4>Main table gooter</h4>} |
| 84 | + renderHeader={() => <h3>Main table header</h3>} |
| 85 | + /> |
| 86 | + </PageTile> |
| 87 | + ), |
| 88 | +}; |
| 89 | + |
| 90 | +export const Loading: Story = { |
| 91 | + render: (args) => ( |
| 92 | + <PageTile> |
| 93 | + <Table |
| 94 | + {...args} |
| 95 | + renderDataHeaders={args.renderDataHeaders} |
| 96 | + renderFooter={args.renderFooter} |
| 97 | + renderData={() => <TableLoader columnsLength={3} rowsLength={3} />} |
| 98 | + /> |
| 99 | + </PageTile> |
| 100 | + ), |
| 101 | +}; |
0 commit comments