Skip to content

Commit 6d3dca1

Browse files
authored
Merge pull request #10 from make-software/adjusted-table-stories
refactor tables
2 parents 6ffb87c + 37533ad commit 6d3dca1

6 files changed

Lines changed: 73 additions & 11 deletions

File tree

File renamed without changes.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react';
2+
import { Meta, StoryFn } from '@storybook/react';
3+
import Identicon from './identicon';
4+
5+
export default {
6+
component: Identicon,
7+
title: 'Components/Display/Identicon',
8+
// tags: ['autodocs', '!dev'],
9+
args: {
10+
size: 30,
11+
hexString:
12+
'01f5f1fa995ab7e966428e5a1aed797526ad5b2454c50a63a7aaa2dfeae6a996c2',
13+
},
14+
argTypes: {
15+
hexString: { control: { type: 'text' } },
16+
size: {
17+
control: { type: 'number' },
18+
},
19+
},
20+
} as Meta<typeof Identicon>;
21+
22+
const Template: StoryFn<typeof Identicon> = (args) => <Identicon {...args} />;
23+
24+
export const Primary = Template.bind({});

src/lib/components/paginated-table/paginated-table.stories.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ import { PrecisionCase } from '../../utils/currency';
1010
import CSPR from '../cspr/cspr';
1111
import PageTile from '../page-tile/page-tile';
1212
import FlexRow from '../flex-row/flex-row';
13+
import TableHead from '../table-head/table-head';
1314

1415
export default {
1516
component: PaginatedTable,
16-
title: 'Components/Display/PaginatedTable',
17+
title: 'Components/Display/Table',
18+
subcomponents: { TableDataHeader, TableRow, TableData, TableHead },
1719
args: {
1820
renderHeader: () => (
1921
<HeaderText size={2} tag={'h1'} scale={'xs'}>
@@ -173,4 +175,4 @@ const Template: StoryFn<typeof PaginatedTable> = (
173175
);
174176
};
175177

176-
export const Primary = Template.bind({});
178+
export const WithPagination = Template.bind({});

src/lib/components/table-data-header/table-data-header.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import TableDataHeader, { TableDataHeaderProps } from './table-data-header';
55
export default {
66
component: TableDataHeader,
77
title: 'Components/Display/TableDataHeader',
8+
excludeStories: ['Primary'],
89
} as Meta<typeof TableDataHeader>;
910

1011
const Template: StoryFn<typeof TableDataHeader> = (

src/lib/components/table/table.stories.tsx

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
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';
44
import TableDataHeader from '../table-data-header/table-data-header';
55
import TableRow from '../table-row/table-row';
66
import TableData from '../table-data/table-data';
77
import BodyText from '../body-text/body-text';
88
import { PrecisionCase } from '../../utils/currency';
99
import CSPR from '../cspr/cspr';
1010
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';
1114

1215
const mockedData = [
1316
{ rank: 1, motes: '50000000000000', owner: 'konrad.cspr' },
1417
{ rank: 2, motes: '482900000000000', owner: 'victoria.cspr' },
1518
{ rank: 3, motes: '1000000', owner: 'ab.cspr' },
1619
];
1720

18-
export default {
21+
const meta = {
1922
component: Table,
2023
title: 'Components/Display/Table',
24+
subcomponents: { TableDataHeader, TableRow, TableData, TableHead },
2125
args: {
2226
renderDataHeaders: () => (
2327
<TableRow>
@@ -51,16 +55,47 @@ export default {
5155
},
5256
} as Meta<typeof Table>;
5357

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) => (
5664
<PageTile>
5765
<Table
66+
{...args}
5867
renderDataHeaders={args.renderDataHeaders}
5968
renderData={args.renderData}
6069
renderFooter={args.renderFooter}
70+
renderHeader={() => <h3>Main table header</h3>}
6171
/>
6272
</PageTile>
63-
);
73+
),
6474
};
6575

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+
};

src/lib/icons-index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import AuctionContractIcon from './assets/icons/ic-auction-contract.svg';
1212
export { AuctionContractIcon };
1313
import BidContractIcon from './assets/icons/ic-bid-contract.svg';
1414
export { BidContractIcon };
15-
import Cep18ContractIcon from './assets/icons/ic-cep18-contract.svg';
16-
export { Cep18ContractIcon };
1715
import CheckIcon from './assets/icons/ic-check.svg';
1816
export { CheckIcon };
1917
import CheckboxCheckedInactiveIcon from './assets/icons/ic-checkbox-checked-inactive.svg';
@@ -124,6 +122,8 @@ import SuccessIcon from './assets/icons/ic-success.svg';
124122
export { SuccessIcon };
125123
import TelegramIcon from './assets/icons/ic-telegram.svg';
126124
export { TelegramIcon };
125+
import TokenContractIcon from './assets/icons/ic-token-contract.svg';
126+
export { TokenContractIcon };
127127
import TwitterIcon from './assets/icons/ic-twitter.svg';
128128
export { TwitterIcon };
129129
import Twitter_xIcon from './assets/icons/ic-twitter_x.svg';

0 commit comments

Comments
 (0)