|
1 | 1 | import '../styles/storybook/index.scss'; |
2 | 2 | import '@gravity-ui/uikit/styles/styles.scss'; |
3 | | -import {MobileProvider, Platform, ThemeProvider} from '@gravity-ui/uikit'; |
4 | 3 |
|
5 | 4 | import * as React from 'react'; |
6 | 5 | import {MINIMAL_VIEWPORTS} from '@storybook/addon-viewport'; |
7 | 6 | import type {Decorator, Preview} from '@storybook/react'; |
8 | 7 | import {themeLight} from './theme/light'; |
9 | | -import {PageConstructorProvider} from '../src/containers/PageConstructor/Provider'; |
10 | 8 | import {withMobile} from './decorators/withMobile'; |
11 | 9 | import {withLang} from './decorators/withLang'; |
| 10 | +import {withPageConstructorProvider} from './decorators/withPageConstructorProvider'; |
| 11 | +import {withContextProvider} from './decorators/withContextProvider'; |
12 | 12 | import {DocsDecorator} from './decorators/docs'; |
13 | 13 |
|
14 | | -import {Theme} from '../src'; |
15 | | -import {GlobalThemeController} from './theme/utils/global-theme-controller'; |
16 | | - |
17 | 14 | import '../styles/styles.scss'; |
18 | 15 | import '../styles/root.scss'; |
19 | 16 |
|
20 | | -const withContextProvider: Decorator = (Story, context) => { |
21 | | - const theme = context.globals.theme; |
22 | | - |
23 | | - // to set theme in docs |
24 | | - context.parameters.backgrounds.default = theme; |
25 | | - context.globals.backgrounds = { |
26 | | - value: theme === Theme.Light ? 'white' : 'black', |
27 | | - }; |
28 | | - context.globals.background = theme; |
29 | | - |
30 | | - // TODO: to switch docs theme dynamically in the future |
31 | | - // context.parameters.docs.theme = theme === 'light' ? CommonTheme.light : CommonTheme.dark; |
32 | | - |
33 | | - return ( |
34 | | - <GlobalThemeController> |
35 | | - <ThemeProvider theme={theme}> |
36 | | - <MobileProvider mobile={false} platform={Platform.BROWSER}> |
37 | | - <Story {...context} /> |
38 | | - </MobileProvider> |
39 | | - </ThemeProvider> |
40 | | - </GlobalThemeController> |
41 | | - ); |
42 | | -}; |
43 | | - |
44 | | -const withPageConstructorProvider: Decorator = (Story, context) => { |
45 | | - return ( |
46 | | - <PageConstructorProvider |
47 | | - isMobile={context.globals.platform === 'mobile'} |
48 | | - locale={{lang: context.globals.lang}} |
49 | | - theme={context.globals.theme} |
50 | | - > |
51 | | - <Story {...context} /> |
52 | | - </PageConstructorProvider> |
53 | | - ); |
54 | | -}; |
55 | | - |
56 | 17 | const preview: Preview = { |
57 | 18 | decorators: [withLang, withMobile, withContextProvider, withPageConstructorProvider], |
58 | 19 |
|
@@ -126,7 +87,7 @@ const preview: Preview = { |
126 | 87 | }, |
127 | 88 | }, |
128 | 89 |
|
129 | | - tags: ['autodocs', 'autodocs'], |
| 90 | + tags: ['autodocs', 'autodocs', 'autodocs'], |
130 | 91 | }; |
131 | 92 |
|
132 | 93 | export default preview; |
0 commit comments