@nypl/design-system-react-components 0.25.5 → 0.25.6

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/index.d.ts CHANGED
@@ -39,6 +39,7 @@ export { default as Modal } from "./components/Modal/Modal";
39
39
  export { default as Notification } from "./components/Notification/Notification";
40
40
  export { NotificationTypes } from "./components/Notification/NotificationTypes";
41
41
  export { default as Pagination } from "./components/Pagination/Pagination";
42
+ export { default as ProgressIndicator } from "./components/ProgressIndicator/ProgressIndicator";
42
43
  export { default as Radio } from "./components/Radio/Radio";
43
44
  export { default as RadioGroup } from "./components/RadioGroup/RadioGroup";
44
45
  export { RadioGroupLayoutTypes } from "./components/RadioGroup/RadioGroupLayoutTypes";
@@ -47,6 +48,7 @@ export { default as Select } from "./components/Select/Select";
47
48
  export { default as SimpleGrid } from "./components/Grid/SimpleGrid";
48
49
  export { default as SkeletonLoader } from "./components/SkeletonLoader/SkeletonLoader";
49
50
  export { SkeletonLoaderImageRatios, SkeletonLoaderLayouts, } from "./components/SkeletonLoader/SkeletonLoaderTypes";
51
+ export { default as Slider } from "./components/Slider/Slider";
50
52
  export { default as StatusBadge } from "./components/StatusBadge/StatusBadge";
51
53
  export { StatusBadgeTypes } from "./components/StatusBadge/StatusBadgeTypes";
52
54
  export { Tabs, TabList, Tab, TabPanels, TabPanel, } from "./components/Tabs/Tabs";
@@ -73,6 +73,15 @@ declare const Breadcrumb: {
73
73
  };
74
74
  };
75
75
  variants: {
76
+ blogs: {
77
+ bg: string;
78
+ color: string;
79
+ a: {
80
+ _hover: {
81
+ color: string;
82
+ };
83
+ };
84
+ };
76
85
  booksAndMore: {
77
86
  bg: string;
78
87
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nypl/design-system-react-components",
3
- "version": "0.25.5",
3
+ "version": "0.25.6",
4
4
  "description": "Design System React Components",
5
5
  "repository": {
6
6
  "type": "git",
@@ -38,7 +38,7 @@ import { getCategory } from "../../utils/componentCategories";
38
38
  | Component Version | DS Version |
39
39
  | ----------------- | ---------- |
40
40
  | Added | `0.0.3` |
41
- | Latest | `0.25.4` |
41
+ | Latest | `0.25.6` |
42
42
 
43
43
  <Description of={Breadcrumbs} />
44
44
 
@@ -91,12 +91,12 @@ The `Breadcrumbs` component background color can be set using the `colorVariant`
91
91
  <Story
92
92
  name="Color Variations"
93
93
  args={{
94
- colorVariant: ColorVariants.BooksAndMore,
94
+ colorVariant: ColorVariants.Blogs,
95
95
  }}
96
96
  >
97
97
  {(args) => (
98
98
  <>
99
- <Heading level={HeadingLevels.Three}>Books and More</Heading>
99
+ <Heading level={HeadingLevels.Three}>Blogs</Heading>
100
100
  <Breadcrumbs
101
101
  breadcrumbsData={[
102
102
  { url: "#", text: "Parent" },
@@ -113,6 +113,23 @@ The `Breadcrumbs` component background color can be set using the `colorVariant`
113
113
  </Story>
114
114
  </Canvas>
115
115
 
116
+ <Canvas>
117
+ <DSProvider>
118
+ <Heading level={HeadingLevels.Three}>Books and More</Heading>
119
+ <Breadcrumbs
120
+ breadcrumbsData={[
121
+ { url: "#", text: "Parent" },
122
+ { url: "#", text: "Child" },
123
+ {
124
+ url: "#",
125
+ text: "Grandchild",
126
+ },
127
+ ]}
128
+ colorVariant={ColorVariants.BooksAndMore}
129
+ />
130
+ </DSProvider>
131
+ </Canvas>
132
+
116
133
  <Canvas>
117
134
  <DSProvider>
118
135
  <Heading level={HeadingLevels.Three}>Locations</Heading>
@@ -41,6 +41,15 @@ describe("Breadcrumbs Snapshot", () => {
41
41
  />
42
42
  )
43
43
  .toJSON();
44
+ const breadcrumbsBlogsVariant = renderer
45
+ .create(
46
+ <Breadcrumbs
47
+ breadcrumbsData={breadcrumbsData}
48
+ colorVariant={ColorVariants.Blogs}
49
+ id="breadcrumbs-test"
50
+ />
51
+ )
52
+ .toJSON();
44
53
  const breadcrumbsAdditionalStyles = renderer
45
54
  .create(
46
55
  <Breadcrumbs
@@ -55,6 +64,7 @@ describe("Breadcrumbs Snapshot", () => {
55
64
 
56
65
  expect(breadcrumbsSnapshot).toMatchSnapshot();
57
66
  expect(breadcrumbsVariantColor).toMatchSnapshot();
67
+ expect(breadcrumbsBlogsVariant).toMatchSnapshot();
58
68
  expect(breadcrumbsAdditionalStyles).toMatchSnapshot();
59
69
  });
60
70
  });
@@ -1,4 +1,5 @@
1
1
  export enum ColorVariants {
2
+ Blogs = "blogs",
2
3
  BooksAndMore = "booksAndMore",
3
4
  Locations = "locations",
4
5
  Research = "research",
@@ -199,6 +199,105 @@ exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 2`] = `
199
199
  `;
200
200
 
201
201
  exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 3`] = `
202
+ <nav
203
+ aria-label="breadcrumb"
204
+ className="chakra-breadcrumb css-0"
205
+ id="breadcrumbs-test"
206
+ >
207
+ <ol
208
+ className="chakra-breadcrumb__list css-0"
209
+ >
210
+ <li
211
+ className="chakra-breadcrumb__list-item css-18biwo"
212
+ >
213
+ <a
214
+ className="chakra-breadcrumb__link css-0"
215
+ href="#string1"
216
+ >
217
+ <span
218
+ className="breadcrumb-label"
219
+ >
220
+ string1
221
+ </span>
222
+ </a>
223
+ <span
224
+ className="css-t4q1nq"
225
+ role="presentation"
226
+ >
227
+ /
228
+ </span>
229
+ </li>
230
+ <li
231
+ className="chakra-breadcrumb__list-item css-18biwo"
232
+ >
233
+ <a
234
+ className="chakra-breadcrumb__link css-0"
235
+ href="#string2"
236
+ >
237
+ <svg
238
+ aria-hidden={true}
239
+ className="chakra-icon breadcrumbs-icon css-onkibi"
240
+ focusable={false}
241
+ id="breadcrumbs-test__backarrow"
242
+ role="img"
243
+ title="arrow icon"
244
+ viewBox="0 0 24 24"
245
+ >
246
+ <g
247
+ stroke="currentColor"
248
+ strokeWidth="1.5"
249
+ >
250
+ <path
251
+ d="M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"
252
+ fill="none"
253
+ strokeLinecap="round"
254
+ />
255
+ <path
256
+ d="M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"
257
+ fill="currentColor"
258
+ strokeLinecap="round"
259
+ />
260
+ <circle
261
+ cx="12"
262
+ cy="12"
263
+ fill="none"
264
+ r="11.25"
265
+ strokeMiterlimit="10"
266
+ />
267
+ </g>
268
+ </svg>
269
+ <span
270
+ className="breadcrumb-label"
271
+ >
272
+ string2
273
+ </span>
274
+ </a>
275
+ <span
276
+ className="css-t4q1nq"
277
+ role="presentation"
278
+ >
279
+ /
280
+ </span>
281
+ </li>
282
+ <li
283
+ className="chakra-breadcrumb__list-item css-18biwo"
284
+ >
285
+ <span
286
+ aria-current="page"
287
+ className="chakra-breadcrumb__link css-0"
288
+ >
289
+ <span
290
+ className="breadcrumb-label"
291
+ >
292
+ string3
293
+ </span>
294
+ </span>
295
+ </li>
296
+ </ol>
297
+ </nav>
298
+ `;
299
+
300
+ exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 4`] = `
202
301
  <nav
203
302
  aria-label="breadcrumb"
204
303
  className="chakra-breadcrumb css-1f2fw9u"
@@ -35,13 +35,13 @@ describe("SearchBar Accessibility", () => {
35
35
  it("passes axe accessibility test", async () => {
36
36
  const { container } = render(
37
37
  <SearchBar
38
+ helperErrorText={helperErrorText}
38
39
  id="id"
40
+ invalidText={invalidText}
39
41
  labelText="Searchbar"
40
42
  onSubmit={jest.fn()}
41
43
  selectProps={selectProps}
42
44
  textInputProps={textInputProps}
43
- helperErrorText={helperErrorText}
44
- invalidText={invalidText}
45
45
  />
46
46
  );
47
47
  expect(await axe(container)).toHaveNoViolations();
@@ -55,11 +55,11 @@ describe("SearchBar", () => {
55
55
  it("renders the basic form", () => {
56
56
  render(
57
57
  <SearchBar
58
+ helperErrorText={helperErrorText}
58
59
  id="id"
59
60
  labelText="searchbar"
60
61
  onSubmit={searchBarSubmit}
61
62
  textInputProps={textInputProps}
62
- helperErrorText={helperErrorText}
63
63
  />
64
64
  );
65
65
  expect(screen.getByRole("search")).toBeInTheDocument();
@@ -74,12 +74,12 @@ describe("SearchBar", () => {
74
74
  it("renders an optional Select component", () => {
75
75
  render(
76
76
  <SearchBar
77
+ helperErrorText={helperErrorText}
77
78
  id="id"
78
79
  labelText="searchbar"
79
80
  onSubmit={searchBarSubmit}
80
81
  selectProps={selectProps}
81
82
  textInputProps={textInputProps}
82
- helperErrorText={helperErrorText}
83
83
  />
84
84
  );
85
85
  expect(screen.getByRole("combobox")).toBeInTheDocument();
@@ -89,14 +89,14 @@ describe("SearchBar", () => {
89
89
  it("renders the invalid text in the invalid state", () => {
90
90
  render(
91
91
  <SearchBar
92
+ helperErrorText={helperErrorText}
92
93
  id="id"
94
+ invalidText={invalidText}
95
+ isInvalid
93
96
  labelText="searchbar"
94
97
  onSubmit={searchBarSubmit}
95
98
  selectProps={selectProps}
96
99
  textInputProps={textInputProps}
97
- helperErrorText={helperErrorText}
98
- invalidText={invalidText}
99
- isInvalid
100
100
  />
101
101
  );
102
102
  expect(screen.getByText(invalidText)).toBeInTheDocument();
@@ -106,14 +106,14 @@ describe("SearchBar", () => {
106
106
  it("does not render the default invalid text from the Select or TextInput components", () => {
107
107
  render(
108
108
  <SearchBar
109
+ helperErrorText={helperErrorText}
109
110
  id="id"
111
+ invalidText={invalidText}
112
+ isInvalid
110
113
  labelText="searchbar"
111
114
  onSubmit={searchBarSubmit}
112
115
  selectProps={selectProps}
113
116
  textInputProps={textInputProps}
114
- helperErrorText={helperErrorText}
115
- invalidText={invalidText}
116
- isInvalid
117
117
  />
118
118
  );
119
119
  expect(
@@ -124,12 +124,12 @@ describe("SearchBar", () => {
124
124
  it("calls the callback function on submit ", () => {
125
125
  render(
126
126
  <SearchBar
127
- labelText="searchBar"
127
+ helperErrorText={helperErrorText}
128
128
  id="id"
129
+ labelText="searchBar"
129
130
  onSubmit={searchBarSubmit}
130
131
  selectProps={selectProps}
131
132
  textInputProps={textInputProps}
132
- helperErrorText={helperErrorText}
133
133
  />
134
134
  );
135
135
  expect(searchBarSubmit).toHaveBeenCalledTimes(0);
@@ -139,34 +139,65 @@ describe("SearchBar", () => {
139
139
  expect(buttonCallback).toHaveBeenCalledTimes(1);
140
140
  });
141
141
 
142
+ it("Renders 'required' in the placeholder text", () => {
143
+ const { rerender } = render(
144
+ <SearchBar
145
+ id="requiredState"
146
+ isDisabled
147
+ isRequired
148
+ labelText="searchbar"
149
+ onSubmit={jest.fn()}
150
+ textInputProps={textInputProps}
151
+ />
152
+ );
153
+
154
+ expect(
155
+ screen.getByPlaceholderText("Item Search (Required)")
156
+ ).not.toBeInTheDocument();
157
+
158
+ rerender(
159
+ <SearchBar
160
+ id="requiredState"
161
+ isDisabled
162
+ isRequired
163
+ labelText="searchbar"
164
+ onSubmit={jest.fn()}
165
+ textInputProps={textInputProps}
166
+ />
167
+ );
168
+ expect(
169
+ screen.getByPlaceholderText("Item Search (Required)")
170
+ ).toBeInTheDocument();
171
+ });
172
+
142
173
  it("Renders the UI snapshot correctly", () => {
143
174
  const basic = renderer
144
175
  .create(
145
176
  <SearchBar
146
- id="id"
177
+ helperErrorText={helperErrorText}
178
+ id="basic"
147
179
  labelText="searchbar"
148
180
  onSubmit={jest.fn()}
149
181
  textInputProps={textInputProps}
150
- helperErrorText={helperErrorText}
151
182
  />
152
183
  )
153
184
  .toJSON();
154
185
  const withSelect = renderer
155
186
  .create(
156
187
  <SearchBar
157
- id="id"
188
+ helperErrorText={helperErrorText}
189
+ id="withSelect"
158
190
  labelText="searchbar"
159
191
  onSubmit={jest.fn()}
160
192
  selectProps={selectProps}
161
193
  textInputProps={textInputProps}
162
- helperErrorText={helperErrorText}
163
194
  />
164
195
  )
165
196
  .toJSON();
166
197
  const withoutHelperText = renderer
167
198
  .create(
168
199
  <SearchBar
169
- id="id"
200
+ id="withoutHelperText"
170
201
  labelText="searchbar"
171
202
  onSubmit={jest.fn()}
172
203
  textInputProps={textInputProps}
@@ -176,22 +207,34 @@ describe("SearchBar", () => {
176
207
  const invalidState = renderer
177
208
  .create(
178
209
  <SearchBar
179
- id="id"
210
+ id="invalidState"
211
+ isInvalid
180
212
  labelText="searchbar"
181
213
  onSubmit={jest.fn()}
182
214
  textInputProps={textInputProps}
183
- isInvalid
184
215
  />
185
216
  )
186
217
  .toJSON();
187
218
  const disabledState = renderer
188
219
  .create(
189
220
  <SearchBar
190
- id="id"
221
+ id="disabledState"
222
+ isDisabled
191
223
  labelText="searchbar"
192
224
  onSubmit={jest.fn()}
193
225
  textInputProps={textInputProps}
226
+ />
227
+ )
228
+ .toJSON();
229
+ const requiredState = renderer
230
+ .create(
231
+ <SearchBar
232
+ id="requiredState"
194
233
  isDisabled
234
+ isRequired
235
+ labelText="searchbar"
236
+ onSubmit={jest.fn()}
237
+ textInputProps={textInputProps}
195
238
  />
196
239
  )
197
240
  .toJSON();
@@ -201,5 +244,6 @@ describe("SearchBar", () => {
201
244
  expect(withoutHelperText).toMatchSnapshot();
202
245
  expect(invalidState).toMatchSnapshot();
203
246
  expect(disabledState).toMatchSnapshot();
247
+ expect(requiredState).toMatchSnapshot();
204
248
  });
205
249
  });
@@ -19,8 +19,7 @@ import DSProvider from "../../theme/provider";
19
19
  parameters={{
20
20
  design: {
21
21
  type: "figma",
22
- url:
23
- "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Master?node-id=11689%3A423",
22
+ url: "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Master?node-id=11689%3A423",
24
23
  },
25
24
  jest: ["SearchBar.test.tsx"],
26
25
  }}
@@ -43,7 +42,7 @@ import DSProvider from "../../theme/provider";
43
42
  | Component Version | DS Version |
44
43
  | ----------------- | ---------- |
45
44
  | Added | `0.0.4` |
46
- | Latest | `0.25.4` |
45
+ | Latest | `0.25.6` |
47
46
 
48
47
  <Description of={SearchBar} />
49
48
 
@@ -99,6 +99,9 @@ export default function SearchBar(props: SearchBarProps) {
99
99
  const ariaDescribedby = helperErrorTextID;
100
100
  const footnote = isInvalid ? invalidText : helperErrorText;
101
101
  const finalAriaLabel = footnote ? `${labelText} - ${footnote}` : labelText;
102
+ const textInputPlaceholder = `${textInputProps?.placeholder} ${
103
+ isRequired ? "(Required)" : ""
104
+ }`;
102
105
  // Render the `Select` component.
103
106
  const selectElem = selectProps && (
104
107
  <Select
@@ -120,7 +123,7 @@ export default function SearchBar(props: SearchBarProps) {
120
123
  <TextInput
121
124
  id={generateUUID()}
122
125
  labelText={textInputProps?.labelText}
123
- placeholder={textInputProps?.placeholder}
126
+ placeholder={textInputPlaceholder}
124
127
  onChange={textInputProps?.onChange}
125
128
  name={textInputProps?.name}
126
129
  type={TextInputTypes.text}
package/src/index.ts CHANGED
@@ -73,6 +73,7 @@ export { default as Modal } from "./components/Modal/Modal";
73
73
  export { default as Notification } from "./components/Notification/Notification";
74
74
  export { NotificationTypes } from "./components/Notification/NotificationTypes";
75
75
  export { default as Pagination } from "./components/Pagination/Pagination";
76
+ export { default as ProgressIndicator } from "./components/ProgressIndicator/ProgressIndicator";
76
77
  export { default as Radio } from "./components/Radio/Radio";
77
78
  export { default as RadioGroup } from "./components/RadioGroup/RadioGroup";
78
79
  export { RadioGroupLayoutTypes } from "./components/RadioGroup/RadioGroupLayoutTypes";
@@ -84,6 +85,7 @@ export {
84
85
  SkeletonLoaderImageRatios,
85
86
  SkeletonLoaderLayouts,
86
87
  } from "./components/SkeletonLoader/SkeletonLoaderTypes";
88
+ export { default as Slider } from "./components/Slider/Slider";
87
89
  export { default as StatusBadge } from "./components/StatusBadge/StatusBadge";
88
90
  export { StatusBadgeTypes } from "./components/StatusBadge/StatusBadgeTypes";
89
91
  export {
@@ -1,4 +1,13 @@
1
1
  // Variant styling
2
+ const blogs = {
3
+ bg: "section.blogs.secondary",
4
+ color: "ui.black",
5
+ a: {
6
+ _hover: {
7
+ color: "ui.gray.xdark",
8
+ },
9
+ },
10
+ };
2
11
  const booksAndMore = {
3
12
  bg: "section.books-and-more.secondary",
4
13
  };
@@ -67,6 +76,7 @@ const Breadcrumb = {
67
76
  },
68
77
  // Available variants:
69
78
  variants: {
79
+ blogs,
70
80
  booksAndMore,
71
81
  locations,
72
82
  research,