Skip to content

Commit 01fd827

Browse files
committed
feat: update deps
1 parent 382cb8f commit 01fd827

40 files changed

+10516
-8237
lines changed

.husky/commit-msg

-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/bin/sh
2-
. "$(dirname "$0")/_/husky.sh"
3-
41
npx commitlint -e

.husky/pre-commit

-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/bin/sh
2-
. "$(dirname "$0")/_/husky.sh"
3-
41
npx nano-staged

.storybook/decorators/withLang.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import React from 'react';
22

3-
import type {DecoratorFn} from '@storybook/react';
3+
import {configure as uiKitConfigure} from '@gravity-ui/uikit';
4+
import type {Decorator} from '@storybook/react';
45

5-
import {Lang, configure} from '../../src';
6+
import {configure} from '../../src';
67

7-
export const withLang: DecoratorFn = (Story, context) => {
8+
export const withLang: Decorator = (Story, context) => {
89
const lang = context.globals.lang;
910

10-
configure({
11-
lang: lang as Lang,
12-
});
11+
uiKitConfigure({lang});
12+
configure({lang});
1313

1414
return <Story key={lang} {...context} />;
1515
};

.storybook/decorators/withMobile.tsx

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
import React from 'react';
22

3-
import {useMobile} from '@gravity-ui/uikit';
4-
import type {DecoratorFn} from '@storybook/react';
3+
import {MobileProvider} from '@gravity-ui/uikit';
4+
import type {Decorator} from '@storybook/react';
55

6-
export const withMobile: DecoratorFn = (Story, context) => {
7-
const mobileValue = context.globals.platform === 'mobile';
6+
export const withMobile: Decorator = (Story, context) => {
7+
const platform = context.globals.platform;
88

9-
const [, setMobile] = useMobile(); // eslint-disable-line react-hooks/rules-of-hooks
10-
11-
// eslint-disable-next-line react-hooks/rules-of-hooks
12-
React.useEffect(() => {
13-
setMobile(mobileValue);
14-
}, [mobileValue]);
15-
16-
return <Story {...context} />;
9+
return (
10+
<MobileProvider mobile={platform === 'mobile'} platform={platform}>
11+
<Story key={platform} {...context} />
12+
</MobileProvider>
13+
);
1714
};
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react';
2+
3+
import type {Decorator} from '@storybook/react';
4+
5+
export const withStrictMode: Decorator = (Story, context) => {
6+
const children = <Story {...context} />;
7+
8+
if (context.parameters?.disableStrictMode) {
9+
return children;
10+
}
11+
12+
return <React.StrictMode>{children}</React.StrictMode>;
13+
};

.storybook/decorators/withTheme.tsx

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
3+
import {ThemeProvider} from '@gravity-ui/uikit';
4+
import type {Decorator} from '@storybook/react';
5+
6+
export const withTheme: Decorator = (Story, context) => {
7+
return (
8+
<ThemeProvider theme={context.globals.theme} direction={context.globals.direction}>
9+
<Story {...context} />
10+
</ThemeProvider>
11+
);
12+
};

.storybook/preview.tsx

+21-28
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,17 @@ import './styles.scss';
33
// eslint-disable-next-line import/order
44
import '@gravity-ui/uikit/styles/styles.css';
55

6-
import React from 'react';
7-
8-
import {Lang, MobileProvider, ThemeProvider, configure as uiKitConfigure} from '@gravity-ui/uikit';
96
import {MINIMAL_VIEWPORTS} from '@storybook/addon-viewport';
10-
import type {Decorator, Preview} from '@storybook/react';
11-
12-
import {configure} from '../src';
7+
import type {Preview} from '@storybook/react';
138

149
import {withLang} from './decorators/withLang';
1510
import {withMobile} from './decorators/withMobile';
11+
import {withStrictMode} from './decorators/withStrictMode';
12+
import {withTheme} from './decorators/withTheme';
1613
import {Docs} from './docs';
1714

18-
configure({
19-
lang: Lang.En,
20-
});
21-
uiKitConfigure({
22-
lang: Lang.En,
23-
});
24-
25-
const withContextProvider: Decorator = (Story, context) => {
26-
return (
27-
<React.StrictMode>
28-
<ThemeProvider theme={context.globals.theme}>
29-
<MobileProvider>
30-
<Story {...context} />
31-
</MobileProvider>
32-
</ThemeProvider>
33-
</React.StrictMode>
34-
);
35-
};
36-
3715
const preview: Preview = {
38-
decorators: [withMobile, withLang, withContextProvider],
16+
decorators: [withLang, withMobile, withTheme, withStrictMode],
3917
parameters: {
4018
docs: {
4119
page: Docs,
@@ -60,9 +38,10 @@ const preview: Preview = {
6038
items: [
6139
{value: 'light', right: '☼', title: 'Light'},
6240
{value: 'dark', right: '☾', title: 'Dark'},
63-
{value: 'light-hc', right: '☼', title: 'High Contrast Light (beta)'},
64-
{value: 'dark-hc', right: '☾', title: 'High Contrast Dark (beta)'},
41+
{value: 'light-hc', right: '☼', title: 'Light (high contrast)'},
42+
{value: 'dark-hc', right: '☾', title: 'Dark (high contrast)'},
6543
],
44+
dynamicTitle: true,
6645
},
6746
},
6847
lang: {
@@ -74,6 +53,19 @@ const preview: Preview = {
7453
{value: 'en', right: '🇬🇧', title: 'En'},
7554
{value: 'ru', right: '🇷🇺', title: 'Ru'},
7655
],
56+
dynamicTitle: true,
57+
},
58+
},
59+
direction: {
60+
defaultValue: 'ltr',
61+
toolbar: {
62+
title: 'Direction',
63+
icon: 'menu',
64+
items: [
65+
{value: 'ltr', title: 'Left to Right', icon: 'arrowrightalt'},
66+
{value: 'rtl', title: 'Right to Left', icon: 'arrowleftalt'},
67+
],
68+
dynamicTitle: true,
7769
},
7870
},
7971
platform: {
@@ -84,6 +76,7 @@ const preview: Preview = {
8476
{value: 'desktop', title: 'Desktop', icon: 'browser'},
8577
{value: 'mobile', title: 'Mobile', icon: 'mobile'},
8678
],
79+
dynamicTitle: true,
8780
},
8881
},
8982
},

gulpfile.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ const {task, src, dest, series, parallel} = require('gulp');
55
const sass = require('gulp-dart-sass');
66
const replace = require('gulp-replace');
77
const ts = require('gulp-typescript');
8-
const rimraf = require('rimraf');
8+
const {rimrafSync} = require('rimraf');
99

1010
const BUILD_DIR = path.resolve('build');
1111

1212
task('clean', (done) => {
13-
rimraf.sync(BUILD_DIR);
14-
rimraf.sync('styles/**/*.css');
13+
rimrafSync(BUILD_DIR);
14+
rimrafSync('styles/**/*.css');
1515
done();
1616
});
1717

0 commit comments

Comments
 (0)