Skip to content

Commit 1197813

Browse files
committed
refactor(stories): create mdx files for table components
1 parent 294e426 commit 1197813

File tree

8 files changed

+215
-208
lines changed

8 files changed

+215
-208
lines changed

.storybook/main.js

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ module.exports = {
4444
'../packages/popover/src/*.stories.@(ts|tsx|js)',
4545
'../packages/restitution/src/*.stories.@(ts|tsx|js)',
4646
'../packages/status/src/*.stories.@(ts|tsx|js)',
47-
'../packages/table/src/**/*.stories.@(ts|tsx|js)',
4847
],
4948
addons: [
5049
'@storybook/addon-essentials',
+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { Meta, Story, Canvas } from '@storybook/addon-docs';
2+
import { ArgsTable } from '@storybook/addon-docs';
3+
import Items from './Items';
4+
5+
<Meta
6+
title="Components/Table/Paging/Items"
7+
component={Items}
8+
argTypes={{
9+
onChange: { action: 'changed' },
10+
items: {
11+
control: {
12+
type: 'array',
13+
options: [5, 10, 25, 50, 100],
14+
},
15+
},
16+
numberItems: {
17+
control: {
18+
type: 'select',
19+
options: [5, 10, 25, 50, 100],
20+
},
21+
},
22+
}}
23+
/>
24+
25+
# Table paging items
26+
27+
export const Template = (args) => <Items {...args} />;
28+
29+
The Items component allows you to change how many items a table component will show.
30+
The `numberItems` property carry that number, as the `items` property allows you to change the list of elements to display in the table.
31+
32+
You will have to install the `select` component in order to have the correct style for this component.
33+
34+
```shell
35+
npm i @axa-fr/react-toolkit-form-input-select
36+
npm i @axa-fr/react-toolkit-form-core
37+
```
38+
39+
The associed stylesheet are the ones from the `select` component of the toolkit.
40+
41+
```javascript
42+
import '@axa-fr/react-toolkit-form-input-select/dist/af-select.css';
43+
import '@axa-fr/react-toolkit-form-core/dist/af-form.css';
44+
```
45+
46+
<Canvas>
47+
<Story
48+
name="Items"
49+
args={{
50+
items: [5, 10, 25, 50, 100],
51+
numberItems: 5,
52+
}}>
53+
{Template.bind({})}
54+
</Story>
55+
</Canvas>
56+
57+
<ArgsTable story="Items" />

packages/table/src/Items/Items.stories.tsx

-40
This file was deleted.
+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { Meta, Story, Canvas } from '@storybook/addon-docs';
2+
import { ArgsTable } from '@storybook/addon-docs';
3+
import Pager from './Pager';
4+
import Modes from './Modes';
5+
6+
<Meta
7+
title="Components/Table/Paging/Pager"
8+
component={Pager}
9+
argTypes={{
10+
onChange: { action: 'changed' },
11+
mode: {
12+
control: {
13+
type: 'select',
14+
options: [Modes.default, Modes.light],
15+
},
16+
},
17+
}}
18+
/>
19+
20+
# Table pager
21+
22+
export const Template = (args) => <Pager {...args} />;
23+
24+
The Pager component allows you to change the page of the table currently seen.
25+
The `mode` property allows you to change between the `default` and `light` mode.
26+
27+
The `previousLabel` and `nextLabel` are only visible with the `default` mode of the page. On the contrary, the `ofLabel` is only visible with the `light` mode of the pager.
28+
29+
Don't forget to import the component css file, so that your pager have the correct style.
30+
31+
```javascript
32+
import '@axa-fr/react-toolkit-table/dist/Pager/af-pager.css';
33+
```
34+
35+
<Canvas>
36+
<Story
37+
name="Pager"
38+
args={{
39+
mode: Modes.default,
40+
currentPage: 5,
41+
numberPages: 23,
42+
}}>
43+
{Template.bind({})}
44+
</Story>
45+
</Canvas>
46+
47+
<ArgsTable story="Pager" />

packages/table/src/Pager/Pager.stories.tsx

-69
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { Meta, Story, Canvas } from '@storybook/addon-docs';
2+
import { ArgsTable } from '@storybook/addon-docs';
3+
import Paging from './Paging';
4+
import Modes from '../Pager/Modes';
5+
6+
<Meta
7+
title="Components/Table/Paging/Paging"
8+
component={Paging}
9+
argTypes={{
10+
onChange: { action: 'changed' },
11+
mode: {
12+
control: {
13+
type: 'select',
14+
options: [Modes.default, Modes.light],
15+
},
16+
},
17+
numberItems: {
18+
control: {
19+
type: 'select',
20+
options: [5, 10, 25, 50, 100],
21+
},
22+
},
23+
}}
24+
/>
25+
26+
# Table full paging
27+
28+
export const Template = (args) => <Paging {...args} />;
29+
30+
The Paging component uses the Items and Pager components to create a full paging experience for the user.
31+
Most of the properties are linked to the Items or Pager components, if you want more details on them, go to the specific documentation of the [Item component](?path=/docs/components-table-paging-items--items) or [Pager component](?path=/docs/components-table-paging-pager--pager).
32+
33+
34+
Don't forget to import the component css files, so that your full paging have the correct style.
35+
36+
```javascript
37+
import '@axa-fr/react-toolkit-table/dist/Paging/af-paging.css';
38+
import '@axa-fr/react-toolkit-table/dist/Pager/af-pager.css';
39+
import '@axa-fr/react-toolkit-form-input-select/dist/af-select.css';
40+
import '@axa-fr/react-toolkit-form-core/dist/af-form.css';
41+
```
42+
43+
<Canvas>
44+
<Story
45+
name="Paging"
46+
args={{
47+
mode: Modes.default,
48+
currentPage: 5,
49+
numberPages: 23,
50+
}}>
51+
{Template.bind({})}
52+
</Story>
53+
</Canvas>

packages/table/src/Paging/Paging.stories.tsx

-49
This file was deleted.

0 commit comments

Comments
 (0)