-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpreview.js
More file actions
82 lines (73 loc) · 2.43 KB
/
preview.js
File metadata and controls
82 lines (73 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import '@gravity-ui/uikit/styles/styles.scss';
import React from 'react';
import {MINIMAL_VIEWPORTS} from '@storybook/addon-viewport';
import {CloudTheme} from './theme';
import {withTheme} from './decorators/withTheme';
import {ThemeProvider} from '@gravity-ui/uikit';
const withContextProvider = (Story, context) => {
const theme = context.globals.theme;
// хак для установки темы в доке
context.parameters.backgrounds.default = theme;
context.globals.backgrounds = {
value: theme === 'light' ? 'white' : 'black',
};
context.globals.background = theme;
// TODO: в будущем возможно появится вариант изменять динамически тему доки, нужно будет перейти на новый способ
// context.parameters.docs.theme = theme === 'light' ? CommonTheme.light : CommonTheme.dark;
return (
<ThemeProvider>
<Story {...context} />
</ThemeProvider>
);
};
export const decorators = [withTheme, withContextProvider];
export const parameters = {
docs: {
theme: CloudTheme,
},
// FIXME: Disabled due to performance reasons. See https://github.com/storybookjs/storybook/issues/5551
// actions: {
// argTypesRegex: '^on.*',
// },
jsx: {showFunctions: true}, // Для того, чтобы функции отображались в сорцах
viewport: {
viewports: MINIMAL_VIEWPORTS,
},
backgrounds: {
default: 'light',
values: [
{name: 'light', value: 'white'},
{name: 'dark', value: 'rgba(45, 44, 51, 1)'},
],
},
options: {
storySort: {
order: ['Theme', 'Components'],
method: 'alphabetical',
},
},
};
export const globalTypes = {
theme: {
name: 'Theme',
description: 'Global theme for components',
defaultValue: 'light',
toolbar: {
items: [
{value: 'light', icon: 'circle', title: 'Light'},
{value: 'dark', icon: 'circlehollow', title: 'Dark'},
],
},
},
lang: {
name: 'Language',
defaultValue: 'ru',
toolbar: {
icon: 'globe',
items: [
{value: 'ru', right: '🇷🇺', title: 'Ru'},
{value: 'en', right: '🇺🇸', title: 'En'},
],
},
},
};