Skip to content

Commit 79c4e7c

Browse files
feat: add size prop to modal component
1 parent 656b54f commit 79c4e7c

2 files changed

Lines changed: 28 additions & 10 deletions

File tree

packages/ui/src/Modal/index.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,29 @@ interface ModalProperties {
77
className?: string;
88
footer?: React.ReactNode;
99
header?: string | JSX.Element;
10-
visible: boolean;
1110
onHide: () => void;
11+
size?: "medium" | "large";
12+
visible: boolean;
1213
}
1314

1415
const Modal: React.FC<ModalProperties> = ({
1516
children,
1617
className = "",
1718
footer,
1819
header,
19-
visible = false,
2020
onHide,
21+
size = "medium",
22+
visible = false,
2123
}) => {
22-
if (!visible) return null;
24+
if (!visible) {
25+
return null;
26+
}
27+
28+
const modalClassName = ["dz-modal", className, size].join(" ");
2329

2430
return (
2531
<div role="dialog" className="dz-modal-overlay">
26-
<div className={`dz-modal ${className}`.trim()}>
32+
<div className={modalClassName}>
2733
<div className="dz-modal-header">
2834
{typeof header === "string" ? (
2935
<span role="heading">{header}</span>

packages/ui/src/assets/css/modal.css

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313

1414
.dz-modal {
1515
background-color: #fff;
16-
padding: 1rem;
17-
z-index: 1000;
18-
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
1916
border-radius: 5px;
20-
min-width: 300px;
21-
max-width: 80%;
17+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
18+
color: var(--color);
2219
max-height: 80%;
20+
min-width: 300px;
2321
overflow-y: auto;
24-
color: var(--color);
22+
padding: 1rem;
23+
width: calc(100% - 2rem);
24+
z-index: 1000;
2525
}
2626

2727
.dz-modal .dz-modal-header {
@@ -53,3 +53,15 @@
5353
padding: 0.75rem;
5454
margin-left: auto;
5555
}
56+
57+
@media screen and (min-width: 576px) {
58+
.dz-modal {
59+
max-width: 35rem;
60+
min-width: 25rem;
61+
width: auto;
62+
}
63+
64+
.dz-modal.large {
65+
max-width: 56.25rem;
66+
}
67+
}

0 commit comments

Comments
 (0)