Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove local configure, use uikit/i18n #177

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading