Skip to content

Commit 0f3a26d

Browse files
committed
Move wrapper out of template
1 parent 3d02b38 commit 0f3a26d

File tree

3 files changed

+44
-49
lines changed

3 files changed

+44
-49
lines changed

.storybook/DocsContainer.js

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,45 @@ import React from "react";
22
import { DocsContainer as BaseContainer } from "@storybook/addon-docs";
33
import { useDarkMode } from "storybook-dark-mode";
44
import { darkTheme, lightTheme } from "./customTheme";
5+
import { useColors } from "../dist";
56

67
export const DocsContainer = ({ children, context }) => {
7-
const dark = useDarkMode();
8+
const isStorybookUiDark = useDarkMode();
9+
10+
const backgroundColor = useColors().decisions.background.default.grey.default;
811

912
return (
10-
<BaseContainer
11-
context={{
12-
...context,
13-
"storyById": id => {
14-
const storyContext = context.storyById(id);
15-
return {
16-
...storyContext,
17-
"parameters": {
18-
...storyContext?.parameters,
19-
"docs": {
20-
...storyContext?.parameters?.docs,
21-
"theme": dark ? darkTheme : lightTheme
22-
}
23-
}
24-
};
13+
<>
14+
<style>{`
15+
body {
16+
padding: 0 !important,
17+
background-color: ${backgroundColor};
2518
}
26-
}}
27-
>
28-
{children}
29-
</BaseContainer>
19+
20+
.docs-story {
21+
background-color: ${backgroundColor};
22+
}
23+
`}</style>
24+
<BaseContainer
25+
context={{
26+
...context,
27+
"storyById": id => {
28+
const storyContext = context.storyById(id);
29+
return {
30+
...storyContext,
31+
"parameters": {
32+
...storyContext?.parameters,
33+
"docs": {
34+
...storyContext?.parameters?.docs,
35+
"theme": isStorybookUiDark ? darkTheme : lightTheme
36+
}
37+
}
38+
};
39+
}
40+
}}
41+
>
42+
{children}
43+
</BaseContainer>
44+
</>
3045
);
3146
};

docs/getStory.tsx

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,16 @@ export function getStoryFactory<Props extends Record<string, any>>(params: {
3232
setIsDark(darkMode);
3333
}, [darkMode]);
3434

35-
const backgroundColor = useColors().decisions.background.default.grey.default;
36-
3735
return (
38-
<>
39-
<GlobalStyles
40-
styles={{
41-
"html": {
42-
"fontSize": "100% !important"
43-
},
44-
"body": {
45-
"padding": `0 !important`,
46-
backgroundColor
47-
},
48-
".docs-story": {
49-
backgroundColor
50-
}
51-
}}
52-
/>
53-
<div
54-
style={{
55-
"width": width || undefined,
56-
"border": "1px dashed #e8e8e8",
57-
"display": "inline-block"
58-
}}
59-
>
60-
<Component {...props} />
61-
</div>
62-
</>
36+
<div
37+
style={{
38+
"width": width || undefined,
39+
"border": "1px dashed #e8e8e8",
40+
"display": "inline-block"
41+
}}
42+
>
43+
<Component {...props} />
44+
</div>
6345
);
6446
};
6547

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
],
5454
"keywords": [
5555
"dsfr",
56-
"tss-react",
5756
"design system",
5857
"react",
5958
"typescript"
@@ -110,7 +109,6 @@
110109
"storybook-dark-mode": "^1.1.2",
111110
"ts-node": "^10.9.1",
112111
"tsd": "^0.24.1",
113-
"tss-react": "^4.4.4",
114112
"typescript": "^4.9.1-beta",
115113
"vitest": "^0.24.3"
116114
}

0 commit comments

Comments
 (0)