Skip to content

Commit 4cd94bb

Browse files
authored
Merge pull request #475 from codegouvfr/revert-470-feat/upgrade-storybook
Revert "feat(storybook): upgrade from v6 to v10"
2 parents 3c7a751 + 24373f2 commit 4cd94bb

80 files changed

Lines changed: 9449 additions & 2217 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ CHANGELOG.md
44
.yarn_home/
55
/test/integration/
66
/storybook-static/
7-
!.storybook
7+
Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,33 @@
1-
import React, { PropsWithChildren, useEffect } from "react";
2-
import {
3-
DocsContainer as BaseContainer,
4-
DocsContainerProps,
5-
Unstyled
6-
} from "@storybook/addon-docs/blocks";
7-
import { useDarkMode } from "@vueless/storybook-dark-mode";
1+
2+
import React, { useEffect } from "react";
3+
import { DocsContainer as BaseContainer } from "@storybook/addon-docs";
4+
import { useDarkMode } from "storybook-dark-mode";
85
import { darkTheme, lightTheme } from "./customTheme";
96
import "../dist/dsfr/utility/icons/icons.min.css";
107
import "../dist/dsfr/dsfr.css";
118
import { useIsDark } from "../dist/useIsDark";
129
import { startReactDsfr } from "../dist/spa";
1310
import { fr } from "../dist/fr";
1411
import { MuiDsfrThemeProvider } from "../dist/mui";
15-
import { TableOfContentsCustom, TocType } from "./TableOfContents";
1612

1713
startReactDsfr({
1814
"defaultColorScheme": "system",
1915
"useLang": () => "fr"
2016
});
2117

22-
export const DocsContainer = ({ children, context }: PropsWithChildren<DocsContainerProps>) => {
18+
export const DocsContainer = ({ children, context }) => {
2319
const isStorybookUiDark = useDarkMode();
2420
const { setIsDark } = useIsDark();
2521

26-
useEffect(() => {
27-
setIsDark(isStorybookUiDark);
28-
}, [isStorybookUiDark]);
22+
useEffect(
23+
()=> {
24+
setIsDark(isStorybookUiDark);
25+
},
26+
[isStorybookUiDark]
27+
);
2928

3029
const backgroundColor = fr.colors.decisions.background.default.grey.default;
3130

32-
// took from addon-docs/src/blocks/DocsContainer.tsx
33-
let toc: TocType | undefined;
34-
try {
35-
const meta = context.resolveOf("meta", ["meta"]);
36-
toc = meta.preparedMeta.parameters?.docs?.toc;
37-
} catch (err) {
38-
// No meta, falling back to project annotations
39-
toc = context?.projectAnnotations?.parameters?.docs?.toc;
40-
}
41-
4231
return (
4332
<>
4433
<style>{`
@@ -63,12 +52,26 @@ export const DocsContainer = ({ children, context }: PropsWithChildren<DocsConta
6352
}
6453
6554
`}</style>
66-
<BaseContainer context={context} theme={isStorybookUiDark ? darkTheme : lightTheme}>
55+
<BaseContainer
56+
context={{
57+
...context,
58+
"storyById": id => {
59+
const storyContext = context.storyById(id);
60+
return {
61+
...storyContext,
62+
"parameters": {
63+
...storyContext?.parameters,
64+
"docs": {
65+
...storyContext?.parameters?.docs,
66+
"theme": isStorybookUiDark ? darkTheme : lightTheme
67+
}
68+
}
69+
};
70+
}
71+
}}
72+
>
6773
<MuiDsfrThemeProvider>
68-
<Unstyled>
69-
{toc && <TableOfContentsCustom channel={context.channel} />}
70-
{children}
71-
</Unstyled>
74+
{children}
7275
</MuiDsfrThemeProvider>
7376
</BaseContainer>
7477
</>

.storybook/Stories.tsx

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

.storybook/TableOfContents.tsx

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

.storybook/customTheme.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { create } from "@storybook/theming";
2+
3+
const brandImage= "logo.png";
4+
const brandTitle= "@codegouvfr/react-dsfr";
5+
const brandUrl= "https://github.com/codegouvfr/react-dsfr";
6+
const fontBase= '"Marianne", arial, sans-serif';
7+
const fontCode= "monospace";
8+
9+
export const darkTheme = create({
10+
"base": "dark",
11+
"appBg": "#1E1E1E",
12+
"appContentBg": "#161616",
13+
"barBg": "#161616",
14+
"colorSecondary": "#8585F6",
15+
"textColor": "#FFFFFF",
16+
brandImage,
17+
brandTitle,
18+
brandUrl,
19+
fontBase,
20+
fontCode
21+
});
22+
23+
export const lightTheme = create({
24+
"base": "light",
25+
"appBg": "#F6F6F6",
26+
"appContentBg": "#FFFFFF",
27+
"barBg": "#FFFFFF",
28+
"colorSecondary": "#000091",
29+
"textColor": "#212121",
30+
brandImage,
31+
brandTitle,
32+
brandUrl,
33+
fontBase,
34+
fontCode
35+
});

.storybook/customTheme.ts

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

.storybook/main.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module.exports = {
2+
"stories": [
3+
"../stories/*.stories.mdx",
4+
"../stories/*.stories.@(ts|tsx)",
5+
"../stories/blocks/*.stories.@(ts|tsx)",
6+
"../stories/charts/*.stories.@(ts|tsx)",
7+
"../stories/picto/*.stories.@(ts|tsx)",
8+
],
9+
"addons": [
10+
"@storybook/addon-links",
11+
"@storybook/addon-essentials",
12+
"storybook-dark-mode",
13+
"@storybook/addon-a11y"
14+
],
15+
"core": {
16+
"builder": "webpack5"
17+
},
18+
"staticDirs": ["../dist", "./static"]
19+
};

.storybook/main.ts

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

.storybook/manager-head.html

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,4 @@
3333
[data-parent-id^="hidden"] {
3434
display: none !important;
3535
}
36-
37-
/* full manager loader (circle) */
38-
body.dark div[aria-label^="Content is loading..."] {
39-
border-color: rgb(133, 133, 246) rgba(130, 130, 243, 0.29) rgba(130, 130, 243, 0.29) !important;
40-
mix-blend-mode: normal !important;
41-
}
42-
43-
body:not(.dark) div[aria-label^="Content is loading..."] {
44-
border-color: rgb(0, 0, 145) rgba(0, 0, 142, 0.29) rgba(0, 0, 142, 0.29) !important;
45-
mix-blend-mode: normal !important;
46-
}
47-
48-
/* full manager page loader (dsfr vars not available) */
49-
body.dark section[aria-labelledby="main-preview-heading"] div:has(+ #storybook-preview-wrapper) {
50-
background-color: #161616 !important;
51-
}
52-
53-
body:not(.dark) section[aria-labelledby="main-preview-heading"] div:has(+ #storybook-preview-wrapper) {
54-
background-color: #ffffff !important;
55-
}
5636
</style>

0 commit comments

Comments
 (0)