diff --git a/packages/sdds-finportal/src/components/Badge/Badge.stories.tsx b/packages/sdds-finportal/src/components/Badge/Badge.stories.tsx index 8b0cc1dca7..afe5f98f6d 100644 --- a/packages/sdds-finportal/src/components/Badge/Badge.stories.tsx +++ b/packages/sdds-finportal/src/components/Badge/Badge.stories.tsx @@ -1,8 +1,17 @@ import React, { ComponentProps } from 'react'; import { disableProps, InSpacingDecorator } from '@salutejs/plasma-sb-utils'; import type { StoryObj, Meta } from '@storybook/react'; +import { badgeConfig } from '@salutejs/plasma-new-hope/styled-components'; -import { Badge } from './Badge'; +import { hasComponentDraftConfig } from '../../helpers/hasComponentDraftConfig'; +import { createComponentByConfig } from '../../helpers/createComponentByConfig'; + +import { config as defaultConfig } from './Badge.config'; +import { config as draftConfig } from './Badge.config.draft'; + +const config = hasComponentDraftConfig() ? draftConfig : defaultConfig; + +const Badge = createComponentByConfig(badgeConfig, config); const meta: Meta = { title: 'Content/Badge', diff --git a/packages/sdds-finportal/src/components/Badge/Badge.tsx b/packages/sdds-finportal/src/components/Badge/Badge.tsx index fe91b37649..92b8cfced1 100644 --- a/packages/sdds-finportal/src/components/Badge/Badge.tsx +++ b/packages/sdds-finportal/src/components/Badge/Badge.tsx @@ -1,12 +1,8 @@ import { badgeConfig, component, mergeConfig } from '@salutejs/plasma-new-hope/styled-components'; -import { IS_DRAFT } from '../../helpers/isDraft'; - import { config } from './Badge.config'; -// INFO: После всех изменений draft станет основной конфигурацией -import { config as draft } from './Badge.config.draft'; -const mergedConfig = mergeConfig(badgeConfig, IS_DRAFT() ? draft : config); +const mergedConfig = mergeConfig(badgeConfig, config); /** * Компонент Badge. diff --git a/packages/sdds-finportal/src/helpers/createComponentByConfig.ts b/packages/sdds-finportal/src/helpers/createComponentByConfig.ts new file mode 100644 index 0000000000..f44e57e2aa --- /dev/null +++ b/packages/sdds-finportal/src/helpers/createComponentByConfig.ts @@ -0,0 +1,8 @@ +// INFO: Temporary method +import { component, mergeConfig } from '@salutejs/plasma-new-hope'; + +export const createComponentByConfig = (baseConfig: any, config: any) => { + const componentConfig = mergeConfig(baseConfig, config); + + return component(componentConfig); +}; diff --git a/packages/sdds-finportal/src/helpers/isDraft.ts b/packages/sdds-finportal/src/helpers/hasComponentDraftConfig.ts similarity index 88% rename from packages/sdds-finportal/src/helpers/isDraft.ts rename to packages/sdds-finportal/src/helpers/hasComponentDraftConfig.ts index 01455f7ee8..eed814aee0 100644 --- a/packages/sdds-finportal/src/helpers/isDraft.ts +++ b/packages/sdds-finportal/src/helpers/hasComponentDraftConfig.ts @@ -1,6 +1,6 @@ // INFO: Этот метод будет удален после внесения всех изменений в пакет // INFO: Предназначен для внутреннего использования -export const IS_DRAFT = () => { +export const hasComponentDraftConfig = () => { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore const { IS_DRAFT = false } = import.meta.env;