Skip to content

Commit 66131bb

Browse files
authored
Merge pull request #62 from rtCamp/fix/dark-mode
Fix: QA issues and styles of storybook for darkmode
2 parents 2c6c3d8 + 84742dd commit 66131bb

File tree

17 files changed

+93
-751
lines changed

17 files changed

+93
-751
lines changed

.storybook/main.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ const config: StorybookConfig = {
3636
},
3737
};
3838
},
39+
typescript: {
40+
check: true,
41+
skipCompiler: true,
42+
reactDocgenTypescriptOptions: {
43+
propFilter: (prop) => (prop.parent ? !/node_modules/.test(prop.parent.fileName) : true),
44+
},
45+
},
3946
};
4047
export default config;
4148

.storybook/modeDecorator.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { withThemeByClassName } from "@storybook/addon-themes";
33
export const decorators = [
44
withThemeByClassName({
55
themes: {
6-
light: "", // Class name for light mode
7-
dark: "dark", // Class name for dark mode
6+
light: "",
7+
dark: "dark",
88
},
9-
defaultTheme: "light", // Default theme
9+
defaultTheme: "light",
1010
}),
1111
];

.storybook/preview-styles.css

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
1-
#storybook-docs,
2-
#storybook-docs .sbdocs-title,
3-
#storybook-docs > .sbdocs > .sbdocs > h1 {
4-
font-family: "Inter", sans-serif;
5-
font-optical-sizing: auto;
6-
}
7-
8-
#storybook-docs .sbdocs-title,
9-
#storybook-docs > .sbdocs > .sbdocs > h1 {
10-
font-weight: 800;
11-
font-size: 36px;
12-
}
13-
14-
#storybook-docs .sbdocs-content p {
15-
font-size: 16px;
16-
}
17-
18-
#storybook-docs .sbdocs-content h2 {
19-
font-weight: 800;
20-
font-size: 24px;
21-
}
22-
231
.dark body {
242
background-color: #171717 !important;
253
}

.storybook/preview.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import type { Preview } from "@storybook/react-vite";
2+
import { themes } from 'storybook/theming';
3+
import { DocsRenderer } from '@storybook/addon-docs';
4+
import type { DocsContextProps, Parameters, Renderer } from 'storybook/internal/types';
25
import './preview-styles.css';
36
import "@rtcamp/frappe-ui-react/theme.css";
47

@@ -13,11 +16,26 @@ const preview: Preview = {
1316
date: /Date$/i,
1417
},
1518
},
19+
docs: {
20+
theme: themes.light,
21+
renderer: () => {
22+
const renderer = new DocsRenderer();
23+
const oldRender = renderer.render;
1624

25+
renderer.render = async (context: DocsContextProps<Renderer>, docsParameter: Parameters, element: HTMLElement) => {
26+
const theme = (context as any).store.userGlobals.globals.theme;
27+
28+
docsParameter.theme = theme === 'dark' ? themes.dark : themes.light;
29+
30+
const result = await oldRender.call(renderer, context, docsParameter, element);
31+
32+
return result;
33+
};
34+
35+
return renderer;
36+
},
37+
},
1738
a11y: {
18-
// 'todo' - show a11y violations in the test UI only
19-
// 'error' - fail CI on a11y violations
20-
// 'off' - skip a11y checks entirely
2139
test: "todo",
2240
},
2341
options: {

README.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Meta, Markdown } from '@storybook/addon-docs/blocks';
22
import GETTINGSTARTED from './GETTING-STARTED.md?raw';
3+
import './preview-styles.css'
34

45
<Meta title="Getting Started" />
56

0 commit comments

Comments
 (0)