@nypl/design-system-react-components 1.0.3 → 1.0.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/CHANGELOG.md +64 -0
- package/README.md +171 -133
- package/dist/__tests__/mediaMatchMock.d.ts +79 -0
- package/dist/components/Accordion/Accordion.d.ts +2 -2
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +2 -2
- package/dist/components/Button/Button.d.ts +4 -2
- package/dist/components/ButtonGroup/ButtonGroup.d.ts +4 -2
- package/dist/components/Card/Card.d.ts +7 -3
- package/dist/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +2 -2
- package/dist/components/ComponentWrapper/ComponentWrapper.d.ts +4 -2
- package/dist/components/Fieldset/Fieldset.d.ts +3 -1
- package/dist/components/Form/Form.d.ts +4 -2
- package/dist/components/Grid/SimpleGrid.d.ts +4 -2
- package/dist/components/Heading/Heading.d.ts +10 -2
- package/dist/components/HelperErrorText/HelperErrorText.d.ts +2 -2
- package/dist/components/Hero/Hero.d.ts +4 -2
- package/dist/components/HorizontalRule/HorizontalRule.d.ts +2 -2
- package/dist/components/Icons/Icon.d.ts +5 -3
- package/dist/components/Icons/IconSvgs.d.ts +23 -0
- package/dist/components/Image/Image.d.ts +6 -2
- package/dist/components/Label/Label.d.ts +4 -2
- package/dist/components/Link/Link.d.ts +2 -2
- package/dist/components/List/List.d.ts +4 -2
- package/dist/components/Logo/Logo.d.ts +5 -3
- package/dist/components/Logo/LogoSvgs.d.ts +1 -0
- package/dist/components/Modal/Modal.d.ts +4 -2
- package/dist/components/Notification/Notification.d.ts +1 -1
- package/dist/components/Pagination/Pagination.d.ts +2 -2
- package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +2 -2
- package/dist/components/Radio/Radio.d.ts +1 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +2 -2
- package/dist/components/SearchBar/SearchBar.d.ts +2 -2
- package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -2
- package/dist/components/SkipNavigation/SkipNavigation.d.ts +4 -2
- package/dist/components/Slider/Slider.d.ts +4 -2
- package/dist/components/StatusBadge/StatusBadge.d.ts +4 -2
- package/dist/components/StructuredContent/StructuredContent.d.ts +4 -2
- package/dist/components/StyleGuide/ColorCard.d.ts +25 -7
- package/dist/components/Table/Table.d.ts +4 -2
- package/dist/components/Tabs/Tabs.d.ts +4 -2
- package/dist/components/Template/Template.d.ts +7 -3
- package/dist/components/Text/Text.d.ts +10 -2
- package/dist/components/TextInput/TextInput.d.ts +1 -1
- package/dist/components/Toggle/Toggle.d.ts +1 -1
- package/dist/components/VideoPlayer/VideoPlayer.d.ts +4 -2
- package/dist/design-system-react-components.cjs.development.js +2929 -1863
- 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 +2839 -1805
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/hooks/__tests__/useNYPLBreakpoints.test.d.ts +1 -0
- package/dist/hooks/useCarouselStyles.d.ts +1 -1
- 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/breadcrumb.d.ts +3 -3
- package/dist/theme/components/button.d.ts +7 -2
- package/dist/theme/components/card.d.ts +4 -4
- package/dist/theme/components/checkbox.d.ts +3 -3
- package/dist/theme/components/customTable.d.ts +43 -43
- package/dist/theme/components/datePicker.d.ts +1 -0
- package/dist/theme/components/global.d.ts +6 -3
- package/dist/theme/components/globalMixins.d.ts +1 -4
- package/dist/theme/components/heading.d.ts +35 -31
- package/dist/theme/components/hero.d.ts +30 -40
- package/dist/theme/components/horizontalRule.d.ts +2 -2
- package/dist/theme/components/icon.d.ts +4762 -4762
- package/dist/theme/components/image.d.ts +60 -42
- package/dist/theme/components/list.d.ts +11 -11
- package/dist/theme/components/notification.d.ts +4 -4
- package/dist/theme/components/radio.d.ts +5 -2
- package/dist/theme/components/searchBar.d.ts +6 -0
- package/dist/theme/components/select.d.ts +6 -2
- package/dist/theme/components/skeletonLoader.d.ts +1 -1
- package/dist/theme/components/slider.d.ts +6 -6
- package/dist/theme/components/structuredContent.d.ts +33 -33
- package/dist/theme/components/tabs.d.ts +9 -9
- package/dist/theme/components/template.d.ts +7 -7
- 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 +2 -2
- package/dist/theme/provider.d.ts +2 -1
- package/package.json +17 -17
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,70 @@ Currently, this repo is in Prerelease. When it is released, this project will ad
|
|
|
8
8
|
|
|
9
9
|
## Prerelease
|
|
10
10
|
|
|
11
|
+
## 1.0.6 (July 21, 2022)
|
|
12
|
+
|
|
13
|
+
### Adds
|
|
14
|
+
|
|
15
|
+
- Adds the `isLazy` prop to the `Image` component which is set to `false` by default.
|
|
16
|
+
|
|
17
|
+
### Updates
|
|
18
|
+
|
|
19
|
+
- Updates the following components to use React's `forwardRef` wrapper function to pass along refs to the correct DOM element. This is for third-party packages and components such as Chakra's `Tooltip` to work correctly.
|
|
20
|
+
- `Accordion`, `Breadcrumbs`, `Button`, `ButtonGroup`, `Card`, `ComponentWrapper`, `FieldSet`, `Form`, `SimpleGrid`, `Heading`, `HelperErrorText`, `Hero`, `HorizontalRule`, `Icon`, `Image`, `Label`, `List`, `Logo`, `Modal`, `Notification`, `Pagination`, `ProgressIndicator`, `SearchBar`, `SkeletonLoader`, `SkipNavigation`, `Slider`, `StatusBadge`, `StructuredContent`, `Table`, `Tabs`, `Template`, `TemplateAppContainer`, `Text`, `VideoPlayer`.
|
|
21
|
+
- Updates `padding-left` and `padding-right` style properties to `padding-start` and `padding-end`, respectively. Updates `margin-left` and `margin-right` style properties to `margin-start` and `margin-end`, respectively. These changes apply to inline CSS, shorthand Chakra style prop syntax, and Chakra theme file syntax. Note that `margin-start/end` and `padding-start/end` get converted to `margin-inline-start/end` and `padding-inline-start/end` respectively by Chakra UI.
|
|
22
|
+
- Updates the `Icon` component to include variants for legacy versions of `Account` (filled and unfilled), `Facebook`, `Instagram`, `Twitter` and `YouTube`.
|
|
23
|
+
- Updates the `Icon` component to include variants for `Warning` (filled and oultine).
|
|
24
|
+
|
|
25
|
+
### Removes
|
|
26
|
+
|
|
27
|
+
- Removes the packages `@mdx-js/react` and `babel-loader` since they are not needed by Storybook.
|
|
28
|
+
|
|
29
|
+
## 1.0.5 (July 7, 2022)
|
|
30
|
+
|
|
31
|
+
### Adds
|
|
32
|
+
|
|
33
|
+
- Exports `ColorCard`.
|
|
34
|
+
|
|
35
|
+
### Updates
|
|
36
|
+
|
|
37
|
+
- Updates the `Icon` component to include variants for `actionCheckCircleFilled`, `actionRegistration`, `decorativeEnvelope`, `decorativeLibraryCard` and `decorativeShoppingBag`.
|
|
38
|
+
- Updates the docs for the `Colors` Style Guide to include additional data related to contrast and WCAG compliance.
|
|
39
|
+
- Updates the `Checkbox` and `Radio` components to use `ui.gray.dark` for the default border color.
|
|
40
|
+
- Updates Storybook packages.
|
|
41
|
+
|
|
42
|
+
### Fixes
|
|
43
|
+
|
|
44
|
+
- Fixes `useNYPLBreakpoints` hook so it internally controls its own state. This eliminates server/client rendering issues on its initial load.
|
|
45
|
+
|
|
46
|
+
## 1.0.4 (June 23, 2022)
|
|
47
|
+
|
|
48
|
+
### Adds
|
|
49
|
+
|
|
50
|
+
- Adds the `useNYPLBreakpoints` hook. This hook internally uses Chakra's `useMediaQuery` hook to get the current responsive media query breakpoint.
|
|
51
|
+
- Adds `ui.gray.xx-dark` to the color palette.
|
|
52
|
+
- Adds npm packages useful for lazy loading images in the `Image` component.
|
|
53
|
+
- Adds text case styles for `Text` component.
|
|
54
|
+
- Exports `ColorModeScript`, `cookieStorageManager`, `localStorageManager`, `useColorMode`, and `useColorModeValue` from Chakra UI for consuming application usage.
|
|
55
|
+
- Adds a "Color Mode" documentation page in Storybook.
|
|
56
|
+
- Adds `ui.white` as default background color to `Checkbox` and `Radio` components.
|
|
57
|
+
- Adds text case styles for `Heading` component
|
|
58
|
+
|
|
59
|
+
### Updates
|
|
60
|
+
|
|
61
|
+
- Updates the `Logo` component to include a variant for `MLN Color`.
|
|
62
|
+
- Updates the `Icon` component to include variants for `Facebook`, `Instagram`, `Tumblr`, `Twitter` and `YouTube`.
|
|
63
|
+
- Updates the `Icon` component to include variants for `Building`, `Exit`, `Locator`, `Power` and `Settings`.
|
|
64
|
+
- Updates to Storybook version 6.5.
|
|
65
|
+
- Explicitly sets the default color mode value to `"light"`.
|
|
66
|
+
- Updates how the `styles.scss` and `resources.scss` files are organized and compiled so that they can be imported in any tech stack.
|
|
67
|
+
- Updates the docs for the `Table` commponent to remove the example that does not include column headers.
|
|
68
|
+
- Updates the `Button`, `Select` and `TextInput` components to use NYPL standard minimum height in mobile viewport.
|
|
69
|
+
- Updates the `SearchBar` component to change how the width of the internal `Select` component is handled.
|
|
70
|
+
|
|
71
|
+
### Fixes
|
|
72
|
+
|
|
73
|
+
- Fixes the styles for the sub-labels in the `DatePicker` component.
|
|
74
|
+
|
|
11
75
|
## 1.0.3 (June 9, 2022)
|
|
12
76
|
|
|
13
77
|
### Adds
|
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 {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
2
|
export declare type AccordionTypes = "default" | "warning" | "error";
|
|
3
3
|
export interface AccordionDataProps {
|
|
4
4
|
accordionType?: AccordionTypes;
|
|
@@ -17,5 +17,5 @@ export interface AccordionProps {
|
|
|
17
17
|
* Accordion component that shows content on toggle. Can be used to display
|
|
18
18
|
* multiple accordion items together.
|
|
19
19
|
*/
|
|
20
|
-
export declare const Accordion: import("@chakra-ui/react").ChakraComponent<
|
|
20
|
+
export declare const Accordion: import("@chakra-ui/react").ChakraComponent<React.ForwardRefExoticComponent<AccordionProps & React.RefAttributes<HTMLDivElement>>, {}>;
|
|
21
21
|
export default Accordion;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
2
|
export declare type BreadcrumbsTypes = "blogs" | "booksAndMore" | "education" | "locations" | "research" | "whatsOn";
|
|
3
3
|
export interface BreadcrumbsDataProps {
|
|
4
4
|
url: string;
|
|
@@ -14,5 +14,5 @@ export interface BreadcrumbProps {
|
|
|
14
14
|
/** ID that other components can cross reference for accessibility purposes */
|
|
15
15
|
id?: string;
|
|
16
16
|
}
|
|
17
|
-
export declare const Breadcrumbs: import("@chakra-ui/react").ChakraComponent<
|
|
17
|
+
export declare const Breadcrumbs: import("@chakra-ui/react").ChakraComponent<React.ForwardRefExoticComponent<BreadcrumbProps & React.RefAttributes<HTMLDivElement>>, {}>;
|
|
18
18
|
export default Breadcrumbs;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
2
|
export declare type ButtonElementType = "submit" | "button" | "reset";
|
|
3
3
|
export declare type ButtonTypes = "primary" | "secondary" | "callout" | "pill" | "link" | "noBrand";
|
|
4
4
|
interface ButtonProps {
|
|
@@ -21,5 +21,7 @@ interface ButtonProps {
|
|
|
21
21
|
/**
|
|
22
22
|
* Renders a simple `button` element with custom variant styles.
|
|
23
23
|
*/
|
|
24
|
-
export declare const Button: import("@chakra-ui/react").ChakraComponent<
|
|
24
|
+
export declare const Button: import("@chakra-ui/react").ChakraComponent<React.ForwardRefExoticComponent<ButtonProps & {
|
|
25
|
+
children?: React.ReactNode;
|
|
26
|
+
} & React.RefAttributes<HTMLButtonElement>>, {}>;
|
|
25
27
|
export default Button;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { LayoutTypes } from "../../helpers/types";
|
|
3
3
|
export declare type ButtonGroupWidths = "default" | "full";
|
|
4
4
|
interface ButtonGroupProps {
|
|
@@ -18,5 +18,7 @@ interface ButtonGroupProps {
|
|
|
18
18
|
* to row or column and the width of internal `Button` components can be set to
|
|
19
19
|
* the parent's full width or the `Button`'s content width
|
|
20
20
|
*/
|
|
21
|
-
export declare const ButtonGroup: import("@chakra-ui/react").ChakraComponent<
|
|
21
|
+
export declare const ButtonGroup: import("@chakra-ui/react").ChakraComponent<React.ForwardRefExoticComponent<ButtonGroupProps & {
|
|
22
|
+
children?: React.ReactNode;
|
|
23
|
+
} & React.RefAttributes<HTMLDivElement>>, {}>;
|
|
22
24
|
export default ButtonGroup;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { LayoutTypes } from "../../helpers/types";
|
|
3
3
|
import { ComponentImageProps } from "../Image/Image";
|
|
4
4
|
interface CardBaseProps {
|
|
@@ -44,8 +44,12 @@ export interface CardProps extends CardBaseProps, CardWrapperProps {
|
|
|
44
44
|
* the row layout. */
|
|
45
45
|
isAlignedRightActions?: boolean;
|
|
46
46
|
}
|
|
47
|
-
export declare const CardHeading: import("@chakra-ui/react").ChakraComponent<import("@chakra-ui/react").ChakraComponent<
|
|
47
|
+
export declare const CardHeading: import("@chakra-ui/react").ChakraComponent<import("@chakra-ui/react").ChakraComponent<React.ForwardRefExoticComponent<import("../Heading/Heading").HeadingProps & {
|
|
48
|
+
children?: React.ReactNode;
|
|
49
|
+
} & React.RefAttributes<HTMLHeadingElement>>, {}>, {}>;
|
|
48
50
|
export declare const CardContent: import("@chakra-ui/react").ChakraComponent<(props: React.PropsWithChildren<{}>) => JSX.Element, {}>;
|
|
49
51
|
export declare const CardActions: import("@chakra-ui/react").ChakraComponent<(props: React.PropsWithChildren<CardActionsProps>) => JSX.Element, {}>;
|
|
50
|
-
export declare const Card: import("@chakra-ui/react").ChakraComponent<
|
|
52
|
+
export declare const Card: import("@chakra-ui/react").ChakraComponent<React.ForwardRefExoticComponent<CardProps & {
|
|
53
|
+
children?: React.ReactNode;
|
|
54
|
+
} & React.RefAttributes<HTMLDivElement>>, {}>;
|
|
51
55
|
export default Card;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { HelperErrorTextType } from "../HelperErrorText/HelperErrorText";
|
|
3
3
|
import { LayoutTypes } from "../../helpers/types";
|
|
4
4
|
export interface CheckboxGroupProps {
|
|
@@ -45,5 +45,5 @@ export interface CheckboxGroupProps {
|
|
|
45
45
|
* wrapping and associated text elements, but the checkbox input elements
|
|
46
46
|
* _need_ to be child `Checkbox` components from the NYPL Design System.
|
|
47
47
|
*/
|
|
48
|
-
export declare const CheckboxGroup: import("@chakra-ui/react").ChakraComponent<React.ForwardRefExoticComponent<CheckboxGroupProps & React.RefAttributes<
|
|
48
|
+
export declare const CheckboxGroup: import("@chakra-ui/react").ChakraComponent<React.ForwardRefExoticComponent<CheckboxGroupProps & React.RefAttributes<HTMLDivElement>>, {}>;
|
|
49
49
|
export default CheckboxGroup;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { HelperErrorTextType } from "../HelperErrorText/HelperErrorText";
|
|
3
3
|
export interface ComponentWrapperProps {
|
|
4
4
|
/** The UI elements that will be wrapped by this component */
|
|
@@ -25,5 +25,7 @@ export interface ComponentWrapperProps {
|
|
|
25
25
|
/** Offers the ability to hide the helper/invalid text. */
|
|
26
26
|
showHelperInvalidText?: boolean;
|
|
27
27
|
}
|
|
28
|
-
export declare const ComponentWrapper: import("@chakra-ui/react").ChakraComponent<
|
|
28
|
+
export declare const ComponentWrapper: import("@chakra-ui/react").ChakraComponent<React.ForwardRefExoticComponent<ComponentWrapperProps & {
|
|
29
|
+
children?: React.ReactNode;
|
|
30
|
+
} & React.RefAttributes<HTMLDivElement>>, {}>;
|
|
29
31
|
export default ComponentWrapper;
|
|
@@ -18,5 +18,7 @@ interface FieldsetProps {
|
|
|
18
18
|
* A wrapper component that renders a `fieldset` element along with a `legend`
|
|
19
19
|
* element as its first child. Commonly used to wrap form components.
|
|
20
20
|
*/
|
|
21
|
-
export declare const Fieldset: import("@chakra-ui/react").ChakraComponent<
|
|
21
|
+
export declare const Fieldset: import("@chakra-ui/react").ChakraComponent<React.ForwardRefExoticComponent<FieldsetProps & {
|
|
22
|
+
children?: React.ReactNode;
|
|
23
|
+
} & React.RefAttributes<HTMLDivElement & HTMLFieldSetElement>>, {}>;
|
|
22
24
|
export default Fieldset;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { GridGaps } from "../Grid/SimpleGrid";
|
|
3
3
|
interface FormBaseProps {
|
|
4
4
|
/** className to be applied to FormRow, FormField, and Form */
|
|
@@ -25,5 +25,7 @@ export declare const FormRow: import("@chakra-ui/react").ChakraComponent<(props:
|
|
|
25
25
|
/** FormField child-component */
|
|
26
26
|
export declare const FormField: import("@chakra-ui/react").ChakraComponent<(props: React.PropsWithChildren<FormChildProps>) => JSX.Element, {}>;
|
|
27
27
|
/** Main Form component */
|
|
28
|
-
export declare const Form: import("@chakra-ui/react").ChakraComponent<
|
|
28
|
+
export declare const Form: import("@chakra-ui/react").ChakraComponent<React.ForwardRefExoticComponent<FormProps & {
|
|
29
|
+
children?: React.ReactNode;
|
|
30
|
+
} & React.RefAttributes<HTMLFormElement>>, {}>;
|
|
29
31
|
export default Form;
|