@nypl/design-system-react-components 0.25.7 → 0.25.8

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/components/Icons/IconSvgs.d.ts +1 -0
  3. package/dist/components/Icons/IconTypes.d.ts +1 -0
  4. package/dist/components/Image/ImageTypes.d.ts +3 -1
  5. package/dist/components/Link/LinkTypes.d.ts +1 -0
  6. package/dist/components/Notification/Notification.d.ts +2 -0
  7. package/dist/components/Select/Select.d.ts +2 -0
  8. package/dist/components/Toggle/Toggle.d.ts +47 -0
  9. package/dist/components/Toggle/ToggleSizes.d.ts +4 -0
  10. package/dist/components/VideoPlayer/VideoPlayer.d.ts +5 -3
  11. package/dist/design-system-react-components.cjs.development.js +613 -366
  12. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  13. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  14. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  15. package/dist/design-system-react-components.esm.js +606 -354
  16. package/dist/design-system-react-components.esm.js.map +1 -1
  17. package/dist/index.d.ts +3 -0
  18. package/dist/theme/components/notification.d.ts +8 -4
  19. package/dist/theme/components/toggle.d.ts +68 -0
  20. package/dist/theme/foundations/spacing.d.ts +2 -0
  21. package/package.json +1 -1
  22. package/src/components/Accordion/Accordion.stories.mdx +1 -2
  23. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +1 -1
  24. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +10 -0
  25. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +99 -0
  26. package/src/components/Button/Button.tsx +0 -1
  27. package/src/components/Card/Card.stories.mdx +74 -7
  28. package/src/components/Card/Card.tsx +9 -8
  29. package/src/components/Card/__snapshots__/Card.test.tsx.snap +67 -35
  30. package/src/components/Chakra/Grid.stories.mdx +11 -14
  31. package/src/components/DatePicker/DatePicker.test.tsx +8 -6
  32. package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +5 -4
  33. package/src/components/Icons/Icon.stories.mdx +3 -2
  34. package/src/components/Icons/IconSvgs.tsx +2 -0
  35. package/src/components/Icons/IconTypes.tsx +1 -0
  36. package/src/components/Image/Image.stories.mdx +152 -90
  37. package/src/components/Image/Image.test.tsx +10 -0
  38. package/src/components/Image/ImageTypes.ts +2 -0
  39. package/src/components/Image/__snapshots__/Image.test.tsx.snap +24 -8
  40. package/src/components/Label/Label.stories.mdx +1 -1
  41. package/src/components/Link/Link.stories.mdx +2 -3
  42. package/src/components/Link/Link.test.tsx +71 -0
  43. package/src/components/Link/Link.tsx +41 -9
  44. package/src/components/Link/LinkTypes.tsx +1 -0
  45. package/src/components/Link/__snapshots__/Link.test.tsx.snap +201 -0
  46. package/src/components/Notification/Notification.stories.mdx +36 -3
  47. package/src/components/Notification/Notification.test.tsx +62 -16
  48. package/src/components/Notification/Notification.tsx +17 -5
  49. package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +117 -0
  50. package/src/components/Pagination/Pagination.stories.mdx +1 -2
  51. package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +42 -0
  52. package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +2 -3
  53. package/src/components/SearchBar/SearchBar.stories.mdx +1 -1
  54. package/src/components/Select/Select.stories.mdx +132 -55
  55. package/src/components/Select/Select.test.tsx +2 -2
  56. package/src/components/Select/Select.tsx +6 -2
  57. package/src/components/Slider/Slider.stories.mdx +3 -2
  58. package/src/components/Slider/Slider.test.tsx +35 -0
  59. package/src/components/Slider/Slider.tsx +8 -2
  60. package/src/components/Template/Template.stories.mdx +1 -2
  61. package/src/components/Toggle/Toggle.stories.mdx +176 -0
  62. package/src/components/Toggle/Toggle.test.tsx +140 -0
  63. package/src/components/Toggle/Toggle.tsx +118 -0
  64. package/src/components/Toggle/ToggleSizes.tsx +4 -0
  65. package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +255 -0
  66. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +39 -18
  67. package/src/components/VideoPlayer/VideoPlayer.test.tsx +103 -1
  68. package/src/components/VideoPlayer/VideoPlayer.tsx +57 -17
  69. package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +48 -0
  70. package/src/index.ts +6 -0
  71. package/src/theme/components/breadcrumb.ts +1 -1
  72. package/src/theme/components/card.ts +4 -5
  73. package/src/theme/components/global.ts +1 -1
  74. package/src/theme/components/icon.ts +2 -2
  75. package/src/theme/components/image.ts +8 -0
  76. package/src/theme/components/notification.ts +8 -6
  77. package/src/theme/components/toggle.ts +65 -0
  78. package/src/theme/foundations/spacing.ts +3 -0
  79. package/src/theme/index.ts +2 -0
  80. package/src/utils/componentCategories.ts +3 -1
@@ -43,6 +43,8 @@ export interface NotificationProps extends BasePropsWithoutAlignText {
43
43
  notificationContent: string | JSX.Element;
44
44
  /** Content to be rendered in a `NotificationHeading` component. */
45
45
  notificationHeading?: string;
46
+ /** Prop to display the `Notification` icon. Defaults to `true`. */
47
+ showIcon?: boolean;
46
48
  }
47
49
 
48
50
  /**
@@ -54,6 +56,7 @@ export function NotificationHeading(
54
56
  const { centered, children, icon, notificationType } = props;
55
57
  const styles = useMultiStyleConfig("NotificationHeading", {
56
58
  centered,
59
+ icon,
57
60
  notificationType,
58
61
  });
59
62
  return (
@@ -75,6 +78,7 @@ export function NotificationContent(
75
78
  const { alignText, children, icon, notificationType } = props;
76
79
  const styles = useMultiStyleConfig("NotificationContent", {
77
80
  alignText,
81
+ icon,
78
82
  notificationType,
79
83
  });
80
84
  return (
@@ -100,6 +104,7 @@ export default function Notification(props: NotificationProps) {
100
104
  notificationContent,
101
105
  notificationHeading,
102
106
  notificationType = NotificationTypes.Standard,
107
+ showIcon = true,
103
108
  } = props;
104
109
  const [isOpen, setIsOpen] = useState(true);
105
110
  const handleClose = () => setIsOpen(false);
@@ -107,6 +112,7 @@ export default function Notification(props: NotificationProps) {
107
112
  centered,
108
113
  noMargin,
109
114
  notificationType,
115
+ showIcon,
110
116
  });
111
117
  const iconElement = () => {
112
118
  const baseIconProps = {
@@ -114,6 +120,10 @@ export default function Notification(props: NotificationProps) {
114
120
  size: IconSizes.Large,
115
121
  additionalStyles: styles.icon,
116
122
  };
123
+ // If the icon should not display, return null.
124
+ if (!showIcon) {
125
+ return null;
126
+ }
117
127
  // If a custom icon is passed, add specific `Notification` styles.
118
128
  if (icon)
119
129
  return React.cloneElement(icon, {
@@ -125,18 +135,22 @@ export default function Notification(props: NotificationProps) {
125
135
  name: IconNames.SpeakerNotes,
126
136
  color: IconColors.SectionResearchSecondary,
127
137
  },
138
+ [NotificationTypes.Standard]: {
139
+ name: IconNames.AlertNotificationImportant,
140
+ color: IconColors.UiBlack,
141
+ },
128
142
  [NotificationTypes.Warning]: {
129
143
  name: IconNames.ErrorFilled,
130
144
  color: IconColors.BrandPrimary,
131
145
  },
132
146
  };
133
- return notificationType !== NotificationTypes.Standard ? (
147
+ return (
134
148
  <Icon
135
149
  id={`${id}-notification-icon`}
136
150
  {...baseIconProps}
137
151
  {...iconProps[notificationType]}
138
152
  />
139
- ) : null;
153
+ );
140
154
  };
141
155
  const dismissibleButton = dismissible && (
142
156
  <Button
@@ -163,9 +177,7 @@ export default function Notification(props: NotificationProps) {
163
177
  </NotificationHeading>
164
178
  );
165
179
  // Specific alignment styles for the content.
166
- const alignText =
167
- childHeading &&
168
- (!!icon || (notificationType !== NotificationTypes.Standard && !centered));
180
+ const alignText = childHeading && showIcon && (!!icon || !centered);
169
181
  const childContent = (
170
182
  <NotificationContent
171
183
  alignText={alignText}
@@ -12,6 +12,38 @@ exports[`Notification renders the UI snapshot correctly 1`] = `
12
12
  <header
13
13
  className="css-0"
14
14
  >
15
+ <svg
16
+ aria-hidden={false}
17
+ className="chakra-icon css-onkibi"
18
+ focusable={false}
19
+ id="notificationID1-notification-icon"
20
+ role="img"
21
+ title="alert_notification_important icon"
22
+ viewBox="0 0 24 24"
23
+ >
24
+ <g
25
+ stroke="currentColor"
26
+ strokeWidth="1.5"
27
+ >
28
+ <path
29
+ d="M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"
30
+ fill="none"
31
+ strokeLinecap="round"
32
+ />
33
+ <path
34
+ d="M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"
35
+ fill="currentColor"
36
+ strokeLinecap="round"
37
+ />
38
+ <circle
39
+ cx="12"
40
+ cy="12"
41
+ fill="none"
42
+ r="11.25"
43
+ strokeMiterlimit="10"
44
+ />
45
+ </g>
46
+ </svg>
15
47
  <h4
16
48
  className="chakra-heading css-0"
17
49
  >
@@ -162,6 +194,91 @@ exports[`Notification renders the UI snapshot correctly 4`] = `
162
194
  className="css-0"
163
195
  data-type="standard"
164
196
  id="notificationID4"
197
+ >
198
+ <div
199
+ className="css-0"
200
+ >
201
+ <div
202
+ className="css-0"
203
+ >
204
+ <svg
205
+ aria-hidden={false}
206
+ className="chakra-icon css-onkibi"
207
+ focusable={false}
208
+ id="notificationID4-notification-icon"
209
+ role="img"
210
+ title="alert_notification_important icon"
211
+ viewBox="0 0 24 24"
212
+ >
213
+ <g
214
+ stroke="currentColor"
215
+ strokeWidth="1.5"
216
+ >
217
+ <path
218
+ d="M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"
219
+ fill="none"
220
+ strokeLinecap="round"
221
+ />
222
+ <path
223
+ d="M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"
224
+ fill="currentColor"
225
+ strokeLinecap="round"
226
+ />
227
+ <circle
228
+ cx="12"
229
+ cy="12"
230
+ fill="none"
231
+ r="11.25"
232
+ strokeMiterlimit="10"
233
+ />
234
+ </g>
235
+ </svg>
236
+ <div
237
+ className="css-0"
238
+ >
239
+ Notification content.
240
+ </div>
241
+ </div>
242
+ </div>
243
+ </aside>
244
+ `;
245
+
246
+ exports[`Notification renders the UI snapshot correctly 5`] = `
247
+ <aside
248
+ className="css-0"
249
+ data-type="standard"
250
+ id="notificationID5"
251
+ >
252
+ <div
253
+ className="css-0"
254
+ >
255
+ <header
256
+ className="css-0"
257
+ >
258
+ <h4
259
+ className="chakra-heading css-0"
260
+ >
261
+ Notification Heading
262
+ </h4>
263
+ </header>
264
+ <div
265
+ className="css-0"
266
+ >
267
+ <div
268
+ className="css-0"
269
+ >
270
+ Notification content.
271
+ </div>
272
+ </div>
273
+ </div>
274
+ </aside>
275
+ `;
276
+
277
+ exports[`Notification renders the UI snapshot correctly 6`] = `
278
+ <aside
279
+ className="css-0"
280
+ data-type="standard"
281
+ id="notificationID6"
165
282
  >
166
283
  <div
167
284
  className="css-0"
@@ -18,8 +18,7 @@ import { getCategory } from "../../utils/componentCategories";
18
18
  parameters={{
19
19
  design: {
20
20
  type: "figma",
21
- url:
22
- "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Master?node-id=17226%3A932",
21
+ url: "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Master?node-id=17226%3A932",
23
22
  },
24
23
  jest: ["Pagination.test.tsx"],
25
24
  }}
@@ -18,6 +18,8 @@ exports[`Pagination Rendering Renders the UI snapshot correctly 1`] = `
18
18
  className="css-1858g8z"
19
19
  href="page=1"
20
20
  id="firstPage-1"
21
+ rel={null}
22
+ target={null}
21
23
  >
22
24
  1
23
25
  </a>
@@ -29,6 +31,8 @@ exports[`Pagination Rendering Renders the UI snapshot correctly 1`] = `
29
31
  className="css-0"
30
32
  href="page=2"
31
33
  id="firstPage-2"
34
+ rel={null}
35
+ target={null}
32
36
  >
33
37
  2
34
38
  </a>
@@ -40,6 +44,8 @@ exports[`Pagination Rendering Renders the UI snapshot correctly 1`] = `
40
44
  className="css-0"
41
45
  href="page=3"
42
46
  id="firstPage-3"
47
+ rel={null}
48
+ target={null}
43
49
  >
44
50
  3
45
51
  </a>
@@ -51,6 +57,8 @@ exports[`Pagination Rendering Renders the UI snapshot correctly 1`] = `
51
57
  className="css-0"
52
58
  href="page=4"
53
59
  id="firstPage-4"
60
+ rel={null}
61
+ target={null}
54
62
  >
55
63
  4
56
64
  </a>
@@ -62,6 +70,8 @@ exports[`Pagination Rendering Renders the UI snapshot correctly 1`] = `
62
70
  className="css-0"
63
71
  href="page=5"
64
72
  id="firstPage-5"
73
+ rel={null}
74
+ target={null}
65
75
  >
66
76
  5
67
77
  </a>
@@ -76,6 +86,8 @@ exports[`Pagination Rendering Renders the UI snapshot correctly 1`] = `
76
86
  className="css-0"
77
87
  href="page=10"
78
88
  id="firstPage-10"
89
+ rel={null}
90
+ target={null}
79
91
  >
80
92
  10
81
93
  </a>
@@ -86,6 +98,8 @@ exports[`Pagination Rendering Renders the UI snapshot correctly 1`] = `
86
98
  className="css-0"
87
99
  href="page=2"
88
100
  id="firstPage-Next"
101
+ rel={null}
102
+ target={null}
89
103
  >
90
104
  Next
91
105
  </a>
@@ -111,6 +125,8 @@ exports[`Pagination Rendering Renders the UI snapshot correctly 2`] = `
111
125
  className="css-0"
112
126
  href="page=9"
113
127
  id="lastPage-Previous"
128
+ rel={null}
129
+ target={null}
114
130
  >
115
131
  Previous
116
132
  </a>
@@ -122,6 +138,8 @@ exports[`Pagination Rendering Renders the UI snapshot correctly 2`] = `
122
138
  className="css-0"
123
139
  href="page=1"
124
140
  id="lastPage-1"
141
+ rel={null}
142
+ target={null}
125
143
  >
126
144
  1
127
145
  </a>
@@ -136,6 +154,8 @@ exports[`Pagination Rendering Renders the UI snapshot correctly 2`] = `
136
154
  className="css-0"
137
155
  href="page=6"
138
156
  id="lastPage-6"
157
+ rel={null}
158
+ target={null}
139
159
  >
140
160
  6
141
161
  </a>
@@ -147,6 +167,8 @@ exports[`Pagination Rendering Renders the UI snapshot correctly 2`] = `
147
167
  className="css-0"
148
168
  href="page=7"
149
169
  id="lastPage-7"
170
+ rel={null}
171
+ target={null}
150
172
  >
151
173
  7
152
174
  </a>
@@ -158,6 +180,8 @@ exports[`Pagination Rendering Renders the UI snapshot correctly 2`] = `
158
180
  className="css-0"
159
181
  href="page=8"
160
182
  id="lastPage-8"
183
+ rel={null}
184
+ target={null}
161
185
  >
162
186
  8
163
187
  </a>
@@ -169,6 +193,8 @@ exports[`Pagination Rendering Renders the UI snapshot correctly 2`] = `
169
193
  className="css-0"
170
194
  href="page=9"
171
195
  id="lastPage-9"
196
+ rel={null}
197
+ target={null}
172
198
  >
173
199
  9
174
200
  </a>
@@ -180,6 +206,8 @@ exports[`Pagination Rendering Renders the UI snapshot correctly 2`] = `
180
206
  className="css-1858g8z"
181
207
  href="page=10"
182
208
  id="lastPage-10"
209
+ rel={null}
210
+ target={null}
183
211
  >
184
212
  10
185
213
  </a>
@@ -205,6 +233,8 @@ exports[`Pagination Rendering Renders the UI snapshot correctly 3`] = `
205
233
  className="css-0"
206
234
  href="page=4"
207
235
  id="middlePage-Previous"
236
+ rel={null}
237
+ target={null}
208
238
  >
209
239
  Previous
210
240
  </a>
@@ -216,6 +246,8 @@ exports[`Pagination Rendering Renders the UI snapshot correctly 3`] = `
216
246
  className="css-0"
217
247
  href="page=1"
218
248
  id="middlePage-1"
249
+ rel={null}
250
+ target={null}
219
251
  >
220
252
  1
221
253
  </a>
@@ -230,6 +262,8 @@ exports[`Pagination Rendering Renders the UI snapshot correctly 3`] = `
230
262
  className="css-0"
231
263
  href="page=4"
232
264
  id="middlePage-4"
265
+ rel={null}
266
+ target={null}
233
267
  >
234
268
  4
235
269
  </a>
@@ -241,6 +275,8 @@ exports[`Pagination Rendering Renders the UI snapshot correctly 3`] = `
241
275
  className="css-1858g8z"
242
276
  href="page=5"
243
277
  id="middlePage-5"
278
+ rel={null}
279
+ target={null}
244
280
  >
245
281
  5
246
282
  </a>
@@ -252,6 +288,8 @@ exports[`Pagination Rendering Renders the UI snapshot correctly 3`] = `
252
288
  className="css-0"
253
289
  href="page=6"
254
290
  id="middlePage-6"
291
+ rel={null}
292
+ target={null}
255
293
  >
256
294
  6
257
295
  </a>
@@ -266,6 +304,8 @@ exports[`Pagination Rendering Renders the UI snapshot correctly 3`] = `
266
304
  className="css-0"
267
305
  href="page=10"
268
306
  id="middlePage-10"
307
+ rel={null}
308
+ target={null}
269
309
  >
270
310
  10
271
311
  </a>
@@ -276,6 +316,8 @@ exports[`Pagination Rendering Renders the UI snapshot correctly 3`] = `
276
316
  className="css-0"
277
317
  href="page=6"
278
318
  id="middlePage-Next"
319
+ rel={null}
320
+ target={null}
279
321
  >
280
322
  Next
281
323
  </a>
@@ -25,8 +25,7 @@ import { GridGaps } from "../Grid/GridTypes";
25
25
  parameters={{
26
26
  design: {
27
27
  type: "figma",
28
- url:
29
- "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Main?node-id=37638%3A23842",
28
+ url: "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Main?node-id=37638%3A23842",
30
29
  },
31
30
  jest: ["ProgressIndicator.test.tsx"],
32
31
  }}
@@ -40,7 +39,7 @@ import { GridGaps } from "../Grid/GridTypes";
40
39
  | Component Version | DS Version |
41
40
  | ----------------- | ---------- |
42
41
  | Added | `0.25.4` |
43
- | Latest | `0.25.4` |
42
+ | Latest | `0.25.8` |
44
43
 
45
44
  <Description of={ProgressIndicator} />
46
45
 
@@ -311,7 +311,7 @@ function SearchBarValueExample() {
311
311
  };
312
312
  const onSubmit = (event) => {
313
313
  event.preventDefault();
314
- console.log(`onSubmit Select value: ${event.target.searchName.value}`);
314
+ console.log(`onSubmit Select value: ${event.target.selectName.value}`);
315
315
  console.log(`onSubmit TextInput value ${event.target.textInputName.value}`);
316
316
  };
317
317
  return (