@purpurds/modal 5.10.1 → 5.11.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpurds/modal",
3
- "version": "5.10.1",
3
+ "version": "5.11.1",
4
4
  "license": "AGPL-3.0-only",
5
5
  "main": "./dist/modal.cjs.js",
6
6
  "types": "./dist/modal.d.ts",
@@ -16,36 +16,36 @@
16
16
  "dependencies": {
17
17
  "@radix-ui/react-dialog": "~1.0.5",
18
18
  "classnames": "~2.5.0",
19
- "@purpurds/button": "5.10.1",
20
- "@purpurds/icon": "5.10.1",
21
- "@purpurds/paragraph": "5.10.1",
22
- "@purpurds/heading": "5.10.1",
23
- "@purpurds/tokens": "5.10.1",
24
- "@purpurds/visually-hidden": "5.10.1",
25
- "@purpurds/text-spacing": "5.10.1",
26
- "@purpurds/notification": "5.10.1"
19
+ "@purpurds/button": "5.11.1",
20
+ "@purpurds/icon": "5.11.1",
21
+ "@purpurds/heading": "5.11.1",
22
+ "@purpurds/text-spacing": "5.11.1",
23
+ "@purpurds/paragraph": "5.11.1",
24
+ "@purpurds/visually-hidden": "5.11.1",
25
+ "@purpurds/tokens": "5.11.1",
26
+ "@purpurds/notification": "5.11.1"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@rushstack/eslint-patch": "~1.10.0",
30
- "@storybook/blocks": "~7.6.0",
31
- "@storybook/react": "~7.6.0",
30
+ "@storybook/react": "^8.2.6",
31
+ "storybook": "^8.2.6",
32
32
  "@telia/base-rig": "~8.2.0",
33
33
  "@telia/react-rig": "~3.2.0",
34
34
  "@testing-library/dom": "~9.3.3",
35
35
  "@testing-library/jest-dom": "~6.4.0",
36
36
  "@testing-library/react": "~14.3.0",
37
37
  "@types/node": "20.12.12",
38
- "@types/react-dom": "~18.3.0",
39
- "@types/react": "~18.3.0",
38
+ "@types/react-dom": "^18.3.0",
39
+ "@types/react": "^18.3.3",
40
40
  "eslint-plugin-testing-library": "~6.2.0",
41
- "eslint": "~8.57.0",
41
+ "eslint": "^8.57.0",
42
42
  "jsdom": "~22.1.0",
43
43
  "lint-staged": "~10.5.3",
44
44
  "prettier": "~2.8.8",
45
- "react-dom": "~18.3.0",
46
- "react": "~18.3.0",
47
- "typescript": "~5.4.2",
48
- "vite": "~5.2.2",
45
+ "react-dom": "^18.3.1",
46
+ "react": "^18.3.1",
47
+ "typescript": "^5.5.4",
48
+ "vite": "5.3.4",
49
49
  "vitest": "~1.5.0",
50
50
  "@purpurds/component-rig": "1.0.0"
51
51
  },
@@ -11,8 +11,8 @@ import c from "classnames/bind";
11
11
 
12
12
  import "@purpurds/notification/styles";
13
13
  import styles from "./modal-content.module.scss";
14
- export const primaryActionVariants = ["primary", "expressive", "destructive"] as const;
15
14
 
15
+ export const primaryActionVariants = ["primary", "expressive", "destructive"] as const;
16
16
  export type PrimaryActionVariant = (typeof primaryActionVariants)[number];
17
17
 
18
18
  export type DefaultProps = {
@@ -45,6 +45,7 @@ export type DefaultProps = {
45
45
  notification?: ReactNode;
46
46
  /**
47
47
  * The variant for the primary action button.
48
+ * `type PrimaryActionVariant = "primary" | "expressive" | "destructive"`
48
49
  * */
49
50
  primaryActionVariant?: PrimaryActionVariant;
50
51
  /**
@@ -109,7 +110,7 @@ export const ModalContent = forwardRef(
109
110
  notification = undefined,
110
111
  zIndex,
111
112
  ...props
112
- }: ModalContentProps,
113
+ }: ModalContentProps & { primaryActionVariant?: "primary" | "expressive" | "destructive" },
113
114
  ref: ForwardedRef<HTMLDivElement>
114
115
  ) => {
115
116
  const { closeButtonAllyLabel, showCloseButton, ...rest } = props;
@@ -299,7 +300,9 @@ export const ModalActions = ({
299
300
  actions,
300
301
  primaryActionVariant,
301
302
  notification,
302
- }: Pick<ModalContentProps, "actions" | "primaryActionVariant" | "notification">) => {
303
+ }: Pick<ModalContentProps, "actions" | "notification"> & {
304
+ primaryActionVariant?: "primary" | "expressive" | "destructive";
305
+ }) => {
303
306
  const notificationRef = useRef<HTMLDivElement>(null);
304
307
  const buttonVariants = [primaryActionVariant, "secondary", "text"];
305
308
 
@@ -1,5 +1,7 @@
1
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
1
2
  import React from "react";
2
3
  import { Button } from "@purpurds/button";
4
+ import { Notification } from "@purpurds/notification";
3
5
  import { Paragraph } from "@purpurds/paragraph";
4
6
  import { TextSpacing } from "@purpurds/text-spacing";
5
7
  import type { Meta, StoryObj } from "@storybook/react";
@@ -7,18 +9,30 @@ import type { Meta, StoryObj } from "@storybook/react";
7
9
  import "@purpurds/button/styles";
8
10
  import "@purpurds/icon/styles";
9
11
  import "@purpurds/text-spacing/styles";
12
+ import "@purpurds/notification/styles";
10
13
  import { Modal } from "./modal";
11
14
 
12
- const meta: Meta<typeof Modal> = {
15
+ const Z_INDEX_TO_MAKE_IT_LOOK_GOOD_IN_STORYBOOK = 1;
16
+
17
+ const meta = {
13
18
  title: "Components/Modal",
14
19
  component: Modal,
15
- };
16
-
17
- export default meta;
18
- type Story = StoryObj<typeof Modal>;
19
-
20
- export const Showcase: Story = {
20
+ subcomponents: {
21
+ // @ts-ignore
22
+ "Modal.Content": Modal.Content,
23
+ // @ts-ignore
24
+ "Modal.Trigger": Modal.Trigger,
25
+ },
21
26
  parameters: {
27
+ docs: {
28
+ description: {
29
+ component: "This is the main Modal component",
30
+ subcomponents: {
31
+ "Modal.Content": "This is the Modal Content subcomponent",
32
+ "Modal.Trigger": "This is the Modal Trigger subcomponent",
33
+ },
34
+ },
35
+ },
22
36
  design: [
23
37
  {
24
38
  name: "Modal",
@@ -27,6 +41,12 @@ export const Showcase: Story = {
27
41
  },
28
42
  ],
29
43
  },
44
+ } satisfies Meta<typeof Modal>;
45
+
46
+ export default meta;
47
+ type Story = StoryObj<typeof Modal>;
48
+
49
+ export const Showcase: Story = {
30
50
  render: () => {
31
51
  const cookieActions = [
32
52
  { label: "I accept cookies", onClick: () => {} },
@@ -55,6 +75,7 @@ export const Showcase: Story = {
55
75
  actions={cookieActions}
56
76
  description="Sticky buttons"
57
77
  stickyButtons
78
+ zIndex={Z_INDEX_TO_MAKE_IT_LOOK_GOOD_IN_STORYBOOK}
58
79
  >
59
80
  <Paragraph variant="paragraph-100">
60
81
  By clicking &quot;I accept cookies&quot; you consent to the storage of cookies on your
@@ -68,7 +89,11 @@ export const Showcase: Story = {
68
89
  <Modal.Trigger>
69
90
  <Button variant="secondary">Open privacy policy</Button>
70
91
  </Modal.Trigger>
71
- <Modal.Content title="Privacy policy for Telia Sverige AB" actions={privacyPolicyActions}>
92
+ <Modal.Content
93
+ title="Privacy policy for Telia Sverige AB"
94
+ actions={privacyPolicyActions}
95
+ zIndex={Z_INDEX_TO_MAKE_IT_LOOK_GOOD_IN_STORYBOOK}
96
+ >
72
97
  <TextSpacing>
73
98
  <Paragraph variant="paragraph-100">
74
99
  We are Telia Sverige AB (org. nr 556430-0142), (hereafter ‘Telia’). In this Privacy
@@ -118,6 +143,7 @@ export const Showcase: Story = {
118
143
  primaryActionVariant="destructive"
119
144
  description="Not sticky buttons"
120
145
  stickyButtons={false}
146
+ zIndex={Z_INDEX_TO_MAKE_IT_LOOK_GOOD_IN_STORYBOOK}
121
147
  >
122
148
  <Paragraph variant="paragraph-100">
123
149
  Upon termination of the main subscription, all related data sims and e-sims are
@@ -129,3 +155,83 @@ export const Showcase: Story = {
129
155
  );
130
156
  },
131
157
  };
158
+
159
+ export const ModalContentWithImage: Story = {
160
+ render: () => {
161
+ return (
162
+ <div style={{ display: "flex", gap: "var(--purpur-spacing-200)" }}>
163
+ <Modal>
164
+ <Modal.Trigger>
165
+ <Button variant="primary">Open</Button>
166
+ </Modal.Trigger>
167
+ <Modal.Content
168
+ zIndex={Z_INDEX_TO_MAKE_IT_LOOK_GOOD_IN_STORYBOOK}
169
+ image={
170
+ // eslint-disable-next-line react/jsx-wrap-multilines
171
+ <img
172
+ src="https://www.telia.se/images/i15skfqwpurk/5YYelnwdIJGush05RYsE6A/04d4eeb571bca6d5c72b557f6da92c92/Telia_Company_Reinvention_69.jpg?f=center&fit=fill&w=720&h=432&fm=webp&q=70"
173
+ alt="Familjens unga ser på tv tillsammans mysig stämning men spännande"
174
+ />
175
+ }
176
+ title="Modal with image"
177
+ >
178
+ <TextSpacing>
179
+ <Paragraph variant="paragraph-100">
180
+ Lorem ipsum dolor sit amet consectetur. Diam vitae leo amet tortor ut faucibus diam
181
+ faucibus eu. Pellentesque quis pellentesque sit fermentum. Mi id aenean aliquam nibh
182
+ placerat.Lorem ipsum dolor sit amet consectetur. Diam vitae leo amet tortor ut
183
+ faucibus diam faucibus eu.
184
+ </Paragraph>
185
+ <Paragraph variant="paragraph-100">
186
+ Pellentesque quis pellentesque sit fermentum. Mi id aenean aliquam nibh
187
+ placerat.Lorem ipsum dolor sit amet consectetur. Diam vitae leo amet tortor ut
188
+ faucibus diam faucibus eu. Pellentesque quis pellentesque sit fermentum. Mi id
189
+ aenean aliquam nibh placerat.
190
+ </Paragraph>
191
+ </TextSpacing>
192
+ </Modal.Content>
193
+ </Modal>
194
+ </div>
195
+ );
196
+ },
197
+ };
198
+
199
+ export const ModalContentWithNotification: Story = {
200
+ render: () => {
201
+ return (
202
+ <div style={{ display: "flex", gap: "var(--purpur-spacing-200)" }}>
203
+ <Modal>
204
+ <Modal.Trigger>
205
+ <Button variant="primary">Open</Button>
206
+ </Modal.Trigger>
207
+ <Modal.Content
208
+ actions={[{ label: "I accept cookies", onClick: () => {} }]}
209
+ zIndex={Z_INDEX_TO_MAKE_IT_LOOK_GOOD_IN_STORYBOOK}
210
+ notification={
211
+ // eslint-disable-next-line react/jsx-wrap-multilines
212
+ <Notification status="error" heading="Notification heading">
213
+ Notification text
214
+ </Notification>
215
+ }
216
+ title="Notification heading"
217
+ >
218
+ <TextSpacing>
219
+ <Paragraph variant="paragraph-100">
220
+ Lorem ipsum dolor sit amet consectetur. Diam vitae leo amet tortor ut faucibus diam
221
+ faucibus eu. Pellentesque quis pellentesque sit fermentum. Mi id aenean aliquam nibh
222
+ placerat.Lorem ipsum dolor sit amet consectetur. Diam vitae leo amet tortor ut
223
+ faucibus diam faucibus eu.
224
+ </Paragraph>
225
+ <Paragraph variant="paragraph-100">
226
+ Pellentesque quis pellentesque sit fermentum. Mi id aenean aliquam nibh
227
+ placerat.Lorem ipsum dolor sit amet consectetur. Diam vitae leo amet tortor ut
228
+ faucibus diam faucibus eu. Pellentesque quis pellentesque sit fermentum. Mi id
229
+ aenean aliquam nibh placerat.
230
+ </Paragraph>
231
+ </TextSpacing>
232
+ </Modal.Content>
233
+ </Modal>
234
+ </div>
235
+ );
236
+ },
237
+ };
package/readme.mdx DELETED
@@ -1,71 +0,0 @@
1
- import { Meta, Stories, ArgTypes, Primary, Subtitle } from "@storybook/blocks";
2
-
3
- import * as ModalStories from "./src/modal.stories";
4
- import * as ModalContentStories from "./src/modal-content.stories";
5
- import packageInfo from "./package.json";
6
-
7
- <Meta name="Docs" title="Components/Modal" of={ModalStories} />
8
-
9
- # Modal
10
-
11
- <Subtitle>Version {packageInfo.version}</Subtitle>
12
-
13
- ### Showcase
14
-
15
- <Primary />
16
-
17
- ### Properties
18
-
19
- #### Modal
20
-
21
- <ArgTypes of={ModalStories} />
22
-
23
- #### ModalContent
24
-
25
- <ArgTypes of={ModalContentStories} />
26
-
27
- ### Installation
28
-
29
- #### Via NPM
30
-
31
- Add the dependency to your consumer app like `"@purpurds/purpur": "^x.y.z"`
32
-
33
- In MyApp.tsx
34
-
35
- ```tsx
36
- import "@purpurds/purpur/styles";
37
- ```
38
-
39
- In MyComponent.tsx
40
-
41
- ```tsx
42
- import { Button, Modal } from "@purpurds/purpur";
43
-
44
- export const MyComponent = () => {
45
- const actions = [
46
- {
47
- label: "Primary action",
48
- onClick: () => {
49
- // click event handler
50
- },
51
- },
52
- ];
53
-
54
- return (
55
- <Modal>
56
- <Modal.Trigger>
57
- <Button variant="primary">Open modal</Button>
58
- </Modal.Trigger>
59
- <Modal.Content
60
- title="A title"
61
- description="A short optional description of the modal"
62
- actions={actions}
63
- showCloseButton
64
- closeButtonAllyLabel="Close"
65
- >
66
- Some content
67
- </Modal.Content>
68
- </Modal>
69
- );
70
- };
71
- ```
@@ -1,148 +0,0 @@
1
- import React from "react";
2
- import { Notification } from "@purpurds/notification";
3
- import { Paragraph } from "@purpurds/paragraph";
4
- import { TextSpacing } from "@purpurds/text-spacing";
5
- import * as RadixDialog from "@radix-ui/react-dialog";
6
- import type { Meta, StoryObj } from "@storybook/react";
7
-
8
- import "@purpurds/button/styles";
9
- import "@purpurds/icon/styles";
10
- import "@purpurds/text-spacing/styles";
11
- import { ModalContent as ModalContentCmp, primaryActionVariants } from "./modal-content";
12
-
13
- const meta: Meta<typeof ModalContentCmp> = {
14
- title: "Components/Modal",
15
- component: ModalContentCmp,
16
- };
17
-
18
- export default meta;
19
- type Story = StoryObj<typeof ModalContentCmp>;
20
-
21
- const defaultArgs = {
22
- actions: [
23
- {
24
- label: "Primary button",
25
- onClick: () => {},
26
- },
27
- {
28
- label: "Secondary button",
29
- onClick: () => {},
30
- },
31
- { label: "Tertiary text button", onClick: () => {} },
32
- ],
33
- description: "This is an optional description",
34
- primaryActionVariant: primaryActionVariants[0],
35
- stickyButtons: true,
36
- title: "Title",
37
- };
38
-
39
- const argTypes = {
40
- primaryActionVariant: { control: "select", options: primaryActionVariants },
41
- };
42
-
43
- export const ModalContent: Story = {
44
- args: defaultArgs,
45
- parameters: {
46
- design: [
47
- {
48
- name: "Modal",
49
- type: "figma",
50
- url: "https://www.figma.com/file/TggtRkYyKpwgKTU0LxuYFN/Modal-redesign?type=design&node-id=104-731&mode=design&t=sm44NPLlG3tjpFQb-0",
51
- },
52
- ],
53
- },
54
- argTypes,
55
- render: (args) => {
56
- return (
57
- <RadixDialog.Root open>
58
- <ModalContentCmp {...args} />
59
- </RadixDialog.Root>
60
- );
61
- },
62
- };
63
-
64
- export const ModalContentWithImage: Story = {
65
- args: {
66
- ...defaultArgs,
67
- description: undefined,
68
- image: (
69
- <img
70
- src="https://www.telia.se/images/i15skfqwpurk/5YYelnwdIJGush05RYsE6A/04d4eeb571bca6d5c72b557f6da92c92/Telia_Company_Reinvention_69.jpg"
71
- alt="Familjens unga ser på tv tillsammans mysig stämning men spännande"
72
- />
73
- ),
74
- },
75
- parameters: {
76
- design: [
77
- {
78
- name: "Modal",
79
- type: "figma",
80
- url: "https://www.figma.com/file/TggtRkYyKpwgKTU0LxuYFN/Modal-redesign?type=design&node-id=104-731&mode=design&t=sm44NPLlG3tjpFQb-0",
81
- },
82
- ],
83
- },
84
- argTypes,
85
- render: (args) => {
86
- return (
87
- <RadixDialog.Root open>
88
- <ModalContentCmp {...args}>
89
- <TextSpacing>
90
- <Paragraph variant="paragraph-100">
91
- Lorem ipsum dolor sit amet consectetur. Diam vitae leo amet tortor ut faucibus diam
92
- faucibus eu. Pellentesque quis pellentesque sit fermentum. Mi id aenean aliquam nibh
93
- placerat.Lorem ipsum dolor sit amet consectetur. Diam vitae leo amet tortor ut
94
- faucibus diam faucibus eu.
95
- </Paragraph>
96
- <Paragraph variant="paragraph-100">
97
- Pellentesque quis pellentesque sit fermentum. Mi id aenean aliquam nibh placerat.Lorem
98
- ipsum dolor sit amet consectetur. Diam vitae leo amet tortor ut faucibus diam faucibus
99
- eu. Pellentesque quis pellentesque sit fermentum. Mi id aenean aliquam nibh placerat.
100
- </Paragraph>
101
- </TextSpacing>
102
- </ModalContentCmp>
103
- </RadixDialog.Root>
104
- );
105
- },
106
- };
107
-
108
- export const ModalContentWithNotification: Story = {
109
- args: {
110
- ...defaultArgs,
111
- notification: (
112
- <Notification status="error" heading="Notification heading">
113
- Notification text
114
- </Notification>
115
- ),
116
- },
117
- parameters: {
118
- design: [
119
- {
120
- name: "Modal",
121
- type: "figma",
122
- url: "https://www.figma.com/file/TggtRkYyKpwgKTU0LxuYFN/Modal-redesign?type=design&node-id=104-731&mode=design&t=sm44NPLlG3tjpFQb-0",
123
- },
124
- ],
125
- },
126
- argTypes,
127
- render: (args) => {
128
- return (
129
- <RadixDialog.Root open>
130
- <ModalContentCmp {...args}>
131
- <TextSpacing>
132
- <Paragraph variant="paragraph-100">
133
- Lorem ipsum dolor sit amet consectetur. Diam vitae leo amet tortor ut faucibus diam
134
- faucibus eu. Pellentesque quis pellentesque sit fermentum. Mi id aenean aliquam nibh
135
- placerat.Lorem ipsum dolor sit amet consectetur. Diam vitae leo amet tortor ut
136
- faucibus diam faucibus eu.
137
- </Paragraph>
138
- <Paragraph variant="paragraph-100">
139
- Pellentesque quis pellentesque sit fermentum. Mi id aenean aliquam nibh placerat.Lorem
140
- ipsum dolor sit amet consectetur. Diam vitae leo amet tortor ut faucibus diam faucibus
141
- eu. Pellentesque quis pellentesque sit fermentum. Mi id aenean aliquam nibh placerat.
142
- </Paragraph>
143
- </TextSpacing>
144
- </ModalContentCmp>
145
- </RadixDialog.Root>
146
- );
147
- },
148
- };