Skip to content

Commit

Permalink
chore(new-hope): CSF 3 for Modal
Browse files Browse the repository at this point in the history
  • Loading branch information
kayman233 committed Nov 15, 2023
1 parent 476f170 commit e8e0e6e
Show file tree
Hide file tree
Showing 17 changed files with 167 additions and 80 deletions.
8 changes: 2 additions & 6 deletions packages/plasma-b2c/api/plasma-b2c.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ import { MediaQueryFunction } from '@salutejs/plasma-hope';
import { Modal } from '@salutejs/plasma-hope';
import { modalClasses as modalBaseClasses } from '@salutejs/plasma-new-hope/styled-components';
import { ModalProps as ModalBaseProps } from '@salutejs/plasma-new-hope/styled-components';
import { modalTokens as modalBaseTokens } from '@salutejs/plasma-new-hope/styled-components';
import { ModalProps } from '@salutejs/plasma-hope';
import { ModalsProvider } from '@salutejs/plasma-hope';
import { ModalView } from '@salutejs/plasma-hope';
Expand Down Expand Up @@ -177,7 +176,6 @@ import { PopupProps as PopupBaseProps } from '@salutejs/plasma-new-hope/styled-c
import { PopupProvider as PopupBaseProvider } from '@salutejs/plasma-new-hope/styled-components';
import { PopupInfo } from '@salutejs/plasma-new-hope/styled-components';
import { PopupProps } from '@salutejs/plasma-hope';
import { PopupProps as PopupProps_2 } from '@salutejs/plasma-new-hope';
import { PreviewGallery } from '@salutejs/plasma-hope';
import { PreviewGalleryItemProps } from '@salutejs/plasma-hope';
import { PreviewGalleryProps } from '@salutejs/plasma-hope';
Expand Down Expand Up @@ -597,14 +595,12 @@ export { MediaQueryFunction }
export { Modal }

// @public
export const ModalBase: React_2.ForwardRefExoticComponent<ModalBaseProps & React_2.RefAttributes<HTMLDivElement>>;
export const ModalBase: ForwardRefExoticComponent<ModalBaseProps & RefAttributes<HTMLDivElement>>;

export { modalBaseClasses }

export { ModalBaseProps }

export { modalBaseTokens }

export { ModalProps }

export { ModalsProvider }
Expand Down Expand Up @@ -659,7 +655,7 @@ export { PopoverTrigger }
export { Popup }

// @public
export const PopupBase: FunctionComponent<PropsType<Record<string, Variant>> & PopupProps_2 & RefAttributes<HTMLDivElement>>;
export const PopupBase: ForwardRefExoticComponent<PopupBaseProps & RefAttributes<HTMLDivElement>>;

export { popupBaseClasses }

Expand Down
8 changes: 3 additions & 5 deletions packages/plasma-b2c/src/components/ModalBase/Modal.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { css } from '@salutejs/plasma-new-hope/styled-components';

import { modalBaseTokens } from '.';
import { css, modalTokens } from '@salutejs/plasma-new-hope/styled-components';

export const config = {
defaults: {
Expand All @@ -9,8 +7,8 @@ export const config = {
variations: {
view: {
default: css`
${modalBaseTokens.modalOverlayWithBlurColor}: rgba(35, 35, 35, 0.2);
${modalBaseTokens.modalOverlayColor}: rgba(8, 8, 8, 0.56);
${modalTokens.modalOverlayWithBlurColor}: rgba(35, 35, 35, 0.2);
${modalTokens.modalOverlayColor}: var(--overlay-soft);
`,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/plasma-b2c/src/components/ModalBase/ModalBase.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ForwardRefExoticComponent, RefAttributes } from 'react';
import { modalConfig, component, mergeConfig } from '@salutejs/plasma-new-hope/styled-components';
import type { ForwardRefExoticComponent, RefAttributes } from 'react';

import { config } from './Modal.config';

Expand Down
5 changes: 1 addition & 4 deletions packages/plasma-b2c/src/components/ModalBase/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
export { ModalBase } from './ModalBase';
export {
modalClasses as modalBaseClasses,
modalTokens as modalBaseTokens,
} from '@salutejs/plasma-new-hope/styled-components';
export { modalClasses as modalBaseClasses } from '@salutejs/plasma-new-hope/styled-components';

export type { ModalProps as ModalBaseProps } from '@salutejs/plasma-new-hope/styled-components';
2 changes: 1 addition & 1 deletion packages/plasma-b2c/src/components/PopupBase/PopupBase.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { popupConfig, component, mergeConfig } from '@salutejs/plasma-new-hope/styled-components';
import { ForwardRefExoticComponent, RefAttributes } from 'react';
import type { ForwardRefExoticComponent, RefAttributes } from 'react';

import { PopupBaseProps } from '.';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { styled } from '@linaria/react';

import { DEFAULT_Z_INDEX } from '../../Popup/utils';
import { tokens } from '../Modal/Modal.tokens';
import { tokens } from '../Modal.tokens';

// TODO: новый отдельный оверлей #778
export const Overlay = styled.div<{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { FC, useCallback, useMemo } from 'react';
import { usePopupContext } from '../../Popup';
import { getIdLastModal } from '../Modal/ModalContext';
import { ModalOverlayProps } from '../Modal/Modal.types';
import { classes } from '../Modal/Modal.tokens';
import { classes } from '../Modal.tokens';

import { Overlay } from './ModalOverlay.styles';

Expand Down
3 changes: 2 additions & 1 deletion packages/plasma-new-hope/src/components/Modal/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { modalConfig, modalRoot } from './Modal/Modal';
export { classes as modalClasses, tokens as modalTokens } from './Modal/Modal.tokens';
export { classes as modalClasses, tokens as modalTokens } from './Modal.tokens';
export type { ModalProps, ModalOverlayProps } from './Modal/Modal.types';
1 change: 1 addition & 0 deletions packages/plasma-new-hope/src/components/Popup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export { PopupProvider, usePopupContext } from './PopupContext';
export { popupRoot, popupConfig } from './Popup';
export { usePopup } from './hooks';
export { classes as popupClasses } from './Popup.tokens';
export type { PopupPlacement, PopupInfo, PopupProps } from './Popup.types';
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useEffect } from 'react';
import React, { useState } from 'react';
import { styled } from '@linaria/react';
import { Story, Meta } from '@storybook/react';
import type { ComponentProps } from 'react';
import type { StoryObj, Meta } from '@storybook/react';
import { SSRProvider } from '@salutejs/plasma-core';

import { PopupProvider, popupClasses } from '../Popup/Popup';
Expand Down Expand Up @@ -28,11 +29,42 @@ export default {
control: {
type: 'select',
},
table: { defaultValue: { summary: 'center' } },
},
offsetX: {
control: {
type: 'number',
},
table: { defaultValue: { summary: 0 } },
},
offsetY: {
control: {
type: 'number',
},
table: { defaultValue: { summary: 0 } },
},
closeOnEsc: {
control: {
type: 'boolean',
},
table: { defaultValue: { summary: true } },
},
closeOnOverlayClick: {
control: {
type: 'boolean',
},
table: { defaultValue: { summary: true } },
},
withBlur: {
control: {
type: 'boolean',
},
table: { defaultValue: { summary: false } },
},
},
} as Meta;

type ModalStoryProps = {
type StoryModalProps = ComponentProps<typeof Modal> & {
placement: string;
offsetX: number;
offsetY: number;
Expand Down Expand Up @@ -89,10 +121,10 @@ const StyledModal = styled(Modal)`
}
`;

export const ModalDemo: Story<ModalStoryProps> = ({ placement, offsetX, offsetY, ...rest }) => {
const [isOpenA, setIsOpenA] = React.useState(false);
const [isOpenB, setIsOpenB] = React.useState(false);
const [isOpenC, setIsOpenC] = React.useState(false);
const StoryModalDemo = ({ placement, offsetX, offsetY, ...rest }: StoryModalProps) => {
const [isOpenA, setIsOpenA] = useState(false);
const [isOpenB, setIsOpenB] = useState(false);
const [isOpenC, setIsOpenC] = useState(false);

return (
<SSRProvider>
Expand Down Expand Up @@ -158,11 +190,14 @@ export const ModalDemo: Story<ModalStoryProps> = ({ placement, offsetX, offsetY,
);
};

ModalDemo.args = {
placement: 'center',
withBlur: false,
closeOnEsc: true,
closeOnOverlayClick: true,
offsetX: 0,
offsetY: 0,
export const ModalDemo: StoryObj<StoryModalProps> = {
args: {
placement: 'center',
withBlur: false,
closeOnEsc: true,
closeOnOverlayClick: true,
offsetX: 0,
offsetY: 0,
},
render: (args) => <StoryModalDemo {...args} />,
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import React, { useState } from 'react';
import { styled } from '@linaria/react';
import { Story, Meta } from '@storybook/react';
import type { ComponentProps } from 'react';
import type { StoryObj, Meta } from '@storybook/react';
import { SSRProvider } from '@salutejs/plasma-core';

import { PopupProvider, popupClasses } from '../Popup/Popup';
Expand Down Expand Up @@ -28,11 +29,42 @@ export default {
control: {
type: 'select',
},
table: { defaultValue: { summary: 'center' } },
},
offsetX: {
control: {
type: 'number',
},
table: { defaultValue: { summary: 0 } },
},
offsetY: {
control: {
type: 'number',
},
table: { defaultValue: { summary: 0 } },
},
closeOnEsc: {
control: {
type: 'boolean',
},
table: { defaultValue: { summary: true } },
},
closeOnOverlayClick: {
control: {
type: 'boolean',
},
table: { defaultValue: { summary: true } },
},
withBlur: {
control: {
type: 'boolean',
},
table: { defaultValue: { summary: false } },
},
},
} as Meta;

type ModalStoryProps = {
type StoryModalProps = ComponentProps<typeof Modal> & {
placement: string;
offsetX: number;
offsetY: number;
Expand Down Expand Up @@ -89,10 +121,10 @@ const StyledModal = styled(Modal)`
}
`;

export const ModalDemo: Story<ModalStoryProps> = ({ placement, offsetX, offsetY, ...rest }) => {
const [isOpenA, setIsOpenA] = React.useState(false);
const [isOpenB, setIsOpenB] = React.useState(false);
const [isOpenC, setIsOpenC] = React.useState(false);
const StoryModalDemo = ({ placement, offsetX, offsetY, ...rest }: StoryModalProps) => {
const [isOpenA, setIsOpenA] = useState(false);
const [isOpenB, setIsOpenB] = useState(false);
const [isOpenC, setIsOpenC] = useState(false);

return (
<SSRProvider>
Expand Down Expand Up @@ -158,11 +190,14 @@ export const ModalDemo: Story<ModalStoryProps> = ({ placement, offsetX, offsetY,
);
};

ModalDemo.args = {
placement: 'center',
withBlur: false,
closeOnEsc: true,
closeOnOverlayClick: true,
offsetX: 0,
offsetY: 0,
export const ModalDemo: StoryObj<StoryModalProps> = {
args: {
placement: 'center',
withBlur: false,
closeOnEsc: true,
closeOnOverlayClick: true,
offsetX: 0,
offsetY: 0,
},
render: (args) => <StoryModalDemo {...args} />,
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import React, { useState } from 'react';
import { styled } from '@linaria/react';
import { Story, Meta } from '@storybook/react';
import type { ComponentProps } from 'react';
import type { StoryObj, Meta } from '@storybook/react';
import { SSRProvider } from '@salutejs/plasma-core';

import { PopupProvider, popupClasses } from '../Popup/Popup';
Expand Down Expand Up @@ -28,11 +29,42 @@ export default {
control: {
type: 'select',
},
table: { defaultValue: { summary: 'center' } },
},
offsetX: {
control: {
type: 'number',
},
table: { defaultValue: { summary: 0 } },
},
offsetY: {
control: {
type: 'number',
},
table: { defaultValue: { summary: 0 } },
},
closeOnEsc: {
control: {
type: 'boolean',
},
table: { defaultValue: { summary: true } },
},
closeOnOverlayClick: {
control: {
type: 'boolean',
},
table: { defaultValue: { summary: true } },
},
withBlur: {
control: {
type: 'boolean',
},
table: { defaultValue: { summary: false } },
},
},
} as Meta;

type ModalStoryProps = {
type StoryModalProps = ComponentProps<typeof Modal> & {
placement: string;
offsetX: number;
offsetY: number;
Expand Down Expand Up @@ -89,10 +121,10 @@ const StyledModal = styled(Modal)`
}
`;

export const ModalDemo: Story<ModalStoryProps> = ({ placement, offsetX, offsetY, ...rest }) => {
const [isOpenA, setIsOpenA] = React.useState(false);
const [isOpenB, setIsOpenB] = React.useState(false);
const [isOpenC, setIsOpenC] = React.useState(false);
const StoryModalDemo = ({ placement, offsetX, offsetY, ...rest }: StoryModalProps) => {
const [isOpenA, setIsOpenA] = useState(false);
const [isOpenB, setIsOpenB] = useState(false);
const [isOpenC, setIsOpenC] = useState(false);

return (
<SSRProvider>
Expand Down Expand Up @@ -158,11 +190,14 @@ export const ModalDemo: Story<ModalStoryProps> = ({ placement, offsetX, offsetY,
);
};

ModalDemo.args = {
placement: 'center',
withBlur: false,
closeOnEsc: true,
closeOnOverlayClick: true,
offsetX: 0,
offsetY: 0,
export const ModalDemo: StoryObj<StoryModalProps> = {
args: {
placement: 'center',
withBlur: false,
closeOnEsc: true,
closeOnOverlayClick: true,
offsetX: 0,
offsetY: 0,
},
render: (args) => <StoryModalDemo {...args} />,
};
4 changes: 1 addition & 3 deletions packages/plasma-new-hope/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export * from './components/Popover';
export * from './components/Tabs';
export * from './components/Calendar';
export * from './components/Typography';
export * from './mixins';
export * from './components/Popup';
export * from './components/Popup/Popup.types';
export * from './components/Modal';
export * from './components/Modal/Modal/Modal.types';
export * from './mixins';
Loading

0 comments on commit e8e0e6e

Please sign in to comment.