Skip to content

Commit fe916f8

Browse files
authored
feat: upd deps (#1154)
* feat: upd deps * feat: refactor decorators * feat: uninstall storybook/tests * feat: uninstall @chromatic-com/storybook * feat: add new playwright image * feat: revert playwright version * feat: refactor theme in docs stories
1 parent 89a4f11 commit fe916f8

File tree

8 files changed

+12702
-18189
lines changed

8 files changed

+12702
-18189
lines changed

.storybook/decorators/docs/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const b = cn('docs-decorator');
1515

1616
export function DocsDecorator({children, context}: DocsDecoratorProps) {
1717
// @ts-expect-error
18-
const theme = context.store?.globals?.globals.theme;
18+
const theme = context.store.userGlobals.globals.theme;
1919

2020
return (
2121
<div className={b()}>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import {MobileProvider, Platform, ThemeProvider} from '@gravity-ui/uikit';
2+
3+
import * as React from 'react';
4+
import type {Decorator} from '@storybook/react';
5+
6+
import {Theme} from '../../src';
7+
import {GlobalThemeController} from '../theme/utils/global-theme-controller';
8+
9+
export const withContextProvider: Decorator = (Story, context) => {
10+
const theme = context.globals.theme;
11+
12+
// to set theme in docs
13+
context.parameters.backgrounds.default = theme;
14+
context.globals.backgrounds = {
15+
value: theme === Theme.Light ? 'white' : 'black',
16+
};
17+
context.globals.background = theme;
18+
19+
// TODO: to switch docs theme dynamically in the future
20+
// context.parameters.docs.theme = theme === 'light' ? CommonTheme.light : CommonTheme.dark;
21+
22+
return (
23+
<GlobalThemeController>
24+
<ThemeProvider theme={theme}>
25+
<MobileProvider mobile={false} platform={Platform.BROWSER}>
26+
<Story {...context} />
27+
</MobileProvider>
28+
</ThemeProvider>
29+
</GlobalThemeController>
30+
);
31+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import * as React from 'react';
2+
import type {Decorator} from '@storybook/react';
3+
import {PageConstructorProvider} from '../../src/containers/PageConstructor/Provider';
4+
5+
export const withPageConstructorProvider: Decorator = (Story, context) => {
6+
return (
7+
<PageConstructorProvider
8+
isMobile={context.globals.platform === 'mobile'}
9+
locale={{lang: context.globals.lang}}
10+
theme={context.globals.theme}
11+
>
12+
<Story {...context} />
13+
</PageConstructorProvider>
14+
);
15+
};

.storybook/main.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ const config = {
1717
docs: {
1818
autodocs: true,
1919
},
20+
2021
stories: ['./stories/**/*.mdx', '../src/**/__stories__/*.mdx', '../src/**/*.stories.@(ts|tsx)'],
2122
staticDirs: ['./public'],
23+
2224
addons: [
2325
'@storybook/preset-scss',
2426
{
@@ -33,6 +35,7 @@ const config = {
3335
'@storybook/addon-mdx-gfm',
3436
'@storybook/addon-webpack5-compiler-babel',
3537
],
38+
3639
webpackFinal: (storybookBaseConfig: any) => {
3740
storybookBaseConfig.plugins.push(
3841
new MonacoWebpackPlugin(),
@@ -65,6 +68,10 @@ const config = {
6568

6669
return storybookBaseConfig;
6770
},
71+
72+
typescript: {
73+
reactDocgen: 'react-docgen-typescript',
74+
},
6875
};
6976

7077
export default config;

.storybook/manager-head.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
<link rel="icon" href="/story-assets/favicon.png" />
2+
<style type="text/css">
3+
/* Hide create story button next to the search bar */
4+
.search-field + div button {
5+
display: none !important;
6+
}
7+
</style>
Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,19 @@
11
import '../styles/storybook/index.scss';
22
import '@gravity-ui/uikit/styles/styles.scss';
3-
import {MobileProvider, Platform, ThemeProvider} from '@gravity-ui/uikit';
43

54
import * as React from 'react';
65
import {MINIMAL_VIEWPORTS} from '@storybook/addon-viewport';
76
import type {Decorator, Preview} from '@storybook/react';
87
import {themeLight} from './theme/light';
9-
import {PageConstructorProvider} from '../src/containers/PageConstructor/Provider';
108
import {withMobile} from './decorators/withMobile';
119
import {withLang} from './decorators/withLang';
10+
import {withPageConstructorProvider} from './decorators/withPageConstructorProvider';
11+
import {withContextProvider} from './decorators/withContextProvider';
1212
import {DocsDecorator} from './decorators/docs';
1313

14-
import {Theme} from '../src';
15-
import {GlobalThemeController} from './theme/utils/global-theme-controller';
16-
1714
import '../styles/styles.scss';
1815
import '../styles/root.scss';
1916

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-
5617
const preview: Preview = {
5718
decorators: [withLang, withMobile, withContextProvider, withPageConstructorProvider],
5819

@@ -126,7 +87,7 @@ const preview: Preview = {
12687
},
12788
},
12889

129-
tags: ['autodocs', 'autodocs'],
90+
tags: ['autodocs', 'autodocs', 'autodocs'],
13091
};
13192

13293
export default preview;

0 commit comments

Comments
 (0)