@nypl/design-system-react-components 0.25.11 → 0.25.12

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 (96) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +4 -16
  3. package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +1 -0
  4. package/dist/components/Icons/IconTypes.d.ts +9 -7
  5. package/dist/components/Logo/LogoSvgs.d.ts +6 -0
  6. package/dist/components/Logo/LogoTypes.d.ts +6 -0
  7. package/dist/components/Pagination/Pagination.d.ts +6 -2
  8. package/dist/components/SearchBar/SearchBar.d.ts +1 -1
  9. package/dist/components/Template/Template.d.ts +1 -1
  10. package/dist/design-system-react-components.cjs.development.js +947 -438
  11. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  12. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  13. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  14. package/dist/design-system-react-components.esm.js +948 -439
  15. package/dist/design-system-react-components.esm.js.map +1 -1
  16. package/dist/styles.css +1 -1
  17. package/dist/theme/components/breadcrumb.d.ts +3 -0
  18. package/dist/theme/components/checkbox.d.ts +0 -2
  19. package/dist/theme/components/fieldset.d.ts +2 -0
  20. package/dist/theme/components/global.d.ts +15 -14
  21. package/dist/theme/components/globalMixins.d.ts +8 -8
  22. package/dist/theme/components/list.d.ts +6 -0
  23. package/dist/theme/components/notification.d.ts +3 -0
  24. package/dist/theme/components/radio.d.ts +3 -2
  25. package/dist/theme/components/select.d.ts +2 -9
  26. package/dist/theme/components/slider.d.ts +8 -4
  27. package/dist/theme/components/textInput.d.ts +8 -12
  28. package/dist/theme/components/toggle.d.ts +6 -2
  29. package/dist/theme/foundations/global.d.ts +31 -3
  30. package/dist/utils/utils.d.ts +10 -0
  31. package/package.json +1 -1
  32. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +18 -1
  33. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +10 -0
  34. package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +1 -0
  35. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +99 -0
  36. package/src/components/Checkbox/Checkbox.stories.mdx +1 -1
  37. package/src/components/Checkbox/Checkbox.tsx +1 -0
  38. package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +6 -6
  39. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +18 -18
  40. package/src/components/Fieldset/Fieldset.stories.mdx +1 -1
  41. package/src/components/Icons/Icon.stories.mdx +1 -1
  42. package/src/components/Icons/IconTypes.tsx +8 -6
  43. package/src/components/List/List.stories.mdx +1 -1
  44. package/src/components/Logo/Logo.stories.mdx +1 -1
  45. package/src/components/Logo/LogoSvgs.tsx +12 -0
  46. package/src/components/Logo/LogoTypes.tsx +6 -0
  47. package/src/components/Notification/Notification.stories.mdx +6 -1
  48. package/src/components/Notification/Notification.test.tsx +20 -9
  49. package/src/components/Notification/Notification.tsx +6 -4
  50. package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +103 -8
  51. package/src/components/Pagination/Pagination.stories.mdx +54 -12
  52. package/src/components/Pagination/Pagination.test.tsx +63 -5
  53. package/src/components/Pagination/Pagination.tsx +45 -23
  54. package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +3 -3
  55. package/src/components/Radio/Radio.stories.mdx +1 -1
  56. package/src/components/Radio/Radio.tsx +1 -0
  57. package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +5 -5
  58. package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +18 -18
  59. package/src/components/SearchBar/SearchBar.Test.tsx +20 -2
  60. package/src/components/SearchBar/SearchBar.stories.mdx +4 -4
  61. package/src/components/SearchBar/SearchBar.tsx +3 -2
  62. package/src/components/Select/Select.stories.mdx +1 -1
  63. package/src/components/Slider/Slider.stories.mdx +1 -1
  64. package/src/components/Slider/Slider.tsx +4 -1
  65. package/src/components/StyleGuide/Bidirectionality.stories.mdx +4 -4
  66. package/src/components/StyleGuide/Colors.stories.mdx +33 -18
  67. package/src/components/Template/Template.stories.mdx +1 -1
  68. package/src/components/Template/Template.tsx +2 -6
  69. package/src/components/Template/__snapshots__/Template.test.tsx.snap +2 -2
  70. package/src/components/Toggle/Toggle.stories.mdx +1 -1
  71. package/src/components/Toggle/Toggle.tsx +2 -1
  72. package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +4 -4
  73. package/src/docs/Chakra.stories.mdx +1 -1
  74. package/src/styles/base/_place-holder.scss +2 -0
  75. package/src/styles.scss +0 -2
  76. package/src/theme/components/breadcrumb.ts +4 -0
  77. package/src/theme/components/checkbox.ts +3 -7
  78. package/src/theme/components/fieldset.ts +2 -0
  79. package/src/theme/components/global.ts +18 -15
  80. package/src/theme/components/globalMixins.ts +8 -8
  81. package/src/theme/components/list.ts +4 -0
  82. package/src/theme/components/notification.ts +3 -0
  83. package/src/theme/components/radio.ts +3 -6
  84. package/src/theme/components/select.ts +3 -3
  85. package/src/theme/components/slider.ts +12 -9
  86. package/src/theme/components/textInput.ts +2 -2
  87. package/src/theme/components/toggle.ts +41 -37
  88. package/src/theme/foundations/colors.ts +19 -12
  89. package/src/theme/foundations/global.ts +17 -5
  90. package/src/theme/foundations/typography.ts +1 -1
  91. package/src/utils/componentCategories.ts +1 -1
  92. package/src/utils/utils.ts +28 -0
  93. package/dist/components/Pagination/Pagination.stories.d.ts +0 -13
  94. package/src/components/Pagination/Pagination.stories.tsx +0 -54
  95. package/src/styles/base/_03-base.scss +0 -25
  96. package/src/styles/base/_04-focus.scss +0 -22
@@ -20,7 +20,7 @@ exports[`Checkbox renders the UI snapshot correctly 1`] = `
20
20
  id="column"
21
21
  >
22
22
  <label
23
- className="chakra-checkbox css-1uiwwan"
23
+ className="chakra-checkbox css-g8du1g"
24
24
  onClick={[Function]}
25
25
  >
26
26
  <input
@@ -81,7 +81,7 @@ exports[`Checkbox renders the UI snapshot correctly 1`] = `
81
81
  </span>
82
82
  </label>
83
83
  <label
84
- className="chakra-checkbox css-1uiwwan"
84
+ className="chakra-checkbox css-g8du1g"
85
85
  onClick={[Function]}
86
86
  >
87
87
  <input
@@ -165,7 +165,7 @@ exports[`Checkbox renders the UI snapshot correctly 2`] = `
165
165
  id="row"
166
166
  >
167
167
  <label
168
- className="chakra-checkbox css-1uiwwan"
168
+ className="chakra-checkbox css-g8du1g"
169
169
  onClick={[Function]}
170
170
  >
171
171
  <input
@@ -226,7 +226,7 @@ exports[`Checkbox renders the UI snapshot correctly 2`] = `
226
226
  </span>
227
227
  </label>
228
228
  <label
229
- className="chakra-checkbox css-1uiwwan"
229
+ className="chakra-checkbox css-g8du1g"
230
230
  onClick={[Function]}
231
231
  >
232
232
  <input
@@ -310,7 +310,7 @@ exports[`Checkbox renders the UI snapshot correctly 3`] = `
310
310
  id="noLabel"
311
311
  >
312
312
  <label
313
- className="chakra-checkbox css-1uiwwan"
313
+ className="chakra-checkbox css-g8du1g"
314
314
  onClick={[Function]}
315
315
  >
316
316
  <input
@@ -371,7 +371,7 @@ exports[`Checkbox renders the UI snapshot correctly 3`] = `
371
371
  </span>
372
372
  </label>
373
373
  <label
374
- className="chakra-checkbox css-1uiwwan"
374
+ className="chakra-checkbox css-g8du1g"
375
375
  onClick={[Function]}
376
376
  >
377
377
  <input
@@ -455,7 +455,7 @@ exports[`Checkbox renders the UI snapshot correctly 4`] = `
455
455
  id="helperText"
456
456
  >
457
457
  <label
458
- className="chakra-checkbox css-1uiwwan"
458
+ className="chakra-checkbox css-g8du1g"
459
459
  onClick={[Function]}
460
460
  >
461
461
  <input
@@ -516,7 +516,7 @@ exports[`Checkbox renders the UI snapshot correctly 4`] = `
516
516
  </span>
517
517
  </label>
518
518
  <label
519
- className="chakra-checkbox css-1uiwwan"
519
+ className="chakra-checkbox css-g8du1g"
520
520
  onClick={[Function]}
521
521
  >
522
522
  <input
@@ -616,7 +616,7 @@ exports[`Checkbox renders the UI snapshot correctly 5`] = `
616
616
  id="invalidText"
617
617
  >
618
618
  <label
619
- className="chakra-checkbox css-1uiwwan"
619
+ className="chakra-checkbox css-g8du1g"
620
620
  onClick={[Function]}
621
621
  >
622
622
  <input
@@ -677,7 +677,7 @@ exports[`Checkbox renders the UI snapshot correctly 5`] = `
677
677
  </span>
678
678
  </label>
679
679
  <label
680
- className="chakra-checkbox css-1uiwwan"
680
+ className="chakra-checkbox css-g8du1g"
681
681
  onClick={[Function]}
682
682
  >
683
683
  <input
@@ -756,7 +756,7 @@ exports[`Checkbox renders the UI snapshot correctly 6`] = `
756
756
  id="optReq"
757
757
  >
758
758
  <label
759
- className="chakra-checkbox css-1uiwwan"
759
+ className="chakra-checkbox css-g8du1g"
760
760
  onClick={[Function]}
761
761
  >
762
762
  <input
@@ -817,7 +817,7 @@ exports[`Checkbox renders the UI snapshot correctly 6`] = `
817
817
  </span>
818
818
  </label>
819
819
  <label
820
- className="chakra-checkbox css-1uiwwan"
820
+ className="chakra-checkbox css-g8du1g"
821
821
  onClick={[Function]}
822
822
  >
823
823
  <input
@@ -901,7 +901,7 @@ exports[`Checkbox renders the UI snapshot correctly 7`] = `
901
901
  id="required"
902
902
  >
903
903
  <label
904
- className="chakra-checkbox css-1uiwwan"
904
+ className="chakra-checkbox css-g8du1g"
905
905
  onClick={[Function]}
906
906
  >
907
907
  <input
@@ -962,7 +962,7 @@ exports[`Checkbox renders the UI snapshot correctly 7`] = `
962
962
  </span>
963
963
  </label>
964
964
  <label
965
- className="chakra-checkbox css-1uiwwan"
965
+ className="chakra-checkbox css-g8du1g"
966
966
  onClick={[Function]}
967
967
  >
968
968
  <input
@@ -1046,7 +1046,7 @@ exports[`Checkbox renders the UI snapshot correctly 8`] = `
1046
1046
  id="invalid"
1047
1047
  >
1048
1048
  <label
1049
- className="chakra-checkbox css-1uiwwan"
1049
+ className="chakra-checkbox css-g8du1g"
1050
1050
  data-invalid=""
1051
1051
  onClick={[Function]}
1052
1052
  >
@@ -1110,7 +1110,7 @@ exports[`Checkbox renders the UI snapshot correctly 8`] = `
1110
1110
  </span>
1111
1111
  </label>
1112
1112
  <label
1113
- className="chakra-checkbox css-1uiwwan"
1113
+ className="chakra-checkbox css-g8du1g"
1114
1114
  data-invalid=""
1115
1115
  onClick={[Function]}
1116
1116
  >
@@ -1197,7 +1197,7 @@ exports[`Checkbox renders the UI snapshot correctly 9`] = `
1197
1197
  id="disabled"
1198
1198
  >
1199
1199
  <label
1200
- className="chakra-checkbox css-1uiwwan"
1200
+ className="chakra-checkbox css-g8du1g"
1201
1201
  data-disabled=""
1202
1202
  onClick={[Function]}
1203
1203
  >
@@ -1261,7 +1261,7 @@ exports[`Checkbox renders the UI snapshot correctly 9`] = `
1261
1261
  </span>
1262
1262
  </label>
1263
1263
  <label
1264
- className="chakra-checkbox css-1uiwwan"
1264
+ className="chakra-checkbox css-g8du1g"
1265
1265
  data-disabled=""
1266
1266
  onClick={[Function]}
1267
1267
  >
@@ -39,7 +39,7 @@ import DSProvider from "../../theme/provider";
39
39
  | Component Version | DS Version |
40
40
  | ----------------- | ---------- |
41
41
  | Added | `0.25.3` |
42
- | Latest | `0.25.10` |
42
+ | Latest | `0.25.12` |
43
43
 
44
44
  <Description of={Fieldset} />
45
45
 
@@ -89,7 +89,7 @@ export const rotationEnumValues = getStorybookEnumValues(
89
89
  | Component Version | DS Version |
90
90
  | ----------------- | ---------- |
91
91
  | Added | `0.0.4` |
92
- | Latest | `0.25.11` |
92
+ | Latest | `0.25.12` |
93
93
 
94
94
  <Description of={Icon} />
95
95
 
@@ -22,19 +22,21 @@ export enum IconColors {
22
22
  UiWhite = "ui.white",
23
23
  BrandPrimary = "brand.primary",
24
24
  BrandSecondary = "brand.secondary",
25
- SectionWhatsOnPrimary = "section.whats-on.primary",
26
- SectionWhatsOnSecondary = "section.whats-on.secondary",
25
+ SectionBlogsPrimary = "section.blogs.primary",
26
+ SectionBlogsSecondary = "section.blogs.secondary",
27
27
  SectionBooksAndMorePrimary = "section.books-and-more.primary",
28
28
  SectionBooksAndMoreSecondary = "section.books-and-more.secondary",
29
- SectionResearchPrimary = "section.research.primary",
30
- SectionResearchSecondary = "section.research.secondary",
29
+ SectionEducationPrimary = "section.education.primary",
30
+ SectionEducationSecondary = "section.education.secondary",
31
31
  SectionLocationsPrimary = "section.locations.primary",
32
32
  SectionLocationsSecondary = "section.locations.secondary",
33
- SectionBlogsPrimary = "section.blogs.primary",
34
- SectionBlogsSecondary = "section.blogs.secondary",
33
+ SectionResearchPrimary = "section.research.primary",
34
+ SectionResearchSecondary = "section.research.secondary",
35
35
  SectionResearchLibraryLpa = "section.research-library.lpa",
36
36
  SectionResearchLibrarySchomburg = "section.research-library.schomburg",
37
37
  SectionResearchLibrarySchwartzman = "section.research-library.schwartzman",
38
+ SectionWhatsOnPrimary = "section.whats-on.primary",
39
+ SectionWhatsOnSecondary = "section.whats-on.secondary",
38
40
  }
39
41
 
40
42
  export enum IconSizes {
@@ -51,7 +51,7 @@ export const enumValues = getStorybookEnumValues(ListTypes, "ListTypes");
51
51
  | Component Version | DS Version |
52
52
  | ----------------- | ---------- |
53
53
  | Added | `0.7.0` |
54
- | Latest | `0.25.11` |
54
+ | Latest | `0.25.12` |
55
55
 
56
56
  <Description of={List} />
57
57
 
@@ -57,7 +57,7 @@ export const sizesEnumValues = getStorybookEnumValues(LogoSizes, "LogoSizes");
57
57
  | Component Version | DS Version |
58
58
  | ----------------- | ---------- |
59
59
  | Added | `0.25.9` |
60
- | Latest | `0.25.11` |
60
+ | Latest | `0.25.12` |
61
61
 
62
62
  <Description of={Logo} />
63
63
 
@@ -3,6 +3,8 @@ import logo_bpl_black from "../../../icons/svg/logo_bpl_black.svg";
3
3
  import logo_bpl_white from "../../../icons/svg/logo_bpl_white.svg";
4
4
  import logo_clever_color from "../../../icons/svg/logo_clever_color.svg";
5
5
  import logo_clever_white from "../../../icons/svg/logo_clever_white.svg";
6
+ import logo_firstbook_color from "../../../icons/svg/logo_firstbook_color.svg";
7
+ import logo_firstbook_color_negative from "../../../icons/svg/logo_firstbook_color_negative.svg";
6
8
  import logo_lpa_color from "../../../icons/svg/logo_lpa_color.svg";
7
9
  import logo_lpa_black from "../../../icons/svg/logo_lpa_black.svg";
8
10
  import logo_lpa_white from "../../../icons/svg/logo_lpa_white.svg";
@@ -12,6 +14,10 @@ import logo_nypl_full_black from "../../../icons/svg/logo_nypl_full_black.svg";
12
14
  import logo_nypl_full_white from "../../../icons/svg/logo_nypl_full_white.svg";
13
15
  import logo_nypl_lion_black from "../../../icons/svg/logo_nypl_lion_black.svg";
14
16
  import logo_nypl_lion_white from "../../../icons/svg/logo_nypl_lion_white.svg";
17
+ import logo_openebooks_color from "../../../icons/svg/logo_openebooks_color.svg";
18
+ import logo_openebooks_negative from "../../../icons/svg/logo_openebooks_negative.svg";
19
+ import logo_openebooks_wtext_color from "../../../icons/svg/logo_openebooks_wtext_color.svg";
20
+ import logo_openebooks_wtext_negative from "../../../icons/svg/logo_openebooks_wtext_negative.svg";
15
21
  import logo_qpl_alt_black from "../../../icons/svg/logo_qpl_alt_black.svg";
16
22
  import logo_qpl_alt_white from "../../../icons/svg/logo_qpl_alt_white.svg";
17
23
  import logo_qpl_black from "../../../icons/svg/logo_qpl_black.svg";
@@ -36,6 +42,8 @@ export default {
36
42
  logo_bpl_white,
37
43
  logo_clever_color,
38
44
  logo_clever_white,
45
+ logo_firstbook_color,
46
+ logo_firstbook_color_negative,
39
47
  logo_lpa_black,
40
48
  logo_lpa_color,
41
49
  logo_lpa_white,
@@ -45,6 +53,10 @@ export default {
45
53
  logo_nypl_full_white,
46
54
  logo_nypl_lion_black,
47
55
  logo_nypl_lion_white,
56
+ logo_openebooks_color,
57
+ logo_openebooks_negative,
58
+ logo_openebooks_wtext_color,
59
+ logo_openebooks_wtext_negative,
48
60
  logo_qpl_alt_black,
49
61
  logo_qpl_alt_white,
50
62
  logo_qpl_black,
@@ -18,6 +18,8 @@ export enum LogoNames {
18
18
  BrooklynPublicLibraryWhite = "logo_bpl_white",
19
19
  CleverColor = "logo_clever_color",
20
20
  CleverWhite = "logo_clever_white",
21
+ FirstBookColor = "logo_firstbook_color",
22
+ FirstBookColorNegative = "logo_firstbook_color_negative",
21
23
  LPAColor = "logo_lpa_color",
22
24
  LPABlack = "logo_lpa_black",
23
25
  LPAWhite = "logo_lpa_white",
@@ -27,6 +29,10 @@ export enum LogoNames {
27
29
  NYPLWhite = "logo_nypl_full_white",
28
30
  NYPLLionBlack = "logo_nypl_lion_black",
29
31
  NYPLLionWhite = "logo_nypl_lion_white",
32
+ OpenEBooksColor = "logo_openebooks_color",
33
+ OpenEBooksNegative = "logo_openebooks_negative",
34
+ OpenEBooksWithTextColor = "logo_openebooks_wtext_color",
35
+ OpenEBooksWithTextNegative = "logo_openebooks_wtext_negative",
30
36
  QueensPublicLibraryColor = "logo_qpl_color",
31
37
  QueensPublicLibraryBlack = "logo_qpl_black",
32
38
  QueensPublicLibraryWhite = "logo_qpl_white",
@@ -59,7 +59,7 @@ export const enumValues = getStorybookEnumValues(
59
59
  | Component Version | DS Version |
60
60
  | ----------------- | ---------- |
61
61
  | Added | `0.23.2` |
62
- | Latest | `0.25.11` |
62
+ | Latest | `0.25.12` |
63
63
 
64
64
  <Description of={Notification} />
65
65
 
@@ -118,6 +118,11 @@ be rendered inside other landmark elements such as the `header` and `footer`
118
118
  landmark elements. Adding a `Notification` component inside an HTML `main` landmark
119
119
  element is acceptable.
120
120
 
121
+ Icons rendered in the `Notification` component are decorative by default which
122
+ means that they are hidden to screen readers. Since the "X" close icon inside the
123
+ dismissible button is decorative and because there is no discernible text inside
124
+ the button, an `aria-label` attribute is added to the button.
125
+
121
126
  ## Variants
122
127
 
123
128
  ### With NotificationHeading
@@ -77,8 +77,12 @@ describe("Notification", () => {
77
77
  });
78
78
 
79
79
  it("renders with an Icon", () => {
80
- // The Icon's role is "img".
81
- expect(screen.queryByRole("img")).toBeInTheDocument();
80
+ // Since the icon has aria-hidden set to true, we can't get it
81
+ // by its "img" role.
82
+ const icon = utils.container.querySelector(
83
+ "#notificationID-notification-icon"
84
+ );
85
+ expect(icon).toBeInTheDocument();
82
86
  });
83
87
 
84
88
  it("does not render an Icon", () => {
@@ -90,8 +94,10 @@ describe("Notification", () => {
90
94
  showIcon={false}
91
95
  />
92
96
  );
93
- // The Icon's role is "img".
94
- expect(screen.queryByRole("img")).not.toBeInTheDocument();
97
+ const icon = utils.container.querySelector(
98
+ "#notificationID-notification-icon"
99
+ );
100
+ expect(icon).not.toBeInTheDocument();
95
101
  });
96
102
 
97
103
  it("renders a custom Icon component", () => {
@@ -111,7 +117,11 @@ describe("Notification", () => {
111
117
  notificationHeading="Notification Heading"
112
118
  />
113
119
  );
114
- expect(utils.container.querySelector(".custom-icon")).toBeInTheDocument();
120
+
121
+ const customIcon = utils.container.querySelector(
122
+ "#notificationID-custom-notification-icon"
123
+ );
124
+ expect(customIcon).toBeInTheDocument();
115
125
  });
116
126
 
117
127
  it("renders the announcement Notification type", () => {
@@ -163,14 +173,15 @@ describe("Notification", () => {
163
173
  notificationType={NotificationTypes.Standard}
164
174
  />
165
175
  );
166
- const icons = screen.queryAllByRole("img");
167
176
 
168
- expect(icons).toHaveLength(2);
169
- expect(screen.getByTitle("Notification standard icon")).toBeInTheDocument();
177
+ const dismissibleIcon = utils.container.querySelector(
178
+ "#notificationID-dismissible-notification-icon"
179
+ );
180
+ expect(dismissibleIcon).toBeInTheDocument();
170
181
  expect(screen.getByTitle("Notification close icon")).toBeInTheDocument();
171
182
  });
172
183
 
173
- it.skip("renders the UI snapshot correctly", () => {
184
+ it("renders the UI snapshot correctly", () => {
174
185
  const standard = renderer
175
186
  .create(
176
187
  <Notification
@@ -124,7 +124,6 @@ export default function Notification(props: NotificationProps) {
124
124
  const iconElement = () => {
125
125
  const baseIconProps = {
126
126
  additionalStyles: styles.icon,
127
- decorative: false,
128
127
  size: IconSizes.Large,
129
128
  };
130
129
  // If the icon should not display, return null.
@@ -164,13 +163,16 @@ export default function Notification(props: NotificationProps) {
164
163
  };
165
164
  const dismissibleButton = dismissible && (
166
165
  <Button
166
+ additionalStyles={styles.dismissibleButton}
167
+ attributes={{
168
+ "aria-label": "Close the notification",
169
+ }}
167
170
  buttonType={ButtonTypes.Link}
171
+ id={`${id}-notification-dismissible-button`}
168
172
  onClick={handleClose}
169
- additionalStyles={styles.dismissibleButton}
170
173
  >
171
174
  <Icon
172
- decorative={false}
173
- id={`${id}-notification-dismissible-icon`}
175
+ id={`${id}-dismissible-notification-icon`}
174
176
  name={IconNames.Close}
175
177
  size={IconSizes.Large}
176
178
  title="Notification close icon"
@@ -13,12 +13,12 @@ exports[`Notification renders the UI snapshot correctly 1`] = `
13
13
  className="css-0"
14
14
  >
15
15
  <svg
16
- aria-hidden={false}
16
+ aria-hidden={true}
17
17
  className="chakra-icon css-onkibi"
18
18
  focusable={false}
19
19
  id="notificationID1-notification-icon"
20
20
  role="img"
21
- title="alert_notification_important icon"
21
+ title="Notification standard icon"
22
22
  viewBox="0 0 24 24"
23
23
  >
24
24
  <g
@@ -77,12 +77,12 @@ exports[`Notification renders the UI snapshot correctly 2`] = `
77
77
  className="css-0"
78
78
  >
79
79
  <svg
80
- aria-hidden={false}
80
+ aria-hidden={true}
81
81
  className="chakra-icon css-onkibi"
82
82
  focusable={false}
83
83
  id="notificationID2-notification-icon"
84
84
  role="img"
85
- title="speaker_notes icon"
85
+ title="Notification announcement icon"
86
86
  viewBox="0 0 24 24"
87
87
  >
88
88
  <g
@@ -141,12 +141,12 @@ exports[`Notification renders the UI snapshot correctly 3`] = `
141
141
  className="css-0"
142
142
  >
143
143
  <svg
144
- aria-hidden={false}
144
+ aria-hidden={true}
145
145
  className="chakra-icon css-onkibi"
146
146
  focusable={false}
147
147
  id="notificationID3-notification-icon"
148
148
  role="img"
149
- title="error_filled icon"
149
+ title="Notification warning icon"
150
150
  viewBox="0 0 24 24"
151
151
  >
152
152
  <g
@@ -205,12 +205,12 @@ exports[`Notification renders the UI snapshot correctly 4`] = `
205
205
  className="css-0"
206
206
  >
207
207
  <svg
208
- aria-hidden={false}
208
+ aria-hidden={true}
209
209
  className="chakra-icon css-onkibi"
210
210
  focusable={false}
211
211
  id="notificationID4-notification-icon"
212
212
  role="img"
213
- title="alert_notification_important icon"
213
+ title="Notification standard icon"
214
214
  viewBox="0 0 24 24"
215
215
  >
216
216
  <g
@@ -299,3 +299,98 @@ exports[`Notification renders the UI snapshot correctly 6`] = `
299
299
  </div>
300
300
  </aside>
301
301
  `;
302
+
303
+ exports[`Notification renders the UI snapshot correctly 7`] = `
304
+ <aside
305
+ className="css-0"
306
+ data-type="standard"
307
+ id="notificationID7"
308
+ >
309
+ <div
310
+ className="css-0"
311
+ >
312
+ <div
313
+ className="css-0"
314
+ >
315
+ <svg
316
+ aria-hidden={true}
317
+ className="chakra-icon css-onkibi"
318
+ focusable={false}
319
+ id="notificationID7-notification-icon"
320
+ role="img"
321
+ title="Notification standard icon"
322
+ viewBox="0 0 24 24"
323
+ >
324
+ <g
325
+ stroke="currentColor"
326
+ strokeWidth="1.5"
327
+ >
328
+ <path
329
+ d="M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"
330
+ fill="none"
331
+ strokeLinecap="round"
332
+ />
333
+ <path
334
+ d="M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"
335
+ fill="currentColor"
336
+ strokeLinecap="round"
337
+ />
338
+ <circle
339
+ cx="12"
340
+ cy="12"
341
+ fill="none"
342
+ r="11.25"
343
+ strokeMiterlimit="10"
344
+ />
345
+ </g>
346
+ </svg>
347
+ <div
348
+ className="css-0"
349
+ >
350
+ Notification content.
351
+ </div>
352
+ </div>
353
+ </div>
354
+ <button
355
+ aria-label="Close the notification"
356
+ className="chakra-button css-0"
357
+ data-testid="button"
358
+ id="notificationID7-notification-dismissible-button"
359
+ onClick={[Function]}
360
+ type="button"
361
+ >
362
+ <svg
363
+ aria-hidden={true}
364
+ className="chakra-icon css-onkibi"
365
+ focusable={false}
366
+ id="notificationID7-dismissible-notification-icon"
367
+ role="img"
368
+ title="Notification close icon"
369
+ viewBox="0 0 24 24"
370
+ >
371
+ <g
372
+ stroke="currentColor"
373
+ strokeWidth="1.5"
374
+ >
375
+ <path
376
+ d="M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"
377
+ fill="none"
378
+ strokeLinecap="round"
379
+ />
380
+ <path
381
+ d="M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"
382
+ fill="currentColor"
383
+ strokeLinecap="round"
384
+ />
385
+ <circle
386
+ cx="12"
387
+ cy="12"
388
+ fill="none"
389
+ r="11.25"
390
+ strokeMiterlimit="10"
391
+ />
392
+ </g>
393
+ </svg>
394
+ </button>
395
+ </aside>
396
+ `;
@@ -1,3 +1,4 @@
1
+ import { useState } from "react";
1
2
  import {
2
3
  ArgsTable,
3
4
  Canvas,
@@ -8,9 +9,13 @@ import {
8
9
  import { withDesign } from "storybook-addon-designs";
9
10
  import { withQuery } from "@storybook/addon-queryparams";
10
11
 
12
+ import Button from "../Button/Button";
13
+ import DSProvider from "../../theme/provider";
11
14
  import Pagination from "./Pagination";
12
- import * as stories from "./Pagination.stories.tsx";
13
15
  import { getCategory } from "../../utils/componentCategories";
16
+ import { getStorybookHrefProps } from "../../utils/utils";
17
+
18
+ export const hrefProps = getStorybookHrefProps(10);
14
19
 
15
20
  <Meta
16
21
  title={getCategory("Pagination")}
@@ -25,6 +30,7 @@ import { getCategory } from "../../utils/componentCategories";
25
30
  }}
26
31
  argTypes={{
27
32
  className: { control: false },
33
+ currentPage: { control: false },
28
34
  getPageHref: { control: false },
29
35
  id: { control: false },
30
36
  initialPage: { table: { defaultValue: { summary: 1 } } },
@@ -37,7 +43,7 @@ import { getCategory } from "../../utils/componentCategories";
37
43
  | Component Version | DS Version |
38
44
  | ----------------- | ---------- |
39
45
  | Added | `0.0.10` |
40
- | Latest | `0.25.10` |
46
+ | Latest | `0.25.12` |
41
47
 
42
48
  <Description of={Pagination} />
43
49
 
@@ -73,14 +79,13 @@ const getPageHref = (selectedPage: number) => {
73
79
  name="Pagination with URL Updates"
74
80
  args={{
75
81
  className: undefined,
76
- getPageHref: undefined,
82
+ getPageHref: hrefProps.getPageHref,
77
83
  id: "pagination-id",
78
- initialPage: 1,
79
- onPageChange: undefined,
84
+ initialPage: hrefProps.computedCurrentPage || 1,
80
85
  pageCount: 10,
81
86
  }}
82
87
  >
83
- {(args) => stories.PaginationGetPageHref(args)}
88
+ {(args) => <Pagination {...args} />}
84
89
  </Story>
85
90
  </Canvas>
86
91
 
@@ -93,14 +98,14 @@ function passed as a prop and that the URL is updated whenever a page is
93
98
  changed. However, the optional `onPageChange` prop is available in case URL
94
99
  updating is not desired.
95
100
 
96
- In the following example, the `onPageChange` function gets the current page as
101
+ In the following example, the `onPageChange` function gets the selected page as
97
102
  its only function argument. This is computed internally in the `Pagination`
98
103
  component through its own state.
99
104
 
100
105
  ```tsx
101
106
  // Example in a search results page.
102
- const onPageChange = (currentPage: number) => {
103
- console.log(`Current page: ${currentPage}`);
107
+ const onPageChange = (selectedPage: number) => {
108
+ console.log(`Current page: ${selectedPage}`);
104
109
  // Do what you need to with the `currentPage` value.
105
110
  };
106
111
  ```
@@ -110,13 +115,50 @@ const onPageChange = (currentPage: number) => {
110
115
  name="Pagination with Unchanging URL"
111
116
  args={{
112
117
  className: undefined,
113
- getPageHref: undefined,
114
118
  id: "pagination-id-2",
115
119
  initialPage: 7,
116
- onPageChange: undefined,
120
+ onPageChange: (selectedPage) => {
121
+ console.log(`Current page: ${selectedPage}`);
122
+ },
117
123
  pageCount: 100,
118
124
  }}
119
125
  >
120
- {(args) => stories.PaginationOnPageChange(args)}
126
+ {(args) => <Pagination {...args} />}
121
127
  </Story>
122
128
  </Canvas>
129
+
130
+ ### Forcing a Page Change Programmatically
131
+
132
+ There may be circumstances when you want to programmatically force the page
133
+ number to change without the user explicitly requesting it (for example, if
134
+ you want a user to be brought back to page 1 after entering a new search term).
135
+ You can use the `currentPage` prop to do this. Note, the `currentPage` prop can
136
+ only be used with the client-side, unchanging URL version of the `Pagination`
137
+ component, and in combination with the `onPageChange` function.
138
+
139
+ The following example shows that the user can be brought to page 1 without clicking
140
+ on the `Pagination` component.
141
+
142
+ export function CurrentPagePaginationExample() {
143
+ const [page, setPage] = useState(1);
144
+ const handleClick = () => setPage(1);
145
+ const handleSelection = (selectedPage) => setPage(selectedPage);
146
+ return (
147
+ <>
148
+ <Pagination
149
+ pageCount={10}
150
+ currentPage={page}
151
+ onPageChange={(selectedPage) => handleSelection(selectedPage)}
152
+ />
153
+ <Button type="button" buttonType="primary" onClick={handleClick}>
154
+ Go to Page 1
155
+ </Button>
156
+ </>
157
+ );
158
+ }
159
+
160
+ <Canvas>
161
+ <DSProvider>
162
+ <CurrentPagePaginationExample />
163
+ </DSProvider>
164
+ </Canvas>