Skip to content

Commit 244c1cb

Browse files
authored
feat(Modal): export new Modal component to /next (#2641)
1 parent a787e27 commit 244c1cb

File tree

102 files changed

+127
-43
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+127
-43
lines changed

packages/core/.storybook/manager.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ addons.setConfig({
1616
const [statusMatch, statusType] = statusRegex.exec(name) || [];
1717

1818
if (statusMatch) {
19-
return <SidebarItem status={statusType}>{name.replace(statusMatch, "").trim()}</SidebarItem>;
19+
return <SidebarItem status={statusType.toLowerCase()}>{name.replace(statusMatch, "").trim()}</SidebarItem>;
2020
}
2121

2222
const { status: storyStatus } = parameters;

packages/core/src/__tests__/__snapshots__/exports.test.ts.snap

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,16 @@ exports[`exports should export all components 1`] = `
110110
]
111111
`;
112112

113-
exports[`exports should export next all components 1`] = `[]`;
113+
exports[`exports should export next all components 1`] = `
114+
[
115+
"Modal",
116+
"ModalBasicLayout",
117+
"ModalContent",
118+
"ModalFooter",
119+
"ModalFooterWizard",
120+
"ModalHeader",
121+
"ModalMedia",
122+
"ModalMediaLayout",
123+
"ModalSideBySideLayout",
124+
]
125+
`;

packages/core/src/components/LegacyModal/__stories__/LegacyModal.mdx

Lines changed: 3 additions & 4 deletions

packages/core/src/components/LegacyModal/__stories__/LegacyModal.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const modalTemplate = ({ onClose, ...modalProps }: ModalProps) => {
5353
};
5454

5555
export default {
56-
title: "Components/Modal",
56+
title: "Components/Modal [Deprecated]",
5757
component: Modal,
5858
subcomponents: {
5959
ModalHeader,

packages/core/src/components/ModalNew/Modal/Modal.module.scss renamed to packages/core/src/components/Modal/Modal/Modal.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
--monday-modal-z-index: 10000;
33
position: fixed;
44
inset: 0;
5-
background-color: rgba(41, 47, 76, 0.7);
5+
background-color: var(--color-surface);
66
z-index: var(--monday-modal-z-index);
77
}
88

packages/core/src/components/ModalNew/Modal/Modal.tsx renamed to packages/core/src/components/Modal/Modal/Modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const Modal = forwardRef(
9898
<motion.div
9999
ref={overlayRef}
100100
variants={modalAnimationOverlayVariants}
101-
initial={false}
101+
initial="initial"
102102
animate="enter"
103103
exit="exit"
104104
data-testid={getTestId(ComponentDefaultTestId.MODAL_NEXT_OVERLAY, id)}

packages/core/src/components/ModalNew/Modal/__stories__/Modal.mdx renamed to packages/core/src/components/Modal/Modal/__stories__/Modal.mdx

Lines changed: 1 addition & 1 deletion

packages/core/src/components/ModalNew/Modal/__stories__/Modal.stories.helpers.tsx renamed to packages/core/src/components/Modal/Modal/__stories__/Modal.stories.helpers.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { StorybookLink, Tip } from "vibe-storybook-components";
44
import { useAfterFirstRender } from "../../../../hooks";
55
import cx from "classnames";
66
import styles from "./Modal.stories.module.scss";
7-
import { createPortal } from "react-dom";
87
import { getStyle } from "../../../../helpers/typesciptCssModulesHelper";
98

109
export const OpenedModalPreview = forwardRef(
@@ -25,14 +24,14 @@ export const OpenedModalPreview = forwardRef(
2524
const isAfterFirstRender = useAfterFirstRender();
2625
return (
2726
<div
28-
className={cx(styles.preview, getStyle(styles, size))}
27+
className={cx(styles.preview, { [getStyle(styles, size)]: isDocsView })}
2928
ref={ref}
3029
// workaround to prevent modal from autofocusing on page load
3130
// autofocus would work as expected when modal closes and reopens
3231
{...(!isAfterFirstRender.current && isDocsView && { "data-no-autofocus": true })}
3332
>
3433
<Button onClick={onOpenModalClick}>Open Modal</Button>
35-
{isDocsView ? modal : createPortal(modal, document.body)}
34+
{modal}
3635
</div>
3736
);
3837
}

packages/core/src/components/ModalNew/Modal/__stories__/Modal.stories.module.scss renamed to packages/core/src/components/Modal/Modal/__stories__/Modal.stories.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
.preview {
88
padding-inline-start: 32px;
99
padding-block-start: 40px;
10-
height: 360px;
10+
height: 100vh;
1111
width: 100%;
1212
container-type: inline-size;
1313

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default as Modal } from "./Modal";
2+
export { ModalProps } from "./Modal.types";
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default as ModalContent } from "./ModalContent";
2+
export { ModalContentProps } from "./ModalContent.types";
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default as ModalHeader } from "./ModalHeader";
2+
export { ModalHeaderProps } from "./ModalHeader.types";
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default as ModalMedia } from "./ModalMedia";
2+
export { ModalMediaProps } from "./ModalMedia.types";
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export { default as ModalFooter } from "./ModalFooter/ModalFooter";
2+
export { ModalFooterProps } from "./ModalFooter/ModalFooter.types";
3+
4+
export { default as ModalFooterWizard } from "./ModalFooterWizard/ModalFooterWizard";
5+
export { ModalFooterWizardProps } from "./ModalFooterWizard/ModalFooterWizard.types";
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export * from "./footers";
2+
export * from "./layouts";
3+
export * from "./Modal";
4+
export * from "./ModalHeader";
5+
export * from "./ModalContent";
6+
export * from "./ModalMedia";
Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ const metaSettings = createStoryMetaSettingsDecorator({
2525
});
2626

2727
export default {
28-
title: "Internal/Components/Modal [New]/Basic modal",
28+
title: "Components/Modal [New]/Basic modal",
2929
component: Modal,
3030
subcomponents: { ModalBasicLayout, ModalHeader, ModalContent, ModalFooter, ModalFooterWizard, TransitionView },
3131
argTypes: metaSettings.argTypes,
3232
decorators: metaSettings.decorators,
33-
tags: ["internal"]
33+
parameters: {
34+
layout: "fullscreen"
35+
}
3436
} satisfies Meta<typeof Modal>;
3537

3638
export const Overview: Story = {
@@ -165,7 +167,9 @@ export const AlertModal: Story = {
165167
<ModalBasicLayout>
166168
<ModalHeader title="Alert modal" />
167169
<ModalContent>
168-
This will allow closing the modal only by the close buttons and not by ESC or by clicking outside.
170+
<Text type="text1" align="inherit" element="p">
171+
This will allow closing the modal only by the close buttons and not by ESC or by clicking outside.
172+
</Text>
169173
</ModalContent>
170174
</ModalBasicLayout>
171175
<ModalFooter
@@ -181,7 +185,14 @@ export const Scroll: Story = {
181185
decorators: [(Story, context) => withOpenedModalPreview(Story, { isDocsView: context.viewMode === "docs" })],
182186
render: (_, { show, setShow, container }) => {
183187
return (
184-
<Modal id="modal-basic" show={show} size="medium" onClose={() => setShow(false)} container={container}>
188+
<Modal
189+
id="modal-basic"
190+
show={show}
191+
size="medium"
192+
onClose={() => setShow(false)}
193+
container={container}
194+
style={{ height: 400 }}
195+
>
185196
<ModalBasicLayout>
186197
<ModalHeader title="Scrollable modal" />
187198
<ModalContent>
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Modal from "../../../Modal/Modal";
44
import { createStoryMetaSettingsDecorator } from "../../../../../storybook";
55
import ModalHeader from "../../../ModalHeader/ModalHeader";
66
import ModalContent from "../../../ModalContent/ModalContent";
7-
import ModalMedia from "../../ModalMedia";
7+
import ModalMedia from "../../../ModalMedia/ModalMedia";
88
import mediaImage from "./assets/media-image.png";
99
import ModalFooter from "../../../footers/ModalFooter/ModalFooter";
1010
import ModalMediaLayout from "../ModalMediaLayout";
@@ -26,7 +26,7 @@ const metaSettings = createStoryMetaSettingsDecorator({
2626
});
2727

2828
export default {
29-
title: "Internal/Components/Modal [New]/Media modal",
29+
title: "Components/Modal [New]/Media modal",
3030
component: Modal,
3131
subcomponents: {
3232
ModalMediaLayout,
@@ -39,7 +39,9 @@ export default {
3939
},
4040
argTypes: metaSettings.argTypes,
4141
decorators: metaSettings.decorators,
42-
tags: ["internal"]
42+
parameters: {
43+
layout: "fullscreen"
44+
}
4345
} satisfies Meta<typeof Modal>;
4446

4547
export const Overview: Story = {
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { withOpenedModalPreview } from "../../../Modal/__stories__/Modal.stories
66
import ModalHeader from "../../../ModalHeader/ModalHeader";
77
import ModalContent from "../../../ModalContent/ModalContent";
88
import ModalSideBySideLayout from "../ModalSideBySideLayout";
9-
import ModalMedia from "../../ModalMedia";
9+
import ModalMedia from "../../../ModalMedia/ModalMedia";
1010
import mediaImage from "./assets/media-image.png";
1111
import useWizard from "../../../../../hooks/useWizard/useWizard";
1212
import TransitionView from "../../../../TransitionView/TransitionView";
@@ -29,7 +29,7 @@ const metaSettings = createStoryMetaSettingsDecorator({
2929
});
3030

3131
export default {
32-
title: "Internal/Components/Modal [New]/Side by side modal",
32+
title: "Components/Modal [New]/Side by side modal",
3333
component: Modal,
3434
subcomponents: {
3535
ModalSideBySideLayout,
@@ -42,7 +42,9 @@ export default {
4242
},
4343
argTypes: metaSettings.argTypes,
4444
decorators: metaSettings.decorators,
45-
tags: ["internal"]
45+
parameters: {
46+
layout: "fullscreen"
47+
}
4648
} satisfies Meta<typeof Modal>;
4749

4850
export const Overview: Story = {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export { default as ModalBasicLayout } from "./ModalBasicLayout/ModalBasicLayout";
2+
export { ModalBasicLayoutProps } from "./ModalBasicLayout/ModalBasicLayout.types";
3+
4+
export { default as ModalMediaLayout } from "./ModalMediaLayout/ModalMediaLayout";
5+
export { ModalMediaLayoutProps } from "./ModalMediaLayout/ModalMediaLayout.types";
6+
7+
export { default as ModalSideBySideLayout } from "./ModalSideBySideLayout/ModalSideBySideLayout";
8+
export { ModalSideBySideLayoutProps } from "./ModalSideBySideLayout/ModalSideBySideLayout.types";

packages/core/src/components/ModalNew/utils/animationVariants.ts renamed to packages/core/src/components/Modal/utils/animationVariants.ts

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,35 @@ import { Variants } from "framer-motion";
22
import { RefObject } from "react";
33

44
export const modalAnimationOverlayVariants: Variants = {
5+
initial: {
6+
opacity: 0
7+
},
58
enter: {
6-
opacity: 1,
9+
opacity: 0.7,
710
transition: {
8-
duration: 0.2,
11+
duration: 0.1,
912
ease: [0.0, 0.0, 0.4, 1.0]
1013
}
1114
},
1215
exit: {
1316
opacity: 0,
1417
transition: {
15-
duration: 0.15,
16-
ease: [0.0, 0.0, 0.4, 1.0]
18+
duration: 0.1,
19+
ease: [0.6, 0.0, 1.0, 1.0]
1720
}
1821
}
1922
};
2023

2124
export const modalAnimationCenterPopVariants: Variants = {
25+
initial: {
26+
opacity: 1,
27+
scale: 1,
28+
x: "-50%",
29+
y: "-50%"
30+
},
2231
enter: {
2332
opacity: [0, 1, 1],
24-
scale: [0.65, 1, 1],
33+
scale: [0.8, 1, 1],
2534
x: "-50%",
2635
y: "-50%",
2736
transition: {
@@ -32,30 +41,46 @@ export const modalAnimationCenterPopVariants: Variants = {
3241
},
3342
exit: {
3443
opacity: [1, 1, 0],
35-
scale: [1, 1, 0.65],
44+
scale: [1, 1, 0.8],
3645
x: "-50%",
3746
y: "-50%",
3847
transition: {
3948
duration: 0.1,
40-
ease: [0.0, 0.0, 0.4, 1.0],
49+
ease: [0.6, 0.0, 1.0, 1.0],
4150
times: [0, 0.5, 1]
4251
}
4352
}
4453
};
4554

4655
export const modalAnimationAnchorPopVariants: Variants = {
56+
initial: (anchorElementRef: RefObject<HTMLElement>) => {
57+
const anchorRect = anchorElementRef.current.getBoundingClientRect();
58+
const anchorCenterX = anchorRect.left + anchorRect.width / 2;
59+
const anchorCenterY = anchorRect.top + anchorRect.height / 2;
60+
61+
const x = `calc(-50% + ${anchorCenterX}px)`;
62+
const y = `calc(-50% + ${anchorCenterY}px)`;
63+
64+
return {
65+
opacity: 0,
66+
scale: 0.8,
67+
top: "50%",
68+
left: "50%",
69+
x,
70+
y
71+
};
72+
},
4773
enter: {
48-
opacity: [0, 1, 1],
49-
scale: [0.65, 0.65, 1],
74+
opacity: [0, 0, 1],
75+
scale: [0.8, 0.8, 1],
5076
top: "50%",
5177
left: "50%",
5278
x: "-50%",
5379
y: "-50%",
5480
transition: {
55-
delay: 0.05,
5681
duration: 0.2,
5782
ease: [0.0, 0.0, 0.4, 1.0],
58-
times: [0, 0.2, 1]
83+
times: [0, 0.4, 1]
5984
}
6085
},
6186
exit: (anchorElementRef: RefObject<HTMLElement>) => {
@@ -67,16 +92,16 @@ export const modalAnimationAnchorPopVariants: Variants = {
6792
const y = `calc(-50% + ${anchorCenterY}px)`;
6893

6994
return {
70-
opacity: [1, 1, 0],
71-
scale: [1, 1, 0.75],
95+
opacity: [1, 0, 0],
96+
scale: [1, 0.8, 0.8],
7297
top: 0,
7398
left: 0,
7499
x,
75100
y,
76101
transition: {
77102
duration: 0.15,
78103
ease: [0.6, 0.0, 1.0, 1.0],
79-
times: [0, 0.33, 1]
104+
times: [0, 0.6, 1]
80105
}
81106
};
82107
}

packages/core/src/components/next.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export {};
1+
export * from "./Modal";

packages/core/src/storybook/components/related-components/component-description-map.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ import { BoxDescription } from "./descriptions/box-description";
5959
import { TableDescription } from "./descriptions/table-description";
6060
import { VirtualizedGridDescription } from "./descriptions/virtualized-grid-description/virtualized-grid-description";
6161
import { MenuGridItemDescription } from "./descriptions/menu-grid-item-description";
62-
import { ModalMediaLayoutRelatedComponent } from "../../../components/ModalNew/layouts/ModalMediaLayout/__stories__/ModalMediaLayoutRelatedComponent";
63-
import { ModalSideBySideLayoutRelatedComponent } from "../../../components/ModalNew/layouts/ModalSideBySideLayout/__stories__/ModalSideBySideLayoutRelatedComponent";
64-
import { ModalBasicLayoutRelatedComponent } from "../../../components/ModalNew/layouts/ModalBasicLayout/__stories__/ModalBasicLayoutRelatedComponent";
62+
import { ModalMediaLayoutRelatedComponent } from "../../../components/Modal/layouts/ModalMediaLayout/__stories__/ModalMediaLayoutRelatedComponent";
63+
import { ModalSideBySideLayoutRelatedComponent } from "../../../components/Modal/layouts/ModalSideBySideLayout/__stories__/ModalSideBySideLayoutRelatedComponent";
64+
import { ModalBasicLayoutRelatedComponent } from "../../../components/Modal/layouts/ModalBasicLayout/__stories__/ModalBasicLayoutRelatedComponent";
6565

6666
export const SPLIT_BUTTON = "split-button";
6767
export const BUTTON_GROUP = "button-group";

packages/storybook-blocks/src/components/status-tag/__stories__/status-tag.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const Types: Story = {
2121
<Flex direction={Flex.directions.COLUMN} gap={Flex.gaps.MEDIUM} align={Flex.align.START}>
2222
<StatusTag type="alpha" />
2323
<StatusTag type="beta" />
24+
<StatusTag type="new" />
2425
<StatusTag type="deprecated" />
2526
</Flex>
2627
),

0 commit comments

Comments
 (0)