Skip to content

Commit f9108d9

Browse files
committed
feat(Modal): add full-view size for Modal
1 parent 8ae3eeb commit f9108d9

File tree

6 files changed

+61
-14
lines changed

6 files changed

+61
-14
lines changed

packages/core/src/components/Modal/Modal/Modal.module.scss

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
$full-view-margin: 40px;
2+
13
.container {
24
position: fixed;
35
inset: 0;
@@ -12,7 +14,8 @@
1214
}
1315

1416
.modal {
15-
--top-actions-spacing: var(--spacing-large);
17+
--top-actions-margin-inline: var(--spacing-large);
18+
--top-actions-margin-block: var(--spacing-large);
1619
--top-actions-width: var(--spacing-xl);
1720
--modal-inline-padding: var(--spacing-xl);
1821

@@ -28,6 +31,7 @@
2831
overflow: hidden;
2932
border-radius: var(--border-radius-big);
3033
box-shadow: var(--box-shadow-large);
34+
outline: none;
3135

3236
&.withHeaderAction {
3337
--top-actions-width: calc(var(--spacing-xl) * 2);
@@ -47,4 +51,20 @@
4751
--modal-max-height: 80%;
4852
--modal-width: 840px;
4953
}
54+
55+
&.sizeFullView {
56+
--top-actions-margin-inline: var(--spacing-xl);
57+
--modal-max-height: 100%;
58+
--modal-width: auto;
59+
60+
position: fixed;
61+
inset: 0;
62+
height: calc(100% - $full-view-margin);
63+
64+
margin-inline: $full-view-margin;
65+
margin-block-start: $full-view-margin;
66+
67+
border-end-start-radius: unset;
68+
border-end-end-radius: unset;
69+
}
5070
}

packages/core/src/components/Modal/Modal/Modal.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { keyCodes } from "../../../constants";
1616
import {
1717
modalAnimationAnchorPopVariants,
1818
modalAnimationCenterPopVariants,
19+
modalAnimationFullViewVariants,
1920
modalAnimationOverlayVariants
2021
} from "../utils/animationVariants";
2122
import { createPortal } from "react-dom";
@@ -98,9 +99,12 @@ const Modal = forwardRef(
9899
[alertModal, onClose, show]
99100
);
100101

101-
const modalAnimationVariants = anchorElementRef?.current
102-
? modalAnimationAnchorPopVariants
103-
: modalAnimationCenterPopVariants;
102+
const modalAnimationVariants =
103+
size === "full-view"
104+
? modalAnimationFullViewVariants
105+
: anchorElementRef?.current
106+
? modalAnimationAnchorPopVariants
107+
: modalAnimationCenterPopVariants;
104108

105109
const zIndexStyle = zIndex ? ({ "--monday-modal-z-index": zIndex } as React.CSSProperties) : {};
106110

packages/core/src/components/Modal/Modal/Modal.types.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from "react";
33
import { ModalTopActionsProps } from "../ModalTopActions/ModalTopActions.types";
44
import { PortalTarget } from "../hooks/usePortalTarget/usePortalTarget.types";
55

6-
export type ModalSize = "small" | "medium" | "large";
6+
export type ModalSize = "small" | "medium" | "large" | "full-view";
77

88
export type ModalCloseEvent =
99
| React.MouseEvent<HTMLDivElement | HTMLButtonElement>

packages/core/src/components/Modal/ModalTopActions/ModalTopActions.module.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
display: flex;
33
align-items: center;
44
position: absolute;
5-
right: var(--top-actions-spacing);
6-
top: var(--top-actions-spacing);
5+
right: var(--top-actions-margin-inline);
6+
top: var(--top-actions-margin-block);
77
}

packages/core/src/components/Modal/layouts/ModalBasicLayout/ModalBasicLayout.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
.header {
77
width: 100%;
88
margin-block: var(--spacing-xl) var(--spacing-large);
9-
padding-inline-end: calc(var(--top-actions-spacing) + var(--top-actions-width) + var(--spacing-medium));
9+
padding-inline-end: calc(var(--top-actions-margin-inline) + var(--top-actions-width) + var(--spacing-medium));
1010
padding-inline-start: var(--modal-inline-padding);
1111
}
1212

packages/core/src/components/Modal/utils/animationVariants.ts

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { Variants } from "framer-motion";
22
import { RefObject } from "react";
33

4+
const enterEase = [0.0, 0.0, 0.4, 1.0];
5+
const exitEase = [0.6, 0.0, 1.0, 1.0];
6+
47
export const modalAnimationOverlayVariants: Variants = {
58
initial: {
69
opacity: 0
@@ -9,14 +12,14 @@ export const modalAnimationOverlayVariants: Variants = {
912
opacity: 0.7,
1013
transition: {
1114
duration: 0.1,
12-
ease: [0.0, 0.0, 0.4, 1.0]
15+
ease: enterEase
1316
}
1417
},
1518
exit: {
1619
opacity: 0,
1720
transition: {
1821
duration: 0.1,
19-
ease: [0.6, 0.0, 1.0, 1.0]
22+
ease: exitEase
2023
}
2124
}
2225
};
@@ -35,7 +38,7 @@ export const modalAnimationCenterPopVariants: Variants = {
3538
y: "-50%",
3639
transition: {
3740
duration: 0.15,
38-
ease: [0.0, 0.0, 0.4, 1.0],
41+
ease: enterEase,
3942
times: [0, 0.5, 1]
4043
}
4144
},
@@ -46,7 +49,7 @@ export const modalAnimationCenterPopVariants: Variants = {
4649
y: "-50%",
4750
transition: {
4851
duration: 0.1,
49-
ease: [0.6, 0.0, 1.0, 1.0],
52+
ease: exitEase,
5053
times: [0, 0.5, 1]
5154
}
5255
}
@@ -79,7 +82,7 @@ export const modalAnimationAnchorPopVariants: Variants = {
7982
y: "-50%",
8083
transition: {
8184
duration: 0.2,
82-
ease: [0.0, 0.0, 0.4, 1.0],
85+
ease: enterEase,
8386
times: [0, 0.4, 1]
8487
}
8588
},
@@ -100,9 +103,29 @@ export const modalAnimationAnchorPopVariants: Variants = {
100103
y,
101104
transition: {
102105
duration: 0.15,
103-
ease: [0.6, 0.0, 1.0, 1.0],
106+
ease: exitEase,
104107
times: [0, 0.6, 1]
105108
}
106109
};
107110
}
108111
};
112+
113+
export const modalAnimationFullViewVariants: Variants = {
114+
enter: {
115+
opacity: [0.3, 1, 1],
116+
y: [24, 24, 0],
117+
transition: {
118+
duration: 0.2,
119+
ease: enterEase,
120+
times: [0, 0.33, 1]
121+
}
122+
},
123+
exit: {
124+
opacity: 0,
125+
y: 24,
126+
transition: {
127+
duration: 0.1,
128+
ease: exitEase
129+
}
130+
}
131+
};

0 commit comments

Comments
 (0)