Skip to content

Commit

Permalink
feat: remove local configure, use uikit/i18n (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunory committed Feb 8, 2024
1 parent 29fadc1 commit c02bb5a
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 76 deletions.
14 changes: 9 additions & 5 deletions .storybook/decorators/withLang.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import React from 'react';
import type {Decorator} from '@storybook/react';
import {Lang, configure} from '../../src';
import {Lang, configure} from '@gravity-ui/uikit';

export const withLang: Decorator = (Story, context) => {
const lang = context.globals.lang;
const [key, forceRender] = React.useState(0);

configure({
lang: lang as Lang,
});
React.useEffect(() => {
configure({
lang: lang as Lang,
});

return <Story key={lang} {...context} />;
forceRender((c) => c + 1);
}, [lang]);
return <Story key={key} {...context} />;
};
4 changes: 0 additions & 4 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ import React from 'react';
import type {Decorator, Preview} from '@storybook/react';
import {ThemeProvider, MobileProvider, Lang, configure as uiKitConfigure} from '@gravity-ui/uikit';
import {configure as componentsConfigure} from '@gravity-ui/components';
import {configure} from '../src';
import {withMobile} from './decorators/withMobile';
import {withLang} from './decorators/withLang';

configure({
lang: Lang.En,
});
uiKitConfigure({
lang: Lang.En,
});
Expand Down
5 changes: 3 additions & 2 deletions src/components/AllPagesPanel/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {registerKeyset} from '../../utils/registerKeyset';
import {addComponentKeysets} from '@gravity-ui/uikit/i18n';
import {NAMESPACE} from '../../utils/cn';

import en from './en.json';
import ru from './ru.json';

const COMPONENT = 'AllPagesPanel';
export default registerKeyset({en, ru}, COMPONENT);
export default addComponentKeysets({en, ru}, `${NAMESPACE}${COMPONENT}`);
5 changes: 3 additions & 2 deletions src/components/AsideHeader/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {registerKeyset} from '../../utils/registerKeyset';
import {addComponentKeysets} from '@gravity-ui/uikit/i18n';
import {NAMESPACE} from '../../utils/cn';

import en from './en.json';
import ru from './ru.json';

const COMPONENT = 'AsideHeader';
export default registerKeyset({en, ru}, COMPONENT);
export default addComponentKeysets({en, ru}, `${NAMESPACE}${COMPONENT}`);
5 changes: 3 additions & 2 deletions src/components/MobileHeader/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {registerKeyset} from '../../utils/registerKeyset';
import {addComponentKeysets} from '@gravity-ui/uikit/i18n';
import {NAMESPACE} from '../../utils/cn';

import en from './en.json';
import ru from './ru.json';

const COMPONENT = 'MobileHeader';
export default registerKeyset({en, ru}, COMPONENT);
export default addComponentKeysets({en, ru}, `${NAMESPACE}${COMPONENT}`);
5 changes: 3 additions & 2 deletions src/components/Settings/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {registerKeyset} from '../../utils/registerKeyset';
import {addComponentKeysets} from '@gravity-ui/uikit/i18n';
import {NAMESPACE} from '../../utils/cn';

import en from './en.json';
import ru from './ru.json';

const COMPONENT = 'Settings';
export default registerKeyset({en, ru}, COMPONENT);
export default addComponentKeysets({en, ru}, `${NAMESPACE}${COMPONENT}`);
5 changes: 3 additions & 2 deletions src/components/Title/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {registerKeyset} from '../../utils/registerKeyset';
import {addComponentKeysets} from '@gravity-ui/uikit/i18n';
import {NAMESPACE} from '../../utils/cn';

import en from './en.json';
import ru from './ru.json';

const COMPONENT = 'Title';
export default registerKeyset({en, ru}, COMPONENT);
export default addComponentKeysets({en, ru}, `${NAMESPACE}${COMPONENT}`);
2 changes: 0 additions & 2 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,3 @@ export * from './HotkeysPanel';
export * from './Settings';
export * from './MobileHeader';
export * from './types';

export {Lang, configure} from './utils/configure';
33 changes: 0 additions & 33 deletions src/components/utils/configure.ts

This file was deleted.

11 changes: 0 additions & 11 deletions src/components/utils/registerKeyset.ts

This file was deleted.

11 changes: 0 additions & 11 deletions src/i18n.ts

This file was deleted.

0 comments on commit c02bb5a

Please sign in to comment.