Skip to content

Commit 61b936c

Browse files
committed
docs: 📝 Improve documentation in SB
- Ajout des différentes dimensions des appareils retenus par le DSFR dans les viewports - Ajout de tests de composants pour les onglets et la modale
1 parent 9dad012 commit 61b936c

File tree

8 files changed

+11708
-2549
lines changed

8 files changed

+11708
-2549
lines changed

.storybook/main.js

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,61 @@
11
import { mergeConfig } from 'vite'
22

33
module.exports = {
4-
"stories": ["../src/**/*.@(mdx|stories.@(js|jsx|ts|tsx))"],
5-
"addons": ["@storybook/addon-links", "@storybook/addon-essentials", {
6-
name: '@storybook/addon-postcss',
7-
options: {
8-
postcssLoaderOptions: {
9-
implementation: require('postcss')
4+
stories: ["../src/**/*.@(mdx|stories.@(js|jsx|ts|tsx))"],
5+
addons: [
6+
"@storybook/addon-links",
7+
"@storybook/addon-essentials",
8+
"@storybook/addon-interactions",
9+
{
10+
name: '@storybook/addon-postcss',
11+
options: {
12+
postcssLoaderOptions: {
13+
implementation: require('postcss')
14+
}
1015
}
1116
}
12-
}],
17+
],
1318
staticDirs: ['../public'],
1419
framework: {
1520
name: "@storybook/vue3-vite",
1621
options: {}
1722
},
23+
features: {
24+
storyStoreV7: true,
25+
},
1826
docs: {
1927
autodocs: true
2028
},
29+
/**
30+
* Extend Vite config
31+
* @param {import('vite').UserConfig} config
32+
* @param {'DEVELOPMENT'|'PRODUCTION'} [configType]
33+
* @returns {Promise<*>}
34+
*/
2135
async viteFinal(config, {
2236
configType
2337
}) {
24-
return mergeConfig(config, {
25-
define: {
26-
'process.env': {}
27-
}
28-
});
38+
// return mergeConfig(config, {
39+
// define: {
40+
// ...config.define,
41+
// 'process.env': {},
42+
// }
43+
// });
44+
config.optimizeDeps = configType === 'PRODUCTION' ? config.optimizeDeps : {
45+
...(config.optimizeDeps || {}),
46+
include: [
47+
...(config?.optimizeDeps?.include || []),
48+
// Fix: `@storybook/addon-interactions` exports is not defined or `jest-mock` does not provide an export named 'fn'
49+
'jest-mock',
50+
// Optional, but prevents error flashing in the Storybook component preview iframe:
51+
// Fix: failed to fetch dynamically import module, avoid cache miss for dependencies on the first load
52+
'@storybook/components',
53+
'@storybook/store',
54+
// Add all addons that imported in the `preview.js` or `preview.ts` file and used in exported constants
55+
'@storybook/addon-links'
56+
],
57+
}
58+
config.define = { ...config.define, 'process.env': {}}
59+
return config;
2960
}
30-
};
61+
};

.storybook/preview-head.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<script>
2+
// Fix: add `jest` to global
3+
window.global = window
4+
</script>

.storybook/preview.js

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import * as jest from "@storybook/jest"
12
import { defineComponent } from 'vue'
23
import { setup } from '@storybook/vue3'
34
import { FocusTrap } from 'focus-trap-vue'
4-
55
// import '@gouvfr/dsfr/dist/core/core.module.js'
66

77
import '../src/assets/variables-fdr.css'
@@ -12,6 +12,8 @@ import './theme.css'
1212

1313
import {OhVueIcon as VIcon} from 'oh-vue-icons'
1414

15+
window.jest = jest
16+
1517
export const parameters = {
1618
actions: { argTypesRegex: "^on[A-Z].*" },
1719
controls: {
@@ -20,6 +22,53 @@ export const parameters = {
2022
date: /Date$/,
2123
},
2224
},
25+
backgrounds: {
26+
values: [
27+
{name: 'black', value: '#000'},
28+
{name: 'dark', value: '#222'},
29+
{name: 'light', value: '#eee'},
30+
{name: 'white', value: '#fff'},
31+
]
32+
},
33+
viewport: {
34+
viewports: {
35+
DSFR_XS: {
36+
name: 'DSFR XS',
37+
styles: {
38+
width: '320px',
39+
height: '768px',
40+
},
41+
},
42+
DSFR_SM: {
43+
name: 'DSFR SM',
44+
styles: {
45+
width: '576px',
46+
height: '1024px',
47+
},
48+
},
49+
DSFR_MD: {
50+
name: 'DSFR MD',
51+
styles: {
52+
width: '768px',
53+
height: '1200px',
54+
},
55+
},
56+
DSFR_LG: {
57+
name: 'DSFR LG',
58+
styles: {
59+
width: '992px',
60+
height: '1600px',
61+
},
62+
},
63+
DSFR_XL: {
64+
name: 'DSFR XL',
65+
styles: {
66+
width: '1440px',
67+
height: '1900px',
68+
},
69+
},
70+
}
71+
},
2372
options: {
2473
storySort: {
2574
method: 'alphabetical',

0 commit comments

Comments
 (0)