Skip to content
This repository was archived by the owner on Jun 17, 2025. It is now read-only.

Commit 294e426

Browse files
committed
refactor(stories): create mdx for tabs component
1 parent 552141a commit 294e426

File tree

3 files changed

+99
-73
lines changed

3 files changed

+99
-73
lines changed

.storybook/main.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,12 @@ module.exports = {
4545
'../packages/restitution/src/*.stories.@(ts|tsx|js)',
4646
'../packages/status/src/*.stories.@(ts|tsx|js)',
4747
'../packages/table/src/**/*.stories.@(ts|tsx|js)',
48-
'../packages/tabs/src/*.stories.@(ts|tsx|js)',
4948
],
5049
addons: [
5150
'@storybook/addon-essentials',
5251
'@storybook/addon-storysource',
5352
'@storybook/addon-a11y',
54-
'storybook-addon-doc',
53+
'@storybook/addon-docs',
5554
],
5655
webpackFinal: async (config) => {
5756
config.module.rules.push({

packages/tabs/src/Tabs.stories.mdx

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import { Meta, Story, Canvas } from '@storybook/addon-docs';
2+
import { ArgsTable } from '@storybook/addon-docs';
3+
import Tabs from './Tabs';
4+
import Badge from '@axa-fr/react-toolkit-badge';
5+
6+
<Meta title="Components/Tabs" component={Tabs} />
7+
8+
# Tabs
9+
10+
export const TabTitleIconLeft = (
11+
<span>
12+
<i className="glyphicon glyphicon-ok" /> Title with left icon
13+
</span>
14+
);
15+
export const TabTitleIconRight = (
16+
<span>
17+
Title with right icon <i className="glyphicon glyphicon-facetime-video" />
18+
</span>
19+
);
20+
export const TabTitleBadge = (
21+
<span>
22+
Title with badge <Badge classModifier="danger"> 42 </Badge>
23+
</span>
24+
);
25+
export const TabTitleIconBadge = (
26+
<span>
27+
Title with badge and left icon
28+
<Badge classModifier="error"> Lorem ipsum </Badge>
29+
<i className="glyphicon glyphicon-facetime-video" />
30+
</span>
31+
);
32+
export const TemplateTabs = (args) => (
33+
<Tabs {...args}>
34+
<Tabs.Tab title={TabTitleIconLeft} classModifier="has-icon-left">
35+
Content of my first tab
36+
</Tabs.Tab>
37+
<Tabs.Tab title={TabTitleIconRight} classModifier="has-icon-right">
38+
Content of my second tab
39+
</Tabs.Tab>
40+
<Tabs.Tab title={TabTitleBadge}>Content of my third tab </Tabs.Tab>
41+
<Tabs.Tab title={TabTitleIconBadge} classModifier="has-icon-left">
42+
Content of my fifth tab
43+
</Tabs.Tab>
44+
</Tabs>
45+
);
46+
47+
export const TemplateTab = (args) => (
48+
<Tabs>
49+
<Tabs.Tab
50+
title={args.title}
51+
classModifier={args.classModifier}
52+
className={args.className}>
53+
{args.children}
54+
</Tabs.Tab>
55+
</Tabs>
56+
);
57+
58+
The tabs component allows you to create tabs with different content for each and to switch between those tabs.
59+
60+
By changing the `activeIndex` property, you can specify which tab is active.
61+
Don't forget to import the component css file, so that your tabs have the correct style.
62+
63+
```javascript
64+
import '@axa-fr/react-toolkit-tabs/dist/af-tabs.css';
65+
```
66+
67+
<Canvas>
68+
<Story
69+
name="Multiple tabs"
70+
args={{
71+
activeIndex: '1',
72+
onChange: (e) => console.log(e),
73+
}}>
74+
{TemplateTabs.bind({})}
75+
</Story>
76+
</Canvas>
77+
78+
<ArgsTable story="Multiple tabs" />
79+
80+
# Tab
81+
82+
The tab component allows you to define the `title` property to change the name of your tab.
83+
The `children` property is a ReactNode variable and can contains enriched HTML.
84+
The `classModifier` property allows you to enrich the css class of the `li` element that is being drawn in the DOM.
85+
86+
<Canvas>
87+
<Story
88+
name="One tab"
89+
args={{
90+
title: 'Only tab',
91+
classModifier: 'has-icon-right',
92+
children: 'My only tab',
93+
}}>
94+
{TemplateTab.bind({})}
95+
</Story>
96+
</Canvas>
97+
98+
<ArgsTable story="One tab" />

packages/tabs/src/Tabs.stories.tsx

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)