Skip to content

Commit

Permalink
feat(amount): add atom imports;
Browse files Browse the repository at this point in the history
  • Loading branch information
denisx committed Dec 23, 2024
1 parent de4a9dc commit e840ca3
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 64 deletions.
7 changes: 0 additions & 7 deletions .changeset/brown-coins-sing.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/flat-oranges-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@alfalab/core-components-amount': minor
---

Добавлены атомарные импорты
6 changes: 3 additions & 3 deletions packages/amount/src/docs/development.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import styles from '!!raw-loader!../index.module.css';
## Подключение

```jsx
// Атомарные импорты
import { AmountComponent, Pure } from '@alfalab/core-components/amount';

// Компаунд импорт
import { Amount } from '@alfalab/core-components/amount';

// Атомарные импорты
import { AmountComponent, Pure } from '@alfalab/core-components/amount';
```

## Свойства
Expand Down
3 changes: 1 addition & 2 deletions packages/amount/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { PureAmount } from './pure/component';
import { Amount as DefaultAmount } from './component';
import { PureAmount } from './pure';

type AmountType = typeof DefaultAmount & { Pure: typeof PureAmount };

export const Amount: AmountType = DefaultAmount as AmountType;
Amount.Pure = PureAmount;

Expand Down
8 changes: 0 additions & 8 deletions packages/modal/src/Component.responsive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,3 @@ export const ModalResponsive = Object.assign(ModalResponsiveComponent, {
});

ModalResponsiveComponent.displayName = 'ModalResponsiveComponent';

export {
ModalResponsiveComponent as ModalComponentResponsive,
Header as HeaderResponsive,
Content as ContentResponsive,
Footer as FooterResponsive,
Controls as ControlsResponsive,
};
15 changes: 2 additions & 13 deletions packages/modal/src/desktop/Component.desktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,9 @@ const ModalDesktopComponent = forwardRef<HTMLDivElement, ModalDesktopProps>((pro
<Modal {...props} ref={ref} view='desktop' />
));

const HeaderDesktop = Header as React.FC<Omit<HeaderProps, 'titleSize' | 'subtitle'>>;
const ControlsDesktop = Controls as React.FC<Omit<ControlsProps, 'mobileLayout'>>;

export const ModalDesktop = Object.assign(ModalDesktopComponent, {
Content,
Header: HeaderDesktop,
Header: Header as React.FC<Omit<HeaderProps, 'titleSize' | 'subtitle'>>,
Footer,
Controls: ControlsDesktop,
Controls: Controls as React.FC<Omit<ControlsProps, 'mobileLayout'>>,
});

export {
ModalDesktopComponent as ModalComponentDesktop,
Content as ContentDesktop,
HeaderDesktop,
Footer as FooterDesktop,
ControlsDesktop,
};
2 changes: 1 addition & 1 deletion packages/modal/src/desktop/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './Component.desktop';
export { type ModalDesktopProps } from '../typings';
export { ModalDesktopProps } from '../typings';
2 changes: 0 additions & 2 deletions packages/modal/src/docs/description.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ Modal построен как Compound Components. Состоит из Header, C
Чтобы во время скролла заголовок и кнопки оставались неподвижны, их нужно расположить в `header` и `footer`.
Текст и изображения всегда располагаются в `content` части.

Также есть атомарные импорты.

```jsx live mobileHeight={640}
const Header = () => {
const { setHasHeader } = React.useContext(ModalContext);
Expand Down
21 changes: 8 additions & 13 deletions packages/modal/src/docs/development.mdx
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
import { ArgsTabs, CssVars } from 'storybook/blocks';
import { ModalDesktop, ModalMobile, Modal as ModalResponsive } from '..';
import { ModalMobile } from '../mobile';
import { ModalDesktop } from '../desktop';
import { ModalResponsive } from '../Component.responsive';
import vars from '!!raw-loader!../vars.css';

## Подключение

```jsx
// Атомарные импорты
import { ModalComponentDesktop, ContentDesktop, HeaderDesktop, FooterDesktop, ControlsDesktop } from '@alfalab/core-components/modal';
import { ModalComponentMobile, ContentMobile, HeaderMobile, FooterMobile, ControlsMobile } from '@alfalab/core-components/modal';
import { ModalComponentResponsive, ContentResponsive, HeaderResponsive, FooterResponsive, ControlsResponsive } from '@alfalab/core-components/modal';
import { Modal } from '@alfalab/core-components/modal';
import { ModalDesktop } from '@alfalab/core-components/modal/desktop';
import { ModalMobile } from '@alfalab/core-components/modal/mobile';

// Компаунд импорты
import { Modal, ModalDesktop, ModalMobile } from '@alfalab/core-components/modal';

// Контекст
import { ModalContext } from '@alfalab/core-components/modal/shared';
```

Импорт Modal - респонсивный компаунд

## Использование контекста

Компонент модального окна предоставляет доступ к контексту, что позволяет гибко настраивать и расширять компонент, а также упрощает использование.
Expand Down Expand Up @@ -48,8 +43,8 @@ export type ModalContext = {

## Использование dataTestId

В компоненте используются модификаторы для `dataTestId`.
Для удобного поиска элементов можно воспользоваться функцией `getModalTestIds`.
В компоненте используются модификаторы для `dataTestId`.
Для удобного поиска элементов можно воспользоваться функцией `getModalTestIds`.
Импорт из `@alfalab/core-components/modal/shared`.

Функция возвращает объект:
Expand Down
4 changes: 1 addition & 3 deletions packages/modal/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export * from './desktop';
export * from './mobile';
export { ModalResponsive as Modal } from './Component.responsive';
export { type ModalResponsiveProps as ModalProps } from './typings';
export { ModalResponsiveProps as ModalProps } from './typings';
12 changes: 1 addition & 11 deletions packages/modal/src/mobile/Component.mobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,9 @@ const ModalMobileComponent = forwardRef<HTMLDivElement, ModalMobileProps>((props
<Modal {...props} ref={ref} view='mobile' />
));

const ControlsMobile = Controls as React.FC<Omit<ControlsProps, 'mobileLayout'>>;

export const ModalMobile = Object.assign(ModalMobileComponent, {
Content,
Header,
Footer,
Controls: ControlsMobile,
Controls: Controls as React.FC<Omit<ControlsProps, 'mobileLayout'>>,
});

export {
ModalMobileComponent as ModalComponentMobile,
Content as ContentMobile,
Header as HeaderMobile,
Footer as FooterMobile,
ControlsMobile,
};
2 changes: 1 addition & 1 deletion packages/modal/src/mobile/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './Component.mobile';
export { type ModalMobileProps } from '../typings';
export { ModalMobileProps } from '../typings';

0 comments on commit e840ca3

Please sign in to comment.