Skip to content

Commit 8570fbf

Browse files
committed
fix: add x-small size to modal
1 parent 7057e93 commit 8570fbf

File tree

2 files changed

+59
-2
lines changed

2 files changed

+59
-2
lines changed

packages/app-elements/src/ui/composite/Modal.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export type ModalProps = {
2727
/** Modal content */
2828
children: React.ReactNode
2929
/** Max width preset */
30-
size?: "large" | "small"
30+
size?: "large" | "small" | "x-small"
3131
}
3232

3333
export const Modal: React.FC<
@@ -98,6 +98,7 @@ export const Modal: React.FC<
9898
"fixed z-70 w-full top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",
9999
size === "large" && "max-w-155 md:w-155",
100100
size === "small" && "max-w-105 md:w-105",
101+
size === "x-small" && "max-w-80 md:w-80",
101102
)}
102103
data-testid="modal"
103104
>
@@ -138,7 +139,7 @@ Modal.Body = ({ children }) => {
138139

139140
Modal.Footer = ({ children }) => {
140141
return (
141-
<div className="flex-none px-6 py-4" data-testid="modal-footer">
142+
<div className="flex-none px-6 py-4 space-y-2" data-testid="modal-footer">
142143
{children}
143144
</div>
144145
)

packages/docs/src/stories/composite/Modal.stories.tsx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import {
88
import type { Meta, StoryFn } from "@storybook/react-vite"
99
import { useRef, useState } from "react"
1010
import { Button } from "#ui/atoms/Button"
11+
import { Icon } from "#ui/atoms/Icon"
12+
import { Spacer } from "#ui/atoms/Spacer"
13+
import { StatusIcon } from "#ui/atoms/StatusIcon"
14+
import { Text } from "#ui/atoms/Text"
1115
import { Modal } from "#ui/composite/Modal"
1216
import { InputSelect } from "#ui/forms/InputSelect"
1317

@@ -169,3 +173,55 @@ export const WithInput: StoryFn = () => {
169173
</div>
170174
)
171175
}
176+
177+
/**
178+
* Modal as dialog without header
179+
*/
180+
export const AsDialog: StoryFn = () => {
181+
const [show, setShow] = useState(false)
182+
183+
const handleClose = () => setShow(false)
184+
const handleShow = () => setShow(true)
185+
186+
return (
187+
<div>
188+
<Button onClick={handleShow}>Open modal</Button>
189+
<Modal show={show} onClose={handleClose} size="x-small">
190+
<Modal.Body>
191+
<Spacer top="4" bottom="4">
192+
<StatusIcon name="check" background="green" gap="x-large" />
193+
</Spacer>
194+
<Text weight="semibold" align="center" tag="div">
195+
Your coupons are ready.
196+
</Text>
197+
<Text align="center" tag="div" size="x-small" variant="info">
198+
Download now or find them later in Imports.
199+
</Text>
200+
</Modal.Body>
201+
<Modal.Footer>
202+
<Button
203+
variant="primary"
204+
onClick={() => {
205+
alert("Downloaded!")
206+
handleClose()
207+
}}
208+
fullWidth
209+
alignItems="center"
210+
>
211+
<Icon name="fileArrowDown" />
212+
Download (CSV)
213+
</Button>
214+
<Button
215+
variant="secondary"
216+
onClick={() => {
217+
handleClose()
218+
}}
219+
fullWidth
220+
>
221+
Cancel
222+
</Button>
223+
</Modal.Footer>
224+
</Modal>
225+
</div>
226+
)
227+
}

0 commit comments

Comments
 (0)