Skip to content

Commit

Permalink
feat(modal): add atoms imports (#1474)
Browse files Browse the repository at this point in the history
* feat: add atoms imports;

* feat(modal): add atom imports;
  • Loading branch information
denisx authored Dec 25, 2024
1 parent 60ed327 commit 0e231f6
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-drinks-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@alfalab/core-components-modal': minor
---

Добавлены атомарные импорты
8 changes: 8 additions & 0 deletions packages/modal/src/Component.responsive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,11 @@ 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: 13 additions & 2 deletions packages/modal/src/desktop/Component.desktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,20 @@ 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: Header as React.FC<Omit<HeaderProps, 'titleSize' | 'subtitle'>>,
Header: HeaderDesktop,
Footer,
Controls: Controls as React.FC<Omit<ControlsProps, 'mobileLayout'>>,
Controls: ControlsDesktop,
});

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 { ModalDesktopProps } from '../typings';
export { type ModalDesktopProps } from '../typings';
2 changes: 2 additions & 0 deletions packages/modal/src/docs/description.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Modal построен как Compound Components. Состоит из Header, C
Чтобы во время скролла заголовок и кнопки оставались неподвижны, их нужно расположить в `header` и `footer`.
Текст и изображения всегда располагаются в `content` части.

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

```jsx live mobileHeight={640}
const Header = () => {
const { setHasHeader } = React.useContext(ModalContext);
Expand Down
14 changes: 12 additions & 2 deletions packages/modal/src/docs/development.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,23 @@ import vars from '!!raw-loader!../vars.css';
## Подключение

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

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

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

```

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

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

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

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

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

Функция возвращает объект:
Expand Down
2 changes: 1 addition & 1 deletion packages/modal/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { ModalResponsive as Modal } from './Component.responsive';
export { ModalResponsiveProps as ModalProps } from './typings';
export { type ModalResponsiveProps as ModalProps } from './typings';
12 changes: 11 additions & 1 deletion packages/modal/src/mobile/Component.mobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,19 @@ 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: Controls as React.FC<Omit<ControlsProps, 'mobileLayout'>>,
Controls: ControlsMobile,
});

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 { ModalMobileProps } from '../typings';
export { type ModalMobileProps } from '../typings';

0 comments on commit 0e231f6

Please sign in to comment.