Skip to content

Commit

Permalink
feat!: remove configure (i18n from uikit used instead) (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
korvin89 authored and amje committed Feb 6, 2024
1 parent 6b99075 commit 41475bf
Show file tree
Hide file tree
Showing 32 changed files with 57 additions and 119 deletions.
6 changes: 1 addition & 5 deletions .storybook/decorators/withLang.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import React from 'react';

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

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

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

uiKitConfigure({lang});
configure({lang});

return <Story key={lang} {...context} />;
Expand Down
2 changes: 1 addition & 1 deletion src/components/AdaptiveTabs/AdaptiveTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import ResizeObserver from 'resize-observer-polyfill';
import {block} from '../utils/cn';

import {DEFAULT_BREAK_POINTS_CONFIG} from './constants';
import i18n from './i18n';
import {i18n} from './i18n';

import './AdaptiveTabs.scss';

Expand Down
7 changes: 4 additions & 3 deletions src/components/AdaptiveTabs/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 = 'AdaptiveTabs';
export default registerKeyset({en, ru}, COMPONENT);
export const i18n = addComponentKeysets({en, ru}, `${NAMESPACE}adaptive-tabs`);
2 changes: 1 addition & 1 deletion src/components/ChangelogDialog/ChangelogDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {block} from '../utils/cn';

import {ErrorContainer} from './components/ErrorContainer/ErrorContainer';
import {Item} from './components/Item/Item';
import i18n from './i18n';
import {i18n} from './i18n';
import type {ChangelogItem} from './types';

import './ChangelogDialog.scss';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';

import {Alert} from '@gravity-ui/uikit';

import i18n from '../../i18n';
import {i18n} from '../../i18n';

interface ErrorContainerProps {
onRetryClick?: () => void;
Expand Down
2 changes: 1 addition & 1 deletion src/components/ChangelogDialog/components/Item/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {CirclePlay} from '@gravity-ui/icons';
import {Button, Icon, Label} from '@gravity-ui/uikit';

import {block} from '../../../utils/cn';
import i18n from '../../i18n';
import {i18n} from '../../i18n';
import type {ChangelogItem} from '../../types';
import {Picture} from '../Picture/Picture';

Expand Down
8 changes: 4 additions & 4 deletions src/components/ChangelogDialog/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +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 = 'ChangelogDialog';

export default registerKeyset({en, ru}, COMPONENT);
export const i18n = addComponentKeysets({en, ru}, `${NAMESPACE}changelog-dialog`);
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import {Alert, Button, Link, useMobile} from '@gravity-ui/uikit';

import {block} from '../../../utils/cn';
import i18n from '../../i18n';
import {i18n} from '../../i18n';

import {ConsentNotificationProps} from './types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {Button, Icon, Link, Modal, Text, useDirection, useMobile} from '@gravity
import {block} from '../../../utils/cn';
import {ConsentType} from '../../ConsentManager';
import type {Consents} from '../../ConsentManager';
import i18n from '../../i18n';
import {i18n} from '../../i18n';
import {FoldableList} from '../FoldableList/FoldableList';

import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import {Button, Portal} from '@gravity-ui/uikit';

import {block} from '../../../utils/cn';
import i18n from '../../i18n';
import {i18n} from '../../i18n';

import {SimpleConsentProps} from './types';

Expand Down
7 changes: 4 additions & 3 deletions src/components/CookieConsent/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 = 'CookieConsent';
export default registerKeyset({en, ru}, COMPONENT);
export const i18n = addComponentKeysets({en, ru}, `${NAMESPACE}cookie-consent`);
2 changes: 1 addition & 1 deletion src/components/FormRow/FormRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import {block} from '../utils/cn';

import {FormRowFieldDescription} from './FormRowFieldDescription';
import i18n from './i18n';
import {i18n} from './i18n';
import {FormRowProps} from './types';

import './FormRow.scss';
Expand Down
8 changes: 4 additions & 4 deletions src/components/FormRow/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +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 = 'FormRow';

export default registerKeyset({en, ru}, COMPONENT);
export const i18n = addComponentKeysets({en, ru}, `${NAMESPACE}form-row`);
2 changes: 1 addition & 1 deletion src/components/ItemSelector/ItemSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Button, Icon, List, ListProps} from '@gravity-ui/uikit';

import {block} from '../utils/cn';

import i18n from './i18n';
import {i18n} from './i18n';

import './ItemSelector.scss';

Expand Down
7 changes: 4 additions & 3 deletions src/components/ItemSelector/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 = 'ItemSelector';
export default registerKeyset({en, ru}, COMPONENT);
export const i18n = addComponentKeysets({en, ru}, `${NAMESPACE}item-selector`);
2 changes: 1 addition & 1 deletion src/components/Notifications/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {NotificationsErrorState} from './NotificationsErrorState';
import {NotificationsList} from './NotificationsList';
import {NotificationsLoadingState} from './NotificationsLoadingState';
import {NotificationsProps} from './definitions';
import i18n from './i18n';
import {i18n} from './i18n';

import './Notifications.scss';

Expand Down
2 changes: 1 addition & 1 deletion src/components/Notifications/NotificationsEmptyState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {Icon} from '@gravity-ui/uikit';

import {block} from '../utils/cn';

import i18n from './i18n/index';
import {i18n} from './i18n/index';

import './Notifications.scss';

Expand Down
2 changes: 1 addition & 1 deletion src/components/Notifications/NotificationsErrorState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {Icon} from '@gravity-ui/uikit';

import {block} from '../utils/cn';

import i18n from './i18n/index';
import {i18n} from './i18n/index';

import './Notifications.scss';

Expand Down
7 changes: 4 additions & 3 deletions src/components/Notifications/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 = 'Notifications';
export default registerKeyset({en, ru}, COMPONENT);
export const i18n = addComponentKeysets({en, ru}, `${NAMESPACE}notifications`);
2 changes: 1 addition & 1 deletion src/components/PasswordInput/PasswordInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {

import {block} from '../utils/cn';

import i18n from './i18n';
import {i18n} from './i18n';
import {getActionButtonSizeAndIconSize} from './utils';

import './PasswordInput.scss';
Expand Down
8 changes: 4 additions & 4 deletions src/components/PasswordInput/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +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 = 'PasswordInput';

export default registerKeyset({en, ru}, COMPONENT);
export const i18n = addComponentKeysets({en, ru}, `${NAMESPACE}password-input`);
2 changes: 1 addition & 1 deletion src/components/SharePopover/ShareList/ShareList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {block} from '../../utils/cn';
import {isOfType} from '../../utils/isOfType';
import {ShareListItem} from '../ShareListItem/ShareListItem';
import type {LayoutDirection, ShareOptions} from '../constants';
import i18n from '../i18n';
import {i18n} from '../i18n';
import type {ShareOptionsData} from '../models';

import './ShareList.scss';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {IconData} from '@gravity-ui/uikit';

import {block} from '../../utils/cn';
import {LayoutDirection, ShareOptions} from '../constants';
import i18n from '../i18n';
import {i18n} from '../i18n';
import * as icons from '../icons';
import type {ShareOptionsData} from '../models';

Expand Down
8 changes: 4 additions & 4 deletions src/components/SharePopover/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +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 = 'SharePopover';

export default registerKeyset({en, ru}, COMPONENT);
export const i18n = addComponentKeysets({en, ru}, `${NAMESPACE}share-popover`);
8 changes: 4 additions & 4 deletions src/components/StoreBadge/StoreBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import React from 'react';

import {Icon, Link, LinkProps} from '@gravity-ui/uikit';
import {Icon, Lang, Link, LinkProps} from '@gravity-ui/uikit';

import {i18n} from '../../i18n';
import {AppStoreEn} from '../../icons/stores/AppStoreEn';
import {AppStoreRu} from '../../icons/stores/AppStoreRu';
import {GooglePlayEn} from '../../icons/stores/GooglePlayEn';
import {GooglePlayRu} from '../../icons/stores/GooglePlayRu';
import {cn} from '../utils/cn';
import {Lang} from '../utils/configure';

const b = cn('store-badge');

Expand All @@ -20,6 +18,7 @@ export type StoreBadgePlatform = typeof androidPlatform | typeof iosPlatform;
export interface StoreBadgeProps extends Omit<LinkProps, 'view' | 'onClick'> {
/** store platform name */
platform: StoreBadgePlatform;
lang?: `${Lang}`;
onClick?: React.MouseEventHandler<HTMLElement>;
}

Expand All @@ -42,9 +41,10 @@ export const StoreBadge = ({
className,
onClick,
href,
lang = Lang.En,
...restLinkProps
}: StoreBadgeProps) => {
const lang = i18n.lang as Lang;
// const lang = i18n.lang as Lang;
const iconData = badgeData?.[platform][lang];

if (!iconData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {ButtonProps} from '@gravity-ui/uikit';

import {MediaRenderer} from '..';
import {block} from '../../../utils/cn';
import i18n from '../../i18n';
import {i18n} from '../../i18n';
import type {StoriesItem} from '../../types';

import './StoriesLayout.scss';
Expand Down
8 changes: 4 additions & 4 deletions src/components/Stories/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +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 = 'Stories';

export default registerKeyset({en, ru}, COMPONENT);
export const i18n = addComponentKeysets({en, ru}, `${NAMESPACE}stories`);
2 changes: 0 additions & 2 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@ export * from './SharePopover';
export * from './StoreBadge';
export * from './Stories';
export * from './StoriesGroup';

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.

5 changes: 0 additions & 5 deletions test-utils/setup-tests.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import {configure} from '@testing-library/dom';

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

libConfigure({
lang: Lang.En,
});
configure({testIdAttribute: 'data-qa'});

global.ResizeObserver = class implements ResizeObserver {
Expand Down

0 comments on commit 41475bf

Please sign in to comment.