Skip to content

Commit

Permalink
feat: update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
amje committed Feb 6, 2024
1 parent 382cb8f commit 01fd827
Show file tree
Hide file tree
Showing 40 changed files with 10,516 additions and 8,237 deletions.
3 changes: 0 additions & 3 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx commitlint -e
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx nano-staged
12 changes: 6 additions & 6 deletions .storybook/decorators/withLang.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React from 'react';

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

import {Lang, configure} from '../../src';
import {configure} from '../../src';

export const withLang: DecoratorFn = (Story, context) => {
export const withLang: Decorator = (Story, context) => {
const lang = context.globals.lang;

configure({
lang: lang as Lang,
});
uiKitConfigure({lang});
configure({lang});

return <Story key={lang} {...context} />;
};
21 changes: 9 additions & 12 deletions .storybook/decorators/withMobile.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import React from 'react';

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

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

const [, setMobile] = useMobile(); // eslint-disable-line react-hooks/rules-of-hooks

// eslint-disable-next-line react-hooks/rules-of-hooks
React.useEffect(() => {
setMobile(mobileValue);
}, [mobileValue]);

return <Story {...context} />;
return (
<MobileProvider mobile={platform === 'mobile'} platform={platform}>
<Story key={platform} {...context} />
</MobileProvider>
);
};
13 changes: 13 additions & 0 deletions .storybook/decorators/withStrictMode.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';

import type {Decorator} from '@storybook/react';

export const withStrictMode: Decorator = (Story, context) => {
const children = <Story {...context} />;

if (context.parameters?.disableStrictMode) {
return children;
}

return <React.StrictMode>{children}</React.StrictMode>;
};
12 changes: 12 additions & 0 deletions .storybook/decorators/withTheme.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';

import {ThemeProvider} from '@gravity-ui/uikit';
import type {Decorator} from '@storybook/react';

export const withTheme: Decorator = (Story, context) => {
return (
<ThemeProvider theme={context.globals.theme} direction={context.globals.direction}>
<Story {...context} />
</ThemeProvider>
);
};
49 changes: 21 additions & 28 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,17 @@ import './styles.scss';
// eslint-disable-next-line import/order
import '@gravity-ui/uikit/styles/styles.css';

import React from 'react';

import {Lang, MobileProvider, ThemeProvider, configure as uiKitConfigure} from '@gravity-ui/uikit';
import {MINIMAL_VIEWPORTS} from '@storybook/addon-viewport';
import type {Decorator, Preview} from '@storybook/react';

import {configure} from '../src';
import type {Preview} from '@storybook/react';

import {withLang} from './decorators/withLang';
import {withMobile} from './decorators/withMobile';
import {withStrictMode} from './decorators/withStrictMode';
import {withTheme} from './decorators/withTheme';
import {Docs} from './docs';

configure({
lang: Lang.En,
});
uiKitConfigure({
lang: Lang.En,
});

const withContextProvider: Decorator = (Story, context) => {
return (
<React.StrictMode>
<ThemeProvider theme={context.globals.theme}>
<MobileProvider>
<Story {...context} />
</MobileProvider>
</ThemeProvider>
</React.StrictMode>
);
};

const preview: Preview = {
decorators: [withMobile, withLang, withContextProvider],
decorators: [withLang, withMobile, withTheme, withStrictMode],
parameters: {
docs: {
page: Docs,
Expand All @@ -60,9 +38,10 @@ const preview: Preview = {
items: [
{value: 'light', right: '☼', title: 'Light'},
{value: 'dark', right: '☾', title: 'Dark'},
{value: 'light-hc', right: '☼', title: 'High Contrast Light (beta)'},
{value: 'dark-hc', right: '☾', title: 'High Contrast Dark (beta)'},
{value: 'light-hc', right: '☼', title: 'Light (high contrast)'},
{value: 'dark-hc', right: '☾', title: 'Dark (high contrast)'},
],
dynamicTitle: true,
},
},
lang: {
Expand All @@ -74,6 +53,19 @@ const preview: Preview = {
{value: 'en', right: '🇬🇧', title: 'En'},
{value: 'ru', right: '🇷🇺', title: 'Ru'},
],
dynamicTitle: true,
},
},
direction: {
defaultValue: 'ltr',
toolbar: {
title: 'Direction',
icon: 'menu',
items: [
{value: 'ltr', title: 'Left to Right', icon: 'arrowrightalt'},
{value: 'rtl', title: 'Right to Left', icon: 'arrowleftalt'},
],
dynamicTitle: true,
},
},
platform: {
Expand All @@ -84,6 +76,7 @@ const preview: Preview = {
{value: 'desktop', title: 'Desktop', icon: 'browser'},
{value: 'mobile', title: 'Mobile', icon: 'mobile'},
],
dynamicTitle: true,
},
},
},
Expand Down
6 changes: 3 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ const {task, src, dest, series, parallel} = require('gulp');
const sass = require('gulp-dart-sass');
const replace = require('gulp-replace');
const ts = require('gulp-typescript');
const rimraf = require('rimraf');
const {rimrafSync} = require('rimraf');

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

task('clean', (done) => {
rimraf.sync(BUILD_DIR);
rimraf.sync('styles/**/*.css');
rimrafSync(BUILD_DIR);
rimrafSync('styles/**/*.css');
done();
});

Expand Down
Loading

0 comments on commit 01fd827

Please sign in to comment.