@nypl/design-system-react-components 1.0.3-beta → 1.0.5
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/CHANGELOG.md +1499 -0
- package/README.md +171 -133
- package/dist/__tests__/mediaMatchMock.d.ts +79 -0
- package/dist/components/Card/Card.d.ts +8 -6
- package/dist/components/Heading/Heading.d.ts +6 -0
- package/dist/components/Icons/Icon.d.ts +1 -1
- package/dist/components/Icons/IconSvgs.d.ts +15 -0
- package/dist/components/Logo/Logo.d.ts +1 -1
- package/dist/components/Logo/LogoSvgs.d.ts +3 -0
- package/dist/components/StyleGuide/ColorCard.d.ts +25 -7
- package/dist/components/Table/Table.d.ts +3 -2
- package/dist/components/Text/Text.d.ts +6 -0
- package/dist/design-system-react-components.cjs.development.js +2086 -1019
- package/dist/design-system-react-components.cjs.development.js.map +1 -1
- package/dist/design-system-react-components.cjs.production.min.js +1 -1
- package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
- package/dist/design-system-react-components.esm.js +2064 -1029
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/hooks/__tests__/useNYPLBreakpoints.test.d.ts +1 -0
- package/dist/hooks/useNYPLBreakpoints.d.ts +13 -0
- package/dist/index.d.ts +3 -1
- package/dist/resources.scss +0 -4
- package/dist/styles.css +3 -2
- package/dist/theme/components/button.d.ts +7 -2
- package/dist/theme/components/checkbox.d.ts +1 -1
- package/dist/theme/components/customTable.d.ts +522 -34
- package/dist/theme/components/datePicker.d.ts +1 -0
- package/dist/theme/components/global.d.ts +4 -1
- package/dist/theme/components/heading.d.ts +5 -1
- package/dist/theme/components/image.d.ts +18 -0
- package/dist/theme/components/radio.d.ts +3 -0
- package/dist/theme/components/searchBar.d.ts +6 -0
- package/dist/theme/components/select.d.ts +4 -5
- package/dist/theme/components/structuredContent.d.ts +117 -17
- package/dist/theme/components/text.d.ts +5 -1
- package/dist/theme/components/textInput.d.ts +4 -0
- package/dist/theme/components/toggle.d.ts +1 -0
- package/dist/theme/provider.d.ts +2 -1
- package/package.json +15 -14
package/README.md
CHANGED
|
@@ -13,108 +13,27 @@ Storybook documentation
|
|
|
13
13
|
|
|
14
14
|
| Table of Contents | |
|
|
15
15
|
| ----------------- | ----------------------------------------------------------------------------------- |
|
|
16
|
-
| 1. | [
|
|
17
|
-
| 2. | [
|
|
18
|
-
| 3. | [
|
|
19
|
-
| 4. | [
|
|
20
|
-
| 5. | [
|
|
21
|
-
| 6. | [
|
|
22
|
-
| 7. | [
|
|
23
|
-
| 8. | [
|
|
16
|
+
| 1. | [Using the Design System in Your Product](#using-the-design-system-in-your-product) |
|
|
17
|
+
| 2. | [Using Chakra UI Components](#using-chakra-ui-components) |
|
|
18
|
+
| 3. | [Storybook](#storybook) |
|
|
19
|
+
| 4. | [Accessibility](#accessibility) |
|
|
20
|
+
| 5. | [Contributing Quickstart](#contributing-quickstart) |
|
|
21
|
+
| 6. | [Developing with NPM Link](#developing-with-npm-link) |
|
|
22
|
+
| 7. | [Typescript Usage](#typescript-usage) |
|
|
23
|
+
| 8. | [Unit Testing](#unit-testing) |
|
|
24
24
|
| 9. | [CDN](#cdn) |
|
|
25
25
|
|
|
26
|
-
## Contributing Quickstart
|
|
27
|
-
|
|
28
|
-
Follow these steps to setup a local installation of the project:
|
|
29
|
-
|
|
30
|
-
1. Clone the repo
|
|
31
|
-
|
|
32
|
-
```sh
|
|
33
|
-
$ git clone https://github.com/NYPL/nypl-design-system.git
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
2. Install all the dependencies
|
|
37
|
-
|
|
38
|
-
```sh
|
|
39
|
-
$ npm install
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
3. Run the Storybook instance and view it at `http://localhost:6006`
|
|
43
|
-
|
|
44
|
-
```sh
|
|
45
|
-
$ npm run storybook
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
You can now edit styles or templates in the `src` directory, and they will automatically re-build and update in the Storybook instance. Adding new stories or changing story names will require a page refresh.
|
|
49
|
-
|
|
50
|
-
Information about active maintainers, how we run reviews, and more can be found in our wiki page for [Contributing to the Design System](https://github.com/NYPL/nypl-design-system/wiki/Contributing-to-the-React-Library).
|
|
51
|
-
|
|
52
|
-
Follow the [contribution document](/.github/CONTRIBUTING.md) to follow git branching convetions, component creation and update guidelines, testing methodoly, and documentation guidelines.
|
|
53
|
-
|
|
54
|
-
### Node Version
|
|
55
|
-
|
|
56
|
-
We recommend using Node version 12.22.x since the DS has some issues with versions higher than 12.x. The Github Actions for linting, automated testing, deploying to Github Pages, and releasing to npm are all running on Node 12.x.
|
|
57
|
-
|
|
58
|
-
If you are using `nvm`, the local `.nvmrc` file can be use to set your local Node version with the `nvm use` command (will be set to `12.22.x`).
|
|
59
|
-
|
|
60
|
-
## Developing with NPM Link
|
|
61
|
-
|
|
62
|
-
To develop with a local version of the Design System:
|
|
63
|
-
|
|
64
|
-
1. In the Design System directory, run:
|
|
65
|
-
|
|
66
|
-
```sh
|
|
67
|
-
$ npm link
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
2. Go to the consuming application directory and run:
|
|
71
|
-
|
|
72
|
-
```sh
|
|
73
|
-
$ npm link @nypl/design-system-react-components
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
3. Go back to the Design System directory and run the following command. It allos the local Design System to be rebuilt and exported automatically:
|
|
77
|
-
|
|
78
|
-
```sh
|
|
79
|
-
$ npm start
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
### Error Troubleshooting
|
|
83
|
-
|
|
84
|
-
It's possible when running `npm link` that you'll get an `Invalid Hook` issue. If this occurs, it's most likely caused by having two versions of React when trying to run the application while the NYPL DS package is linked. This [Duplicate React](https://reactjs.org/warnings/invalid-hook-call-warning.html#duplicate-react) issue is covered by the React team.
|
|
85
|
-
|
|
86
|
-
To be more specific, you should run the following in your local DS directory, where `[../path/to/application]` is the local directory of the consuming application.
|
|
87
|
-
|
|
88
|
-
```sh
|
|
89
|
-
$ npm link [../path/to/application]/node_modules/react
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
Now you should be able to run `npm start` in the DS directory and `npm run dev` (or whatever your application uses) in the application directory and not get an `Invalid Hook` error.
|
|
93
|
-
|
|
94
|
-
### npm Unlink
|
|
95
|
-
|
|
96
|
-
To unlink the DS codebase:
|
|
97
|
-
|
|
98
|
-
1. Run `npm unlink` in the Design System directory.
|
|
99
|
-
2. Run `npm unlink --no-save @nypl/design-system-react-components` in the consuming application.
|
|
100
|
-
|
|
101
26
|
## Using the Design System in Your Product
|
|
102
27
|
|
|
103
|
-
|
|
28
|
+
The Reservoir Design System package is distributed on npm.
|
|
104
29
|
|
|
105
|
-
1. Install the
|
|
30
|
+
1. Install the package in your app's directory:
|
|
106
31
|
|
|
107
32
|
```sh
|
|
108
33
|
$ npm install @nypl/design-system-react-components
|
|
109
34
|
```
|
|
110
35
|
|
|
111
|
-
2. Import the
|
|
112
|
-
|
|
113
|
-
```css
|
|
114
|
-
@import "~@nypl/design-system-react-components/dist/styles.css";
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
3. Import the `DSProvider` component
|
|
36
|
+
2. Import the `DSProvider` component
|
|
118
37
|
|
|
119
38
|
In order to use DS components in a consuming application, there is a necessary step that must be done for component styles to properly render. Consuming applications need to wrap all the DS components with a simple provider component. Fortunately, this only needs to be done once at the top level of the consuming application.
|
|
120
39
|
|
|
@@ -138,7 +57,59 @@ const ApplicationContainer = (props) => {
|
|
|
138
57
|
};
|
|
139
58
|
```
|
|
140
59
|
|
|
141
|
-
|
|
60
|
+
3. Import the minified styles `@nypl/design-system-react-components/dist/styles.css` file in your app.
|
|
61
|
+
|
|
62
|
+
This file contains normalized reset CSS rules, system fonts, the `react-datepicker`'s styles, breakpoint CSS variables, and overriding styles for a few components.
|
|
63
|
+
|
|
64
|
+
Importing this file varies on the stack of the application. For Nextjs apps, the file can be imported in the `_app.tsx` file:
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
// _app.tsx
|
|
68
|
+
@import "@nypl/design-system-react-components/dist/styles.css";
|
|
69
|
+
|
|
70
|
+
import {
|
|
71
|
+
DSProvider,
|
|
72
|
+
TemplateAppContainer,
|
|
73
|
+
} from "@nypl/design-system-react-components";
|
|
74
|
+
...
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Otherwise, it can be imported in the app's main SCSS file:
|
|
78
|
+
|
|
79
|
+
```scss
|
|
80
|
+
// main.scss (for example)
|
|
81
|
+
@import "@nypl/design-system-react-components/dist/styles.css";
|
|
82
|
+
|
|
83
|
+
body {
|
|
84
|
+
....
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Note: Using tilde to import scss/css is no longer a best practice for apps using _recent_ versions of webpack or parcel.
|
|
89
|
+
|
|
90
|
+
```scss
|
|
91
|
+
// No longer a best practice:
|
|
92
|
+
@import "~@nypl/design-system-react-components/dist/styles.css";
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
For apps using parcel, prepend the string import with `npm:` such as :
|
|
96
|
+
|
|
97
|
+
```scss
|
|
98
|
+
@import "npm:@nypl/design-system-react-components/dist/styles.css";
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
4. Optionally import the `@nypl/design-system-react-components/dist/resources.scss` file in your main _scss_ file. This file contains useful SCSS mixins that can be used for global or component style rules.
|
|
102
|
+
|
|
103
|
+
```scss
|
|
104
|
+
@import "@nypl/design-system-react-components/dist/resources.scss";
|
|
105
|
+
|
|
106
|
+
// `screenreader-only` is one example of a mixing from `resources.scss`:
|
|
107
|
+
legend {
|
|
108
|
+
@include screenreader-only;
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
5. Use DS components!
|
|
142
113
|
|
|
143
114
|
Consult Storybook for the list of available components and props that they require.
|
|
144
115
|
|
|
@@ -196,22 +167,6 @@ Find more information about the Design System's internal use of Chakra to create
|
|
|
196
167
|
|
|
197
168
|
Chakra was integrated into the Design System in version `0.25.0`. For those looking to update to a version greater than or equal `0.25.0`, check out our [Chakra Migration Guide](/CHAKRA_MIGRATION_GUIDE.md).
|
|
198
169
|
|
|
199
|
-
## CDN
|
|
200
|
-
|
|
201
|
-
You can also use the Design System styles in your project through the `unpkg` CDN:
|
|
202
|
-
|
|
203
|
-
```jsx
|
|
204
|
-
<link href="https://unpkg.com/@nypl/design-system-react-components/dist/styles.css">
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
If you need to reference a particular version you can do do by including the version number in the URL:
|
|
208
|
-
|
|
209
|
-
```jsx
|
|
210
|
-
<link href="https://unpkg.com/@nypl/design-system-react-components@0.9.1/dist/styles.css">
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
You can check out a working Codepen with unpkg [here](https://codepen.io/edwinguzman/pen/ExmXGKx).
|
|
214
|
-
|
|
215
170
|
## Storybook
|
|
216
171
|
|
|
217
172
|
The Reservoir Design System leverages Storybook to document all the React components and style guidelines. The Storybook documentation can be found [here](https://nypl.github.io/nypl-design-system/reservoir/v1/?path=/story/welcome--page). For your convenience, the Reservoir Design System components have been organized into logical categories based on both form and function. Please refer to the COMPONENTS section in the Storybook sidebar.
|
|
@@ -267,6 +222,101 @@ $ npm run build-storybook:v1
|
|
|
267
222
|
|
|
268
223
|
You can then view `/reservoir/v1/index.html` in your browser. _Make sure not to commit this directory_.
|
|
269
224
|
|
|
225
|
+
## Accessibility
|
|
226
|
+
|
|
227
|
+
### Development and Storybook
|
|
228
|
+
|
|
229
|
+
The Reservoir Design System is built with accessibility in mind. By using Chakra UI as our foundational base, the custom DS components built with Chakra have accessibility concerns already implemented. On top of built-in accessible elements, DS components internally work to link labels with input elements, to add correct `aria-*` attributes, to visually hide text but still associate it with the correct element for titles and descriptions, and much more.
|
|
230
|
+
|
|
231
|
+
We make use of:
|
|
232
|
+
|
|
233
|
+
- `eslint-plugin-jsx-a11y` for finding accessibility errors through linting and through IDE environments.
|
|
234
|
+
- `jest-axe` for running [`axe-core`](https://github.com/dequelabs/axe-core) on _every_ component's unit test file. This is part of the automated tests that run in Github Actions through the `npm test` command.
|
|
235
|
+
- `@storybook/addon-a11y` for real-time accessibility testing in the browser through Storybook. _Every_ component has a tab that displays violations, passes, and incomplete checks performed by `axe-core`.
|
|
236
|
+
|
|
237
|
+
If applicable, DS components have section(s) on accessibility in their Storybook documentation. For example, in the `Slider`'s [Storybook file](/src/components/Slider/Slider.stories.mdx), there are two "Accessibility" sections for each of the two `Slider` types, "single" and "range". This gives an explanation on additional changes we made to make the combination of elements in the `Slider` component accessible.
|
|
238
|
+
|
|
239
|
+
### Product Requirements
|
|
240
|
+
|
|
241
|
+
The Reservoir Design System provides accessible stories, but real data can necessitate additional accessibility requirements beyond what we're committed to in our generic, extensible components. To ensure your products' final result is accessible, please adhere to the accessibility requirements put together by NYPL's accessibility coordinator on [Metronome](http://themetronome.co/).
|
|
242
|
+
|
|
243
|
+
NYPL's Metronome instance is currently password protected. For access to Metronome, please contact NYPL's UX team or Design System team.
|
|
244
|
+
|
|
245
|
+
## Contributing Quickstart
|
|
246
|
+
|
|
247
|
+
Follow these steps to setup a local installation of the project:
|
|
248
|
+
|
|
249
|
+
1. Clone the repo
|
|
250
|
+
|
|
251
|
+
```sh
|
|
252
|
+
$ git clone https://github.com/NYPL/nypl-design-system.git
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
2. Install all the dependencies
|
|
256
|
+
|
|
257
|
+
```sh
|
|
258
|
+
$ npm install
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
3. Run the Storybook instance and view it at `http://localhost:6006`
|
|
262
|
+
|
|
263
|
+
```sh
|
|
264
|
+
$ npm run storybook
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
You can now edit styles or templates in the `src` directory, and they will automatically re-build and update in the Storybook instance. Adding new stories or changing story names will require a page refresh.
|
|
268
|
+
|
|
269
|
+
Information about active maintainers, how we run reviews, and more can be found in our wiki page for [Contributing to the Design System](https://github.com/NYPL/nypl-design-system/wiki/Contributing-to-the-React-Library).
|
|
270
|
+
|
|
271
|
+
Follow the [contribution document](/.github/CONTRIBUTING.md) to follow git branching convetions, component creation and update guidelines, testing methodoly, and documentation guidelines.
|
|
272
|
+
|
|
273
|
+
### Node Version
|
|
274
|
+
|
|
275
|
+
We recommend using Node version 12.22.x since the DS has some issues with versions higher than 12.x. The Github Actions for linting, automated testing, deploying to Github Pages, and releasing to npm are all running on Node 12.x.
|
|
276
|
+
|
|
277
|
+
If you are using `nvm`, the local `.nvmrc` file can be use to set your local Node version with the `nvm use` command (will be set to `12.22.x`).
|
|
278
|
+
|
|
279
|
+
## Developing with NPM Link
|
|
280
|
+
|
|
281
|
+
To develop with a local version of the Design System:
|
|
282
|
+
|
|
283
|
+
1. In the Design System directory, run:
|
|
284
|
+
|
|
285
|
+
```sh
|
|
286
|
+
$ npm link
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
2. Go to the consuming application directory and run:
|
|
290
|
+
|
|
291
|
+
```sh
|
|
292
|
+
$ npm link @nypl/design-system-react-components
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
3. Go back to the Design System directory and run the following command. It allos the local Design System to be rebuilt and exported automatically:
|
|
296
|
+
|
|
297
|
+
```sh
|
|
298
|
+
$ npm start
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Error Troubleshooting
|
|
302
|
+
|
|
303
|
+
It's possible when running `npm link` that you'll get an `Invalid Hook` issue. If this occurs, it's most likely caused by having two versions of React when trying to run the application while the NYPL DS package is linked. This [Duplicate React](https://reactjs.org/warnings/invalid-hook-call-warning.html#duplicate-react) issue is covered by the React team.
|
|
304
|
+
|
|
305
|
+
To be more specific, you should run the following in your local DS directory, where `[../path/to/application]` is the local directory of the consuming application.
|
|
306
|
+
|
|
307
|
+
```sh
|
|
308
|
+
$ npm link [../path/to/application]/node_modules/react
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
Now you should be able to run `npm start` in the DS directory and `npm run dev` (or whatever your application uses) in the application directory and not get an `Invalid Hook` error.
|
|
312
|
+
|
|
313
|
+
### npm Unlink
|
|
314
|
+
|
|
315
|
+
To unlink the DS codebase:
|
|
316
|
+
|
|
317
|
+
1. Run `npm unlink` in the Design System directory.
|
|
318
|
+
2. Run `npm unlink --no-save @nypl/design-system-react-components` in the consuming application.
|
|
319
|
+
|
|
270
320
|
## Typescript Usage
|
|
271
321
|
|
|
272
322
|
The Reservoir Design System is built with Typescript. Check out the Design System's [Typescript documentation](/TYPESCRIPT.md) for more information on why we chose to build React components in Typescript and the benefits and the gotchas we encountered.
|
|
@@ -353,38 +403,26 @@ Through the [`@storybook/addon-jest`](https://www.npmjs.com/package/@storybook/a
|
|
|
353
403
|
|
|
354
404
|
After writing new tests, run `npm run test:generate-output` to create a new JSON file that is used by Storybook. This JSON file contains all the test suites for all the components and Storybook picks this up and automatically combines a component with its relevant unit tests. Make sure to commit this file although new builds on Github Pages will recreate this file for the production Storybook instance.
|
|
355
405
|
|
|
356
|
-
## Accessibility
|
|
357
|
-
|
|
358
|
-
### Development and Storybook
|
|
359
|
-
|
|
360
|
-
The Reservoir Design System is built with accessibility in mind. By using Chakra UI as our foundational base, the custom DS components built with Chakra have accessibility concerns already implemented. On top of built-in accessible elements, DS components internally work to link labels with input elements, to add correct `aria-*` attributes, to visually hide text but still associate it with the correct element for titles and descriptions, to auto-generate a random `id` attribute if none was passed, and much more.
|
|
361
|
-
|
|
362
|
-
We make use of:
|
|
363
|
-
|
|
364
|
-
- `eslint-plugin-jsx-a11y` for finding accessibility errors through linting and through IDE environments.
|
|
365
|
-
- `jest-axe` for running [`axe-core`](https://github.com/dequelabs/axe-core) on _every_ component's unit test file. This is part of the automated tests that run in Github Actions through the `npm test` command.
|
|
366
|
-
- `@storybook/addon-a11y` for real-time accessibility testing in the browser through Storybook. _Every_ component has a tab that displays violations, passes, and incomplete checks performed by `axe-core`.
|
|
367
|
-
|
|
368
|
-
If applicable, DS components have section(s) on accessibility in their Storybook documentation. For example, in the `Slider`'s [Storybook file](/src/components/Slider/Slider.stories.mdx), there are two "Accessibility" sections for each of the two `Slider` types, "single" and "range". This gives an explanation on additional changes we made to make the combination of elements in the `Slider` component accessible.
|
|
369
|
-
|
|
370
|
-
### Product Requirements
|
|
371
|
-
|
|
372
|
-
The Reservoir Design System provides accessible stories, but real live data can necessitate additional accessibility requirements beyond what we're committed to in our generic, extensible components. To ensure your products' final result is accessible, please adhere to the accessibility requirements put together by NYPL's accessibility coordinator on [Metronome](http://themetronome.co/).
|
|
373
|
-
|
|
374
|
-
NYPL's Metronome instance is currently password protected. For access to Metronome, please contact NYPL's UX team or Design System team.
|
|
375
|
-
|
|
376
406
|
## CDN
|
|
377
407
|
|
|
378
408
|
You can also use the Design System styles in your project through the `unpkg` CDN:
|
|
379
409
|
|
|
380
|
-
```
|
|
381
|
-
<link
|
|
410
|
+
```html
|
|
411
|
+
<link
|
|
412
|
+
href="https://unpkg.com/@nypl/design-system-react-components/dist/styles.css"
|
|
413
|
+
/>
|
|
414
|
+
<script src="https://unpkg.com/@nypl/design-system-react-components/dist/design-system-react-components.cjs.production.min.js" />
|
|
415
|
+
<script src="https://unpkg.com/@nypl/design-system-react-components/dist/design-system-react-components.esm.js" />
|
|
382
416
|
```
|
|
383
417
|
|
|
384
418
|
If you need to reference a particular version you can do do by including the version number in the URL:
|
|
385
419
|
|
|
386
|
-
```
|
|
387
|
-
<link
|
|
420
|
+
```html
|
|
421
|
+
<link
|
|
422
|
+
href="https://unpkg.com/@nypl/design-system-react-components@1.0.0/dist/styles.css"
|
|
423
|
+
/>
|
|
424
|
+
<script src="https://unpkg.com/@nypl/design-system-react-components@1.0.0/dist/design-system-react-components.cjs.production.min.js" />
|
|
425
|
+
<script src="https://unpkg.com/@nypl/design-system-react-components@1.0.0/dist/design-system-react-components.esm.js" />
|
|
388
426
|
```
|
|
389
427
|
|
|
390
428
|
You can check out a working Codepen with unpkg [here](https://codepen.io/edwinguzman/pen/ExmXGKx).
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NYPL Note:
|
|
3
|
+
* This file is directly taken from Chakra:
|
|
4
|
+
* https://github.com/chakra-ui/chakra-ui/blob/main/packages/media-query/tests/matchmedia-mock-plus.ts
|
|
5
|
+
*
|
|
6
|
+
* We need this to test the `useNYPLBreakpoints` hook and, unfortunately,
|
|
7
|
+
* this function is not exported by Chakra.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* This mock is a combination of jest-matchmedia-mock
|
|
11
|
+
* https://github.com/dyakovk/jest-matchmedia-mock and
|
|
12
|
+
* mq-polyfill https://github.com/bigslycat/mq-polyfill.
|
|
13
|
+
*
|
|
14
|
+
* A solution which allowed resizing and a more realistic implementation of
|
|
15
|
+
* matchMedia was the reason for its creation. Neither project provided a good
|
|
16
|
+
* solution. Combining their strong points does. The class will listen for a
|
|
17
|
+
* resize event which is provided by a resizeTo function defined in the test:
|
|
18
|
+
*
|
|
19
|
+
* window.resizeTo = function resizeTo(width, height) {
|
|
20
|
+
* Object.assign(this, {
|
|
21
|
+
* innerWidth: width,
|
|
22
|
+
* innerHeight: height,
|
|
23
|
+
* outerWidth: width,
|
|
24
|
+
* outerHeight: height,
|
|
25
|
+
* }).dispatchEvent(new this.Event('resize'))
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* Listeners are only called if there has been a change in the match
|
|
29
|
+
* status for their media query.
|
|
30
|
+
*/
|
|
31
|
+
declare type MediaQueryListener = (this: MediaQueryList) => void;
|
|
32
|
+
interface MediaQueryList {
|
|
33
|
+
readonly matches: boolean;
|
|
34
|
+
readonly media: string;
|
|
35
|
+
onchange: MediaQueryListener | null;
|
|
36
|
+
addListener(listener: MediaQueryListener): void;
|
|
37
|
+
removeListener(listener: MediaQueryListener): void;
|
|
38
|
+
addEventListener(type: "change", listener: MediaQueryListener): void;
|
|
39
|
+
removeEventListener(type: "change", listener: MediaQueryListener): void;
|
|
40
|
+
dispatchEvent(event: Event): boolean;
|
|
41
|
+
}
|
|
42
|
+
export default class MatchMedia {
|
|
43
|
+
private mediaQueries;
|
|
44
|
+
private prevMatchMap;
|
|
45
|
+
private mediaQueryList;
|
|
46
|
+
constructor();
|
|
47
|
+
private compileQuery;
|
|
48
|
+
private evalQuery;
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* Adds a listener function for the window resize event
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
private handleResize;
|
|
55
|
+
private addListener;
|
|
56
|
+
private removeListener;
|
|
57
|
+
/**
|
|
58
|
+
* Returns an array listing the media queries for which the matchMedia has registered listeners
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
getMediaQueries(): string[];
|
|
62
|
+
/**
|
|
63
|
+
* Returns a copy of the array of listeners for the specified media query
|
|
64
|
+
* @public
|
|
65
|
+
*/
|
|
66
|
+
getListeners(mediaQuery: string): MediaQueryListener[];
|
|
67
|
+
/**
|
|
68
|
+
* Clears all registered media queries and their listeners
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
clear(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Clears all registered media queries and their listeners,
|
|
74
|
+
* and destroys the implementation of `window.matchMedia`
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
destroy(): void;
|
|
78
|
+
}
|
|
79
|
+
export {};
|
|
@@ -8,9 +8,15 @@ interface CardBaseProps {
|
|
|
8
8
|
* Default is `"column"`. */
|
|
9
9
|
layout?: LayoutTypes;
|
|
10
10
|
}
|
|
11
|
-
interface
|
|
11
|
+
interface CardWrapperProps {
|
|
12
|
+
/** Optional CSS class name to add. */
|
|
13
|
+
className?: string;
|
|
14
|
+
/** ID that other components can cross reference for accessibility purposes. */
|
|
15
|
+
id?: string;
|
|
12
16
|
/** Main link to use when the full `Card` component should be clickable. */
|
|
13
17
|
mainActionLink?: string;
|
|
18
|
+
/** Additional object for styling the `Card`'s `div` wrapper. */
|
|
19
|
+
styles?: any;
|
|
14
20
|
}
|
|
15
21
|
interface CardImageProps extends ComponentImageProps {
|
|
16
22
|
/** Optional boolean value to control the position of the `CardImage`. */
|
|
@@ -24,15 +30,11 @@ interface CardActionsProps extends CardBaseProps {
|
|
|
24
30
|
* the card actions element */
|
|
25
31
|
topBorder?: boolean;
|
|
26
32
|
}
|
|
27
|
-
export interface CardProps extends CardBaseProps,
|
|
33
|
+
export interface CardProps extends CardBaseProps, CardWrapperProps {
|
|
28
34
|
/** Optional hex color value used to set the card background color. */
|
|
29
35
|
backgroundColor?: string;
|
|
30
|
-
/** Optional CSS class name to add. */
|
|
31
|
-
className?: string;
|
|
32
36
|
/** Optional hex color value used to override the default text color. */
|
|
33
37
|
foregroundColor?: string;
|
|
34
|
-
/** ID that other components can cross reference for accessibility purposes. */
|
|
35
|
-
id?: string;
|
|
36
38
|
/** Optional boolean value to control the visibility of a border around
|
|
37
39
|
* the card. */
|
|
38
40
|
isBordered?: boolean;
|
|
@@ -6,6 +6,12 @@ export interface HeadingProps {
|
|
|
6
6
|
className?: string;
|
|
7
7
|
/** Optional ID that other components can cross reference for accessibility purposes */
|
|
8
8
|
id?: string;
|
|
9
|
+
/** Optional prop used to show capitalized text */
|
|
10
|
+
isCapitalized?: boolean;
|
|
11
|
+
/** Optional prop used to show upper case text */
|
|
12
|
+
isUppercase?: boolean;
|
|
13
|
+
/** Optional prop used to show lower case text */
|
|
14
|
+
isLowercase?: boolean;
|
|
9
15
|
/** Optional number 1-6 used to create the `<h*>` tag; if prop is not passed,
|
|
10
16
|
* `Heading` will default to `<h2>` */
|
|
11
17
|
level?: HeadingLevels;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
export declare type IconAlign = "left" | "right" | "none";
|
|
3
3
|
export declare type IconColors = "ui.black" | "ui.white" | "brand.primary" | "brand.secondary" | "section.blogs.primary" | "section.blogs.secondary" | "section.books-and-more.primary" | "section.books-and-more.secondary" | "section.education.primary" | "section.education.secondary" | "section.locations.primary" | "section.locations.secondary" | "section.research.primary" | "section.research.secondary" | "section.research-library.lpa" | "section.research-library.schomburg" | "section.research-library.schwartzman" | "section.whats-on.primary" | "section.whats-on.secondary";
|
|
4
|
-
export declare type IconNames = "accessibilityFull" | "accessibilityPartial" | "actionCheckCircle" | "actionHelpDefault" | "actionHelpOutline" | "actionLaunch" | "alertNotificationImportant" | "arrow" | "check" | "clock" | "close" | "download" | "errorFilled" | "errorOutline" | "fileTypeAudio" | "fileTypeDoc" | "fileTypeGenericDoc" | "fileTypeImage" | "fileTypePdf" | "fileTypeSpreadsheet" | "fileTypeVideo" | "headset" | "minus" | "plus" | "search" | "speakerNotes" | "utilityAccountFilled" | "utilityAccountUnfilled" | "utilityHamburger" | "utilitySearch";
|
|
4
|
+
export declare type IconNames = "accessibilityFull" | "accessibilityPartial" | "actionCheckCircle" | "actionCheckCircleFilled" | "actionExit" | "actionHelpDefault" | "actionHelpOutline" | "actionLaunch" | "actionPower" | "actionRegistration" | "actionSettings" | "alertNotificationImportant" | "arrow" | "building" | "check" | "clock" | "close" | "decorativeEnvelope" | "decorativeLibraryCard" | "decorativeShoppingBag" | "download" | "errorFilled" | "errorOutline" | "fileTypeAudio" | "fileTypeDoc" | "fileTypeGenericDoc" | "fileTypeImage" | "fileTypePdf" | "fileTypeSpreadsheet" | "fileTypeVideo" | "headset" | "locator" | "minus" | "plus" | "search" | "socialFacebook" | "socialInstagram" | "socialTumblr" | "socialTwitter" | "socialYoutube" | "speakerNotes" | "utilityAccountFilled" | "utilityAccountUnfilled" | "utilityHamburger" | "utilitySearch";
|
|
5
5
|
export declare type IconRotationTypes = "rotate0" | "rotate90" | "rotate180" | "rotate270";
|
|
6
6
|
export declare type IconSizes = "default" | "small" | "medium" | "large" | "xlarge" | "xxlarge" | "xxxlarge";
|
|
7
7
|
export declare type IconTypes = "default" | "breadcrumbs";
|
|
@@ -2,14 +2,23 @@ declare const _default: {
|
|
|
2
2
|
accessibilityFull: string;
|
|
3
3
|
accessibilityPartial: string;
|
|
4
4
|
actionCheckCircle: string;
|
|
5
|
+
actionCheckCircleFilled: string;
|
|
6
|
+
actionExit: string;
|
|
5
7
|
actionHelpDefault: string;
|
|
6
8
|
actionHelpOutline: string;
|
|
7
9
|
actionLaunch: string;
|
|
10
|
+
actionPower: string;
|
|
11
|
+
actionRegistration: string;
|
|
12
|
+
actionSettings: string;
|
|
8
13
|
alertNotificationImportant: string;
|
|
9
14
|
arrow: string;
|
|
15
|
+
building: string;
|
|
10
16
|
check: string;
|
|
11
17
|
clock: string;
|
|
12
18
|
close: string;
|
|
19
|
+
decorativeEnvelope: string;
|
|
20
|
+
decorativeLibraryCard: string;
|
|
21
|
+
decorativeShoppingBag: string;
|
|
13
22
|
download: string;
|
|
14
23
|
errorFilled: string;
|
|
15
24
|
errorOutline: string;
|
|
@@ -21,9 +30,15 @@ declare const _default: {
|
|
|
21
30
|
fileTypeSpreadsheet: string;
|
|
22
31
|
fileTypeVideo: string;
|
|
23
32
|
headset: string;
|
|
33
|
+
locator: string;
|
|
24
34
|
minus: string;
|
|
25
35
|
plus: string;
|
|
26
36
|
search: string;
|
|
37
|
+
socialFacebook: string;
|
|
38
|
+
socialInstagram: string;
|
|
39
|
+
socialTumblr: string;
|
|
40
|
+
socialTwitter: string;
|
|
41
|
+
socialYoutube: string;
|
|
27
42
|
speakerNotes: string;
|
|
28
43
|
utilityAccountFilled: string;
|
|
29
44
|
utilityAccountUnfilled: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
export declare type LogoNames = "appleAppStoreBlack" | "appleAppStoreWhite" | "bplBlack" | "bplWhite" | "cleverBadgeColor" | "cleverColor" | "cleverWhite" | "firstbookColor" | "firstbookColorNegative" | "googlePlayBlack" | "lpaBlack" | "lpaColor" | "lpaWhite" | "mlnBlack" | "mlnWhite" | "nyplFullBlack" | "nyplFullWhite" | "nyplLionBlack" | "nyplLionWhite" | "openebooksColor" | "openebooksNegative" | "openebooksWithTextColor" | "openebooksWithTextNegative" | "qplAltBlack" | "qplAltWhite" | "qplBlack" | "qplColor" | "qplWhite" | "reservoirIconColor" | "reservoirVerticalColor" | "schomburgBlack" | "schomburgCircleBlack" | "schomburgCircleColor" | "schomburgCircleWhite" | "schomburgColor" | "schomburgWhite" | "simplyeBlack" | "simplyeWhite" | "simplyeColor" | "snflBlack" | "snflWhite" | "treasuresColor" | "treasuresColorNegative";
|
|
2
|
+
export declare type LogoNames = "appleAppStoreBlack" | "appleAppStoreWhite" | "bplBlack" | "bplWhite" | "cleverBadgeColor" | "cleverColor" | "cleverWhite" | "firstbookColor" | "firstbookColorNegative" | "googlePlayBlack" | "lpaBlack" | "lpaColor" | "lpaWhite" | "mlnBlack" | "mlnColor" | "mlnWhite" | "nyplFullBlack" | "nyplFullWhite" | "nyplLionBlack" | "nyplLionWhite" | "nyplTextBlack" | "nyplTextWhite" | "openebooksColor" | "openebooksNegative" | "openebooksWithTextColor" | "openebooksWithTextNegative" | "qplAltBlack" | "qplAltWhite" | "qplBlack" | "qplColor" | "qplWhite" | "reservoirIconColor" | "reservoirVerticalColor" | "schomburgBlack" | "schomburgCircleBlack" | "schomburgCircleColor" | "schomburgCircleWhite" | "schomburgColor" | "schomburgWhite" | "simplyeBlack" | "simplyeWhite" | "simplyeColor" | "snflBlack" | "snflWhite" | "treasuresColor" | "treasuresColorNegative";
|
|
3
3
|
export declare type LogoSizes = "default" | "xxsmall" | "xsmall" | "small" | "medium" | "large";
|
|
4
4
|
export interface LogoProps {
|
|
5
5
|
/** Optional className that will be added to the parent element */
|
|
@@ -13,11 +13,14 @@ declare const _default: {
|
|
|
13
13
|
lpaColor: string;
|
|
14
14
|
lpaWhite: string;
|
|
15
15
|
mlnBlack: string;
|
|
16
|
+
mlnColor: string;
|
|
16
17
|
mlnWhite: string;
|
|
17
18
|
nyplFullBlack: string;
|
|
18
19
|
nyplFullWhite: string;
|
|
19
20
|
nyplLionBlack: string;
|
|
20
21
|
nyplLionWhite: string;
|
|
22
|
+
nyplTextBlack: string;
|
|
23
|
+
nyplTextWhite: string;
|
|
21
24
|
openebooksColor: string;
|
|
22
25
|
openebooksNegative: string;
|
|
23
26
|
openebooksWithTextColor: string;
|
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
export interface ColorCardProps {
|
|
3
|
-
/** backgroundColor of the color card */
|
|
3
|
+
/** The backgroundColor of the color card. */
|
|
4
4
|
backgroundColor: string;
|
|
5
|
-
/** name of
|
|
5
|
+
/** The name of a color's javascript theme object. */
|
|
6
6
|
colorName: string;
|
|
7
|
+
/** The name of the color that the current color is based on. */
|
|
8
|
+
colorSource: string;
|
|
9
|
+
/** Contrast and WCAG compliance data related to the color black when used
|
|
10
|
+
* with the current color. */
|
|
11
|
+
dataBlack: string[];
|
|
12
|
+
/** Contrast and WCAG compliance data related to the color white when used
|
|
13
|
+
* with the current color. */
|
|
14
|
+
dataWhite: string[];
|
|
15
|
+
/** The color to use for text in the color card. */
|
|
16
|
+
textColor: string;
|
|
7
17
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
18
|
+
export interface DataTableProps {
|
|
19
|
+
/** Contrast and WCAG compliance data related to the color black when used
|
|
20
|
+
* with the current color. */
|
|
21
|
+
dataBlack: string[];
|
|
22
|
+
/** Contrast and WCAG compliance data related to the color white when used
|
|
23
|
+
* with the current color. */
|
|
24
|
+
dataWhite: string[];
|
|
25
|
+
/** color to use for text in color card */
|
|
26
|
+
textColor: string;
|
|
27
|
+
}
|
|
28
|
+
export declare const DataTable: (props: React.PropsWithChildren<DataTableProps>) => JSX.Element;
|
|
29
|
+
export declare const ColorCard: (props: React.PropsWithChildren<ColorCardProps>) => JSX.Element;
|
|
30
|
+
export default ColorCard;
|
|
@@ -2,8 +2,9 @@ import * as React from "react";
|
|
|
2
2
|
export interface TableProps {
|
|
3
3
|
/** Additional class name for the `Table` component. */
|
|
4
4
|
className?: string;
|
|
5
|
-
/** Array of string values used to populate the `Table` column headers.
|
|
6
|
-
|
|
5
|
+
/** Array of string values used to populate the `Table` column headers.
|
|
6
|
+
* For improved accessibility, column headers are required. */
|
|
7
|
+
columnHeaders: string[];
|
|
7
8
|
/** Hex value to set the background color of the column headers. */
|
|
8
9
|
columnHeadersBackgroundColor?: string;
|
|
9
10
|
/** Hex value to set the text color of the column headers. */
|
|
@@ -7,6 +7,12 @@ export interface TextProps {
|
|
|
7
7
|
isBold?: boolean;
|
|
8
8
|
/** Optional prop used to show itlicized text */
|
|
9
9
|
isItalic?: boolean;
|
|
10
|
+
/** Optional prop used to show capitalized text */
|
|
11
|
+
isCapitalized?: boolean;
|
|
12
|
+
/** Optional prop used to show upper case text */
|
|
13
|
+
isUppercase?: boolean;
|
|
14
|
+
/** Optional prop used to show lower case text */
|
|
15
|
+
isLowercase?: boolean;
|
|
10
16
|
/** Optional prop used to remove default spacing */
|
|
11
17
|
noSpace?: boolean;
|
|
12
18
|
/** Optional prop to control the text styling */
|