Skip to content

Commit

Permalink
chore: wip 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Yakutoc committed Nov 7, 2024
1 parent 6a891a5 commit 9c9785a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
11 changes: 10 additions & 1 deletion packages/sdds-finportal/src/components/Badge/Badge.stories.tsx
Original file line number Diff line number Diff line change
@@ -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<typeof Badge> = {
title: 'Content/Badge',
Expand Down
6 changes: 1 addition & 5 deletions packages/sdds-finportal/src/components/Badge/Badge.tsx
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
};
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 9c9785a

Please sign in to comment.