File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 1
1
import React from "react" ;
2
- import { ThemeProvider } from "../src/components/ThemeProvider" ;
2
+ import { StorybookThemeProvider } from "../src/components/ThemeProvider" ;
3
3
import type { Preview } from "@storybook/react" ;
4
4
import {
5
5
ThemeDefaultBackground ,
@@ -26,12 +26,12 @@ const preview: Preview = {
26
26
} ,
27
27
decorators : [
28
28
( Story ) => (
29
- < ThemeProvider >
29
+ < StorybookThemeProvider >
30
30
< ThemeDefaultBackground >
31
31
< ToggleThemeButton />
32
32
< Story />
33
33
</ ThemeDefaultBackground >
34
- </ ThemeProvider >
34
+ </ StorybookThemeProvider >
35
35
) ,
36
36
] ,
37
37
} ;
Original file line number Diff line number Diff line change @@ -53,6 +53,22 @@ export const ThemeContext = createContext(defaultTheme);
53
53
export const ThemeProvider = ( props : {
54
54
children : React . ReactNode ;
55
55
theme ?: PartialDeep < Theme > ;
56
+ dark ?: boolean
57
+ } ) => {
58
+ const { children, theme : providedTheme , dark } = props ;
59
+ const theme = providedTheme ?? defaultTheme ;
60
+ return (
61
+ < ThemeContext . Provider value = { theme } >
62
+ < StyledThemeProvider theme = { dark ? theme . dark : theme . light } >
63
+ { children }
64
+ </ StyledThemeProvider >
65
+ </ ThemeContext . Provider >
66
+ ) ;
67
+ } ;
68
+
69
+ export const StorybookThemeProvider = ( props : {
70
+ children : React . ReactNode ;
71
+ theme ?: PartialDeep < Theme > ;
56
72
} ) => {
57
73
const { children, theme : providedTheme } = props ;
58
74
const darkMode = useDarkMode ( false ) ;
You can’t perform that action at this time.
0 commit comments