@@ -4,7 +4,7 @@ import type { ArgType } from "@storybook/addons";
44import { symToStr } from "tsafe/symToStr" ;
55import { id } from "tsafe/id" ;
66import "../dist/dsfr/dsfr.css" ;
7- import { startDsfrReact , useIsDark } from "../dist" ;
7+ import { startDsfrReact , useIsDark , DsfrLangProvider } from "../dist" ;
88
99startDsfrReact ( { "defaultColorScheme" : "system" } ) ;
1010
@@ -31,8 +31,9 @@ export function getStoryFactory<Props extends Record<string, any>>(params: {
3131 darkMode : boolean ;
3232 containerWidth : number ;
3333 isFirstStory : boolean ;
34+ lang : "fr" | "en" | "en" | "de" ;
3435 }
35- > = ( { darkMode, containerWidth, isFirstStory, ...props } ) => {
36+ > = ( { darkMode, containerWidth, isFirstStory, lang , ...props } ) => {
3637 const { setIsDark } = useIsDark ( ) ;
3738
3839 useEffect ( ( ) => {
@@ -43,13 +44,43 @@ export function getStoryFactory<Props extends Record<string, any>>(params: {
4344 setIsDark ( darkMode ) ;
4445 } , [ darkMode ] ) ;
4546
46- return containerWidth === 0 ? (
47- < Component { ...props } />
48- ) : (
49- < div className = "container" style = { { "width" : containerWidth } } >
50- < Component { ...props } />
51- </ div >
52- ) ;
47+ if ( containerWidth !== 0 && lang === "fr" ) {
48+ return (
49+ < div className = "container" style = { { "width" : containerWidth } } >
50+ < Component { ...props } />
51+ </ div >
52+ ) ;
53+ }
54+
55+ if ( containerWidth !== 0 && lang !== "fr" ) {
56+ return (
57+ < DsfrLangProvider lang = { lang } >
58+ < div className = "container" style = { { "width" : containerWidth } } >
59+ < Component { ...props } />
60+ </ div >
61+ </ DsfrLangProvider >
62+ ) ;
63+ }
64+
65+ if ( containerWidth !== 0 && lang !== "fr" ) {
66+ return (
67+ < DsfrLangProvider lang = { lang } >
68+ < div className = "container" style = { { "width" : containerWidth } } >
69+ < Component { ...props } />
70+ </ div >
71+ </ DsfrLangProvider >
72+ ) ;
73+ }
74+
75+ if ( containerWidth === 0 && lang !== "fr" ) {
76+ return (
77+ < DsfrLangProvider lang = { lang } >
78+ < Component { ...props } />
79+ </ DsfrLangProvider >
80+ ) ;
81+ }
82+
83+ return < Component { ...props } /> ;
5384 } ;
5485
5586 let isFirstStory = true ;
@@ -62,6 +93,7 @@ export function getStoryFactory<Props extends Record<string, any>>(params: {
6293 out . args = {
6394 "darkMode" : window . matchMedia ( "(prefers-color-scheme: dark)" ) . matches ,
6495 "containerWidth" : defaultContainerWidth ?? 0 ,
96+ "lang" : "fr" ,
6597 isFirstStory,
6698 ...props
6799 } ;
@@ -99,6 +131,12 @@ export function getStoryFactory<Props extends Record<string, any>>(params: {
99131 "step" : 10
100132 }
101133 } ,
134+ "lang" : {
135+ "options" : [ "fr" , "en" , "es" , "de" ] ,
136+ "control" : {
137+ "type" : "select"
138+ }
139+ } ,
102140 "isFirstStory" : {
103141 "table" : {
104142 "disable" : true
0 commit comments