@purpurds/modal 5.24.2 → 5.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LICENSE.txt +5 -5
- package/dist/modal-content.d.ts +4 -2
- package/dist/modal-content.d.ts.map +1 -1
- package/dist/modal.cjs.js +5 -5
- package/dist/modal.cjs.js.map +1 -1
- package/dist/modal.es.js +25 -21
- package/dist/modal.es.js.map +1 -1
- package/package.json +9 -9
- package/src/modal-content.module.scss +6 -4
- package/src/modal-content.tsx +11 -2
- package/src/modal.stories.tsx +36 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@purpurds/modal",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.25.0",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"main": "./dist/modal.cjs.js",
|
|
6
6
|
"types": "./dist/modal.d.ts",
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@radix-ui/react-dialog": "~1.0.5",
|
|
18
18
|
"classnames": "~2.5.0",
|
|
19
|
-
"@purpurds/
|
|
20
|
-
"@purpurds/
|
|
21
|
-
"@purpurds/
|
|
22
|
-
"@purpurds/
|
|
23
|
-
"@purpurds/
|
|
24
|
-
"@purpurds/
|
|
25
|
-
"@purpurds/
|
|
26
|
-
"@purpurds/
|
|
19
|
+
"@purpurds/icon": "5.25.0",
|
|
20
|
+
"@purpurds/paragraph": "5.25.0",
|
|
21
|
+
"@purpurds/text-spacing": "5.25.0",
|
|
22
|
+
"@purpurds/heading": "5.25.0",
|
|
23
|
+
"@purpurds/button": "5.25.0",
|
|
24
|
+
"@purpurds/visually-hidden": "5.25.0",
|
|
25
|
+
"@purpurds/notification": "5.25.0",
|
|
26
|
+
"@purpurds/tokens": "5.25.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@rushstack/eslint-patch": "~1.10.0",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@
|
|
1
|
+
@use "@purpurds/tokens/breakpoint/variables" as *;
|
|
2
2
|
|
|
3
3
|
$fadeIn: fadeIn var(--purpur-motion-duration-200) var(--purpur-motion-easing-ease-in-out);
|
|
4
4
|
|
|
@@ -95,12 +95,14 @@ $fadeIn: fadeIn var(--purpur-motion-duration-200) var(--purpur-motion-easing-eas
|
|
|
95
95
|
position: sticky;
|
|
96
96
|
top: 0;
|
|
97
97
|
flex-grow: 0;
|
|
98
|
-
padding: var(--purpur-spacing-200) calc(var(--purpur-spacing-600) + var(--purpur-spacing-150)) 0
|
|
98
|
+
padding: var(--purpur-spacing-200) calc(var(--purpur-spacing-600) + var(--purpur-spacing-150)) 0
|
|
99
|
+
var(--purpur-spacing-200);
|
|
99
100
|
background: var(--purpur-color-background-primary);
|
|
100
101
|
z-index: 1;
|
|
101
102
|
|
|
102
103
|
@media (min-width: $purpur-breakpoint-md) {
|
|
103
|
-
padding: var(--purpur-spacing-250) calc(var(--purpur-spacing-800) + var(--purpur-spacing-50))
|
|
104
|
+
padding: var(--purpur-spacing-250) calc(var(--purpur-spacing-800) + var(--purpur-spacing-50))
|
|
105
|
+
0 var(--purpur-spacing-300);
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
108
|
|
|
@@ -246,4 +248,4 @@ $fadeIn: fadeIn var(--purpur-motion-duration-200) var(--purpur-motion-easing-eas
|
|
|
246
248
|
to {
|
|
247
249
|
opacity: 1;
|
|
248
250
|
}
|
|
249
|
-
}
|
|
251
|
+
}
|
package/src/modal-content.tsx
CHANGED
|
@@ -19,7 +19,14 @@ export type DefaultProps = {
|
|
|
19
19
|
/**
|
|
20
20
|
* An array of actions to be displayed at the bottom of the modal in the form of buttons. A maximum of 3 buttons will be rendered,
|
|
21
21
|
* */
|
|
22
|
-
actions?:
|
|
22
|
+
actions?: {
|
|
23
|
+
label: string;
|
|
24
|
+
onClick: () => void;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
loading?: boolean;
|
|
27
|
+
icon?: ReactNode;
|
|
28
|
+
iconPosition?: "left" | "right";
|
|
29
|
+
}[];
|
|
23
30
|
children: ReactNode;
|
|
24
31
|
className?: string;
|
|
25
32
|
/**
|
|
@@ -302,7 +309,7 @@ export const ModalActions = ({
|
|
|
302
309
|
<div className={cx(`${rootClassName}__actions-buttons`)} data-testid="modal actions">
|
|
303
310
|
{actions
|
|
304
311
|
.slice(0, MAX_NUMBER_OF_ACTIONS)
|
|
305
|
-
.map(({ label, onClick, disabled, loading }, index) => (
|
|
312
|
+
.map(({ label, onClick, disabled, loading, iconPosition = "right", icon }, index) => (
|
|
306
313
|
<Button
|
|
307
314
|
key={label}
|
|
308
315
|
data-testid="modal actions button"
|
|
@@ -312,7 +319,9 @@ export const ModalActions = ({
|
|
|
312
319
|
loading={loading}
|
|
313
320
|
className={cx(`${rootClassName}__actions-button`)}
|
|
314
321
|
>
|
|
322
|
+
{iconPosition === "left" && icon && icon}
|
|
315
323
|
{label}
|
|
324
|
+
{iconPosition === "right" && icon && icon}
|
|
316
325
|
</Button>
|
|
317
326
|
))}
|
|
318
327
|
</div>
|
package/src/modal.stories.tsx
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
1
2
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
3
|
import React from "react";
|
|
3
4
|
import { Button } from "@purpurds/button";
|
|
5
|
+
import { IconAiRobot, IconBankid } from "@purpurds/icon";
|
|
4
6
|
import { Notification } from "@purpurds/notification";
|
|
5
7
|
import { Paragraph } from "@purpurds/paragraph";
|
|
6
8
|
import { TextSpacing } from "@purpurds/text-spacing";
|
|
@@ -278,3 +280,37 @@ export const ModalContentWithNotification: Story = {
|
|
|
278
280
|
);
|
|
279
281
|
},
|
|
280
282
|
};
|
|
283
|
+
|
|
284
|
+
export const ModalContentWithCustomIcon: Story = {
|
|
285
|
+
render: () => (
|
|
286
|
+
<div style={{ display: "flex", gap: "var(--purpur-spacing-200)" }}>
|
|
287
|
+
<Modal>
|
|
288
|
+
<Modal.Trigger>
|
|
289
|
+
<Button variant="primary">Open</Button>
|
|
290
|
+
</Modal.Trigger>
|
|
291
|
+
<Modal.Content
|
|
292
|
+
actions={[
|
|
293
|
+
{ label: "I accept cookies", onClick: () => {}, icon: <IconAiRobot /> },
|
|
294
|
+
{
|
|
295
|
+
label: "I accept BankID",
|
|
296
|
+
onClick: () => {},
|
|
297
|
+
icon: <IconBankid />,
|
|
298
|
+
iconPosition: "left",
|
|
299
|
+
},
|
|
300
|
+
]}
|
|
301
|
+
zIndex={Z_INDEX_TO_MAKE_IT_LOOK_GOOD_IN_STORYBOOK}
|
|
302
|
+
title="Notification heading"
|
|
303
|
+
>
|
|
304
|
+
<TextSpacing>
|
|
305
|
+
<Paragraph>
|
|
306
|
+
Lorem ipsum dolor sit amet consectetur. Diam vitae leo amet tortor ut faucibus diam
|
|
307
|
+
faucibus eu. Pellentesque quis pellentesque sit fermentum. Mi id aenean aliquam nibh
|
|
308
|
+
placerat.Lorem ipsum dolor sit amet consectetur. Diam vitae leo amet tortor ut
|
|
309
|
+
faucibus diam faucibus eu.
|
|
310
|
+
</Paragraph>
|
|
311
|
+
</TextSpacing>
|
|
312
|
+
</Modal.Content>
|
|
313
|
+
</Modal>
|
|
314
|
+
</div>
|
|
315
|
+
),
|
|
316
|
+
};
|