Skip to content

Commit 2cab7dd

Browse files
committed
Hide the default collumn in ArgsTable
1 parent f6fc1c2 commit 2cab7dd

File tree

3 files changed

+54
-12
lines changed

3 files changed

+54
-12
lines changed

.storybook/DocsContainer.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ export const DocsContainer = ({ children, context }) => {
2323
[id^=story--] .container {
2424
border: 1px dashed #e8e8e8;
2525
}
26+
27+
.docblock-argstable-head th:nth-child(3), .docblock-argstable-body tr > td:nth-child(3) {
28+
visibility: collapse;
29+
}
30+
2631
`}</style>
2732
<BaseContainer
2833
context={{

docs/Alert.stories.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ const { meta, getStory } = getStoryFactory({
2424
},
2525
"title": {
2626
"description": `Required when the \`<Alert isSmall={false} />\`
27-
(which is the default if \`isSmall\` isn't specified).
28-
`
27+
(which is the default if \`isSmall\` isn't specified).`
2928
},
3029
"description": {
3130
"description": "Required when the `<Alert isSmall />`"
@@ -80,7 +79,7 @@ export const TitleOnlyWarning = getStory(
8079
}
8180
);
8281

83-
export const Error = getStory({
82+
export const ClosableError = getStory({
8483
"severity": "error",
8584
"title": "This is the title",
8685
"description": "This is the description",

docs/getStory.tsx

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { ArgType } from "@storybook/addons";
44
import { symToStr } from "tsafe/symToStr";
55
import { id } from "tsafe/id";
66
import "../dist/dsfr/dsfr.css";
7-
import { startDsfrReact, useIsDark } from "../dist";
7+
import { startDsfrReact, useIsDark, DsfrLangProvider } from "../dist";
88

99
startDsfrReact({ "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

Comments
 (0)