@nypl/design-system-react-components 4.0.0-alpha-rc4 → 4.0.0-rc
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/README.md +125 -201
- package/dist/design-system-react-components.cjs +39 -39
- package/dist/design-system-react-components.js +4507 -4571
- package/dist/readme/componentheader.png +0 -0
- package/dist/src/components/Accordion/Accordion.d.ts +1 -1
- package/dist/src/components/Banner/Banner.d.ts +2 -3
- package/dist/src/components/Button/Button.d.ts +1 -1
- package/dist/src/components/CheckboxGroup/CheckboxGroup.d.ts +2 -2
- package/dist/src/components/Form/Form.d.ts +6 -1
- package/dist/src/components/MultiSelect/MultiSelect.d.ts +7 -6
- package/dist/src/components/NewsletterSignup/NewsletterSignup.d.ts +1 -1
- package/dist/src/components/Notification/Notification.d.ts +2 -2
- package/dist/src/components/ProgressIndicator/ProgressIndicator.d.ts +1 -1
- package/dist/src/components/RadioGroup/RadioGroup.d.ts +4 -3
- package/dist/src/components/SearchBar/SearchBar.d.ts +2 -2
- package/dist/src/components/TagSet/TagSet.d.ts +2 -5
- package/dist/src/components/Text/Text.d.ts +1 -1
- package/dist/src/index.d.ts +1 -3
- package/dist/src/theme/components/breadcrumb.d.ts +1 -1
- package/dist/src/theme/components/feedbackBox.d.ts +1 -1
- package/dist/src/theme/components/heading.d.ts +5 -3
- package/dist/src/theme/components/hero.d.ts +14 -15
- package/dist/src/theme/components/newsletterSignup.d.ts +1 -1
- package/dist/src/theme/components/searchBar.d.ts +2 -2
- package/dist/src/theme/components/select.d.ts +7 -3
- package/dist/src/theme/components/socialmedialinks.d.ts +2 -2
- package/dist/src/theme/components/structuredContent.d.ts +1 -1
- package/dist/src/theme/components/subnav.d.ts +1 -1
- package/dist/src/theme/components/template.d.ts +6 -11
- package/dist/useNextjsImage/aspectRatio.png +0 -0
- package/dist/useNextjsImage/containedImageExamples.png +0 -0
- package/dist/useNextjsImage/croppedImageExamples.png +0 -0
- package/dist/useNextjsImage/customWidth.png +0 -0
- package/dist/useNextjsImage/fallbackImageDark.png +0 -0
- package/dist/useNextjsImage/fallbackImageLight.png +0 -0
- package/dist/useNextjsImage/focalPointExamples01.png +0 -0
- package/dist/useNextjsImage/focalPointExamples02.png +0 -0
- package/package.json +1 -1
- package/dist/src/hooks/useCarouselStyles.d.ts +0 -17
- package/dist/src/hooks/useWindowSize.d.ts +0 -10
package/README.md
CHANGED
|
@@ -4,74 +4,68 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://badge.fury.io/js/%40nypl%2Fdesign-system-react-components)
|
|
6
6
|
|
|
7
|
-
The Reservoir Design System (DS) is
|
|
7
|
+
The Reservoir Design System (DS) is an open-source, extensible React library for NYPL products and experiences with accessibility at its core. It ships functional components with consistent NYPL styling.
|
|
8
8
|
|
|
9
|
-
Storybook documentation
|
|
9
|
+
Storybook documentation:
|
|
10
10
|
|
|
11
|
-
- [
|
|
12
|
-
- [
|
|
13
|
-
- [
|
|
14
|
-
- [V1 Production - deployed to Github Pages](https://nypl.github.io/nypl-design-system/reservoir/v1)
|
|
11
|
+
- [v4 docs (current)](https://nypl.github.io/nypl-design-system/reservoir/v4/?path=/docs/welcome--docs)
|
|
12
|
+
- [v3 docs](https://nypl.github.io/nypl-design-system/reservoir/v3/?path=/docs/welcome--docs)
|
|
13
|
+
- [Development/QA branch docs](https://nypl-design-system.vercel.app/?path=/docs/welcome--docs)
|
|
15
14
|
|
|
16
|
-
| Table of Contents |
|
|
17
|
-
| ----------------- |
|
|
18
|
-
| 1. | [
|
|
19
|
-
| 2. | [Using Chakra UI
|
|
20
|
-
| 3. | [
|
|
21
|
-
| 4. | [
|
|
22
|
-
| 5. | [
|
|
23
|
-
| 6. | [
|
|
24
|
-
| 7. | [Typescript Usage](#typescript-usage) |
|
|
25
|
-
| 8. | [Unit Testing](#unit-testing) |
|
|
26
|
-
| 9. | [CDN](#cdn) |
|
|
15
|
+
| Table of Contents | |
|
|
16
|
+
| ----------------- | ----------------------------------------------------------------------------------------------- |
|
|
17
|
+
| 1. | [Get started using the Reservoir Design System](#get-started-using-the-reservoir-design-system) |
|
|
18
|
+
| 2. | [Using Chakra UI components](#using-chakra-ui-components) |
|
|
19
|
+
| 3. | [Accessibility](#accessibility) |
|
|
20
|
+
| 4. | [Contributing](#contributing) |
|
|
21
|
+
| 5. | [Git workflow and releases](#git-workflow-and-releases) |
|
|
22
|
+
| 6. | [CDN](#cdn) |
|
|
27
23
|
|
|
28
|
-
##
|
|
24
|
+
## Get started using the Reservoir Design System
|
|
29
25
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
1. Install the package in your app's directory:
|
|
26
|
+
1. Install the npm package in your app's directory.
|
|
33
27
|
|
|
34
28
|
```sh
|
|
35
29
|
$ npm install @nypl/design-system-react-components
|
|
36
30
|
```
|
|
37
31
|
|
|
38
|
-
2.
|
|
39
|
-
|
|
40
|
-
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.
|
|
32
|
+
2. Add the `DSProvider`.
|
|
41
33
|
|
|
42
|
-
|
|
34
|
+
In order to properly render styles, you must wrap all Reservoir components with a `DSProvider` component.
|
|
43
35
|
|
|
44
36
|
```jsx
|
|
45
37
|
// your main application file
|
|
46
38
|
import { DSProvider } from "@nypl/design-system-react-components";
|
|
47
|
-
|
|
48
39
|
// ...
|
|
49
40
|
const ApplicationContainer = (props) => {
|
|
50
41
|
// ...
|
|
51
42
|
return (
|
|
52
|
-
<
|
|
53
|
-
<
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
43
|
+
<header>...</header>
|
|
44
|
+
<DSProvider>
|
|
45
|
+
<div className="my-app">
|
|
46
|
+
// ...
|
|
47
|
+
{children}
|
|
48
|
+
</div>
|
|
49
|
+
</DSProvider>
|
|
50
|
+
<footer>...</footer>
|
|
58
51
|
);
|
|
59
52
|
};
|
|
60
53
|
```
|
|
61
54
|
|
|
62
|
-
3. Import the
|
|
55
|
+
3. Import the `@nypl/design-system-react-components/dist/styles.css` file.
|
|
56
|
+
|
|
57
|
+
This file contains additional, minified styles – normalized reset CSS rules, system fonts, the `react-datepicker`'s styles, breakpoint CSS variables, and overriding styles for a few components.
|
|
63
58
|
|
|
64
|
-
|
|
59
|
+
Where you import this file varies on the stack of the application.
|
|
65
60
|
|
|
66
|
-
|
|
61
|
+
For Next apps, the file can be imported in the `_app.tsx` file:
|
|
67
62
|
|
|
68
63
|
```tsx
|
|
69
64
|
// _app.tsx
|
|
70
65
|
@import "@nypl/design-system-react-components/dist/styles.css";
|
|
71
66
|
|
|
72
67
|
import {
|
|
73
|
-
DSProvider
|
|
74
|
-
TemplateAppContainer,
|
|
68
|
+
DSProvider
|
|
75
69
|
} from "@nypl/design-system-react-components";
|
|
76
70
|
```
|
|
77
71
|
|
|
@@ -86,7 +80,7 @@ body {
|
|
|
86
80
|
}
|
|
87
81
|
```
|
|
88
82
|
|
|
89
|
-
For apps using parcel, prepend the string import with `npm
|
|
83
|
+
For apps using parcel, prepend the string import with `npm:`.
|
|
90
84
|
|
|
91
85
|
```scss
|
|
92
86
|
@import "npm:@nypl/design-system-react-components/dist/styles.css";
|
|
@@ -94,134 +88,27 @@ For apps using parcel, prepend the string import with `npm:` such as :
|
|
|
94
88
|
|
|
95
89
|
4. Use DS components!
|
|
96
90
|
|
|
97
|
-
Consult Storybook for the list of available components and
|
|
98
|
-
|
|
99
|
-
Here's an example with the `Link` component:
|
|
100
|
-
|
|
101
|
-
```jsx
|
|
102
|
-
import { Link } from "@nypl/design-system-react-components";
|
|
103
|
-
|
|
104
|
-
function NewComponent(props) {
|
|
105
|
-
return <Link href="https://www.hathitrust.org/">HathiTrust</Link>;
|
|
106
|
-
}
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
Sometimes you may have conflicts, perhaps with Next.js' `Link` router component. In that case, you can alias your imports:
|
|
110
|
-
|
|
111
|
-
```jsx
|
|
112
|
-
import { Link as DSLink } from "@nypl/design-system-react-components";
|
|
113
|
-
import { Link } from "next/link";
|
|
114
|
-
|
|
115
|
-
function NewComponent(props) {
|
|
116
|
-
return (
|
|
117
|
-
<DSLink as={Link} type="action" href="#">
|
|
118
|
-
Next Page
|
|
119
|
-
</DSLink>
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
## Using Chakra UI Components
|
|
125
|
-
|
|
126
|
-
The Chakra UI component library has been integrated into the Reservoir Design System. We are still progressing towards using Chakra components and patterns to build DS components, and therefore documentation and features are expected to change. While the implementation details of DS components will use Chakra, the DS package itself will export _some_ Chakra components.
|
|
127
|
-
|
|
128
|
-
The list of re-exported Chakra components can be found in the main [index.ts](/src/index.ts) file. They include:
|
|
129
|
-
|
|
130
|
-
- `Box`, `Center`, `Circle`, `Grid`, `GridItem`, `HStack`, `Square`, `Stack`, `VStack`
|
|
131
|
-
|
|
132
|
-
Find more information about the Design System's internal use of Chakra to create and refactor components in the Storybook documentation page. The following two links have the same information but in different formats for your reading preference:
|
|
133
|
-
|
|
134
|
-
- [MDX format](/src/docs/Chakra.mdx)
|
|
135
|
-
- [Storybook page](https://nypl.github.io/nypl-design-system/reservoir/v3/?path=/docs/chakra-ui--docs)
|
|
136
|
-
|
|
137
|
-
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).
|
|
138
|
-
|
|
139
|
-
## Storybook
|
|
140
|
-
|
|
141
|
-
The Reservoir Design System leverages Storybook to document all the React components and style guidelines. The Storybook documentation for version 3.x can be found [on Github Pages](https://nypl.github.io/nypl-design-system/reservoir/v3/?path=/docs/welcome--docs). 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.
|
|
142
|
-
|
|
143
|
-
### Documentation Instances
|
|
144
|
-
|
|
145
|
-
There are currently three main instances of the Reservoir Design System Storybook documentation. There are also "preview" sites that are used to quickly and easily view pull request changes.
|
|
146
|
-
|
|
147
|
-
**Production**
|
|
148
|
-
|
|
149
|
-
The production Storybook documentation for DS version 3.x is deployed to [Github Pages](https://nypl.github.io/nypl-design-system/reservoir/v3/?path=/docs/welcome--docs). This is the main instance we use to share the latest stable release of the Reservoir Design System. This documentation site is deployed through [Github Actions](/.github/workflows/gh-pages.yml) only on merges to the `release` and `gh-pages` branches.
|
|
150
|
-
|
|
151
|
-
As of July, 2021, the Github Pages production site gets deployed every two weeks on the same schedule as npm releases.
|
|
152
|
-
|
|
153
|
-
**Development**
|
|
154
|
-
|
|
155
|
-
The development Storybook documentation is deployed to [Vercel](https://nypl-design-system.vercel.app/?path=/docs/welcome--docs). This development site has all the working updates that get merged to the `development` branch. This means that this site is constantly being updated as pull requests are being merged in. This site is used to see the lastest changes during a working sprint before a production release is made.
|
|
156
|
-
|
|
157
|
-
**Version 2.x**
|
|
158
|
-
|
|
159
|
-
The Storybook documentation for DS version 2.x is deployed to [Vercel](https://nypl.github.io/nypl-design-system/reservoir/v2). If you are using a DS version less than 3.0, this is the Storybook documentation you should be referencing. While the DS team will continue to support version 2.x, we will not be adding new features or components to this version. We highly recommend updating to version 3.x for design update and bug fixes.
|
|
160
|
-
|
|
161
|
-
**Version 1.x**
|
|
162
|
-
|
|
163
|
-
The Storybook documentation for DS version 1.x is deployed to [Vercel](https://nypl.github.io/nypl-design-system/reservoir/v1). If you are using a DS version less than 2.0, this is the Storybook documentation you should be referencing. We highly recommend updating to version 3.x for design update and bug fixes.
|
|
164
|
-
|
|
165
|
-
**Preview Sites**
|
|
166
|
-
|
|
167
|
-
Preview Storybook documentation sites are deployed to Vercel on every commit push to every branch in this repository. They follow a pattern such as `nypl-design-system-[hash]-nypl.vercel.app` where `[hash]` is a random hash created by Vercel. This means that the URL varies and that those instances are eventually shut off. They are not meant to be used as long-term sites but rather for reviewing working changes within the team.
|
|
168
|
-
|
|
169
|
-
### React Component Documentation
|
|
170
|
-
|
|
171
|
-
When actively developing components or fixing bugs, make sure that the related stories are created or updated. This means updating the respective `[component-name].mdx` file. For information on how to write stories, check out the [Anatomy of a Story](https://github.com/NYPL/nypl-design-system/wiki/Anatomy-of-a-Story) wiki page.
|
|
172
|
-
|
|
173
|
-
For stand-alone document pages in Storybook, you need to:
|
|
174
|
-
|
|
175
|
-
1. create the `[page-name].mdx` file in `src/docs/`
|
|
176
|
-
2. add the file reference to the `.storybook/main.ts` file in the `stories` array
|
|
177
|
-
|
|
178
|
-
### React Component Versions
|
|
179
|
-
|
|
180
|
-
To help consuming application developers understand which version of the DS is required for a specific component, each component story page includes the following:
|
|
181
|
-
|
|
182
|
-
- when a component was added to the DS
|
|
183
|
-
- minimum version of the DS required for the latest version of a component
|
|
184
|
-
|
|
185
|
-
**Example Component Version Table**
|
|
186
|
-
|
|
187
|
-
| Component Version | DS Version |
|
|
188
|
-
| ----------------- | ---------- |
|
|
189
|
-
| Added | `0.20.1` |
|
|
190
|
-
| Latest | `0.23.2` |
|
|
191
|
-
|
|
192
|
-
### Static Build
|
|
193
|
-
|
|
194
|
-
_Make sure not to commit the directory created from the following process_.
|
|
195
|
-
|
|
196
|
-
There should be no need to run the static Storybook instance while actively developing -- it's used exclusively for building out the `gh-pages` environment and deploying it to [Github Pages](https://nypl.github.io/nypl-design-system/reservoir/v3/?path=/docs/welcome--docs). In the event that you do run the static Storybook npm script, run:
|
|
91
|
+
Consult [Storybook](https://nypl.github.io/nypl-design-system/reservoir/v4/?path=/docs/welcome--docs) for the list of available components and how to use them.
|
|
197
92
|
|
|
198
|
-
|
|
199
|
-
$ npm run build-storybook:v3
|
|
200
|
-
```
|
|
93
|
+
## Using Chakra UI components
|
|
201
94
|
|
|
202
|
-
|
|
95
|
+
The Reservoir Design System is generally built _on top of_ [Chakra v2](https://v2.chakra-ui.com/), but the following Chakra components are exported _directly_ for your use: `Box`, `Center`, `Circle`, `Grid`, `GridItem`, `HStack`, `Square`, `Stack`, `VStack`.
|
|
203
96
|
|
|
204
97
|
## Accessibility
|
|
205
98
|
|
|
206
|
-
|
|
99
|
+
Accessibility is a main priority of the Reservoir Design System.
|
|
207
100
|
|
|
208
|
-
|
|
101
|
+
On top of built-in accessibility from Chakra, DS components link labels with input elements, add correct `aria-*` attributes, visually hide important text for screenreader users, and much more.
|
|
209
102
|
|
|
210
|
-
|
|
103
|
+
Reservoir makes use of:
|
|
211
104
|
|
|
212
105
|
- `eslint-plugin-jsx-a11y` for finding accessibility errors through linting and through IDE environments.
|
|
213
106
|
- `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.
|
|
214
107
|
- `@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`.
|
|
215
108
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
### Product Requirements
|
|
219
|
-
|
|
220
|
-
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/).
|
|
221
|
-
|
|
222
|
-
NYPL's Metronome instance is currently password protected. For access to Metronome, please contact NYPL's UX team or Design System team.
|
|
109
|
+
Additionally, DS components include detailed accessibility information in their Storybook documentation.
|
|
223
110
|
|
|
224
|
-
## Contributing
|
|
111
|
+
## Contributing
|
|
225
112
|
|
|
226
113
|
Follow these steps to setup a local installation of the project:
|
|
227
114
|
|
|
@@ -231,7 +118,7 @@ Follow these steps to setup a local installation of the project:
|
|
|
231
118
|
$ git clone https://github.com/NYPL/nypl-design-system.git
|
|
232
119
|
```
|
|
233
120
|
|
|
234
|
-
2. Install
|
|
121
|
+
2. Install dependencies
|
|
235
122
|
|
|
236
123
|
```sh
|
|
237
124
|
$ npm install
|
|
@@ -243,67 +130,48 @@ $ npm install
|
|
|
243
130
|
$ npm run storybook
|
|
244
131
|
```
|
|
245
132
|
|
|
246
|
-
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.
|
|
247
|
-
|
|
248
133
|
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).
|
|
249
134
|
|
|
250
|
-
Follow the [contribution document](/.github/CONTRIBUTING.md) to follow git branching
|
|
251
|
-
|
|
252
|
-
### Node Version
|
|
253
|
-
|
|
254
|
-
The DS uses Node version 18.x and we do not support any Node versions below 18.x. The Github Actions for linting, automated testing, deploying to Github Pages, and releasing to npm are all running on Node 18.x.
|
|
135
|
+
Follow the [contribution document](/.github/CONTRIBUTING.md) to follow git branching conventions, component creation and update guidelines, testing methodology, and documentation guidelines.
|
|
255
136
|
|
|
256
|
-
|
|
137
|
+
### Typescript usage
|
|
257
138
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
There are currently two main branches for the DS:
|
|
261
|
-
|
|
262
|
-
- `development` is the main and default branch for the DS. All new feature and bug fix pull requests should be made against this branch.
|
|
263
|
-
- `release` is the production branch used to create Github releases, tags, and npm releases.
|
|
264
|
-
- `gh-pages` is the branch used to deploy the static Storybook instance to Github Pages, the DS' production Storybook instance.
|
|
139
|
+
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 gotchas we encountered.
|
|
265
140
|
|
|
266
|
-
|
|
141
|
+
### Node version
|
|
267
142
|
|
|
268
|
-
|
|
143
|
+
The DS uses Node version 20.x and we do not support any Node versions below 20.x. The Github Actions for linting, automated testing, deploying to Github Pages, and releasing to npm are all running on Node 20.x.
|
|
269
144
|
|
|
270
|
-
|
|
271
|
-
2. Create a pull request that points to the `development` branch.
|
|
272
|
-
3. If your pull request is approved and _should_ be merged, merge it. This is indicated with the "SHIP IT" Github label. Sometimes, some features must wait and the "DO NOT MERGE" label is added to the pull request.
|
|
145
|
+
If you are using `nvm`, the local `.nvmrc` file (using `20.x`) can be used to set your local Node version with the `nvm use` command. Make sure your machine has Node version 20.x installed through `nvm` already.
|
|
273
146
|
|
|
274
|
-
###
|
|
147
|
+
### Component documentation
|
|
275
148
|
|
|
276
|
-
|
|
149
|
+
When developing components or fixing bugs, make sure to update or create the related Storybook doc(s).
|
|
277
150
|
|
|
278
|
-
|
|
151
|
+
To create a story:
|
|
279
152
|
|
|
280
|
-
1.
|
|
281
|
-
2.
|
|
282
|
-
3. Run `npm install` to install all the dependencies and create a new `package-lock.json` file with the updated version.
|
|
283
|
-
4. Run `npm publish` to publish the new release candidate version to npm. Make sure you have an npm account, are logged in to npm on your machine, and have the correct permissions to publish to the `@nypl/design-system-react-components` package.
|
|
153
|
+
1. Add a `[component-name].mdx` file in the `src/components/[component-name]/` directory.
|
|
154
|
+
2. Make sure the file is referenced in the `stories` array of `.storybook/main.ts`
|
|
284
155
|
|
|
285
|
-
|
|
156
|
+
For information on how to write stories, check out the [Anatomy of a Story](https://github.com/NYPL/nypl-design-system/wiki/Anatomy-of-a-Story) wiki page.
|
|
286
157
|
|
|
287
|
-
|
|
288
|
-
2. Once approved, merge the pull request into the feature branch or the `development` branch.
|
|
289
|
-
3. Follow the same steps above to create a new release candidate version but this time the `-rc` suffix should be incremented. For example, `1.5.0-rc` becomes `1.5.0-rc1`.
|
|
290
|
-
4. QA the new release candidate version in the Turbine test app.
|
|
158
|
+
### Component header
|
|
291
159
|
|
|
292
|
-
|
|
160
|
+
Each story page starts with a component header. It includes the component category, name, summary, and versioning information.
|
|
293
161
|
|
|
294
|
-
|
|
295
|
-
2. Make sure all the new changes are merged into the `development` branch.
|
|
296
|
-
3. Remove the `-rc` suffix from the version in the `package.json` file.
|
|
297
|
-
4. Delete the `package-lock.json` file and the `node_modules` directory.
|
|
298
|
-
5. Run `npm install` to install all the dependencies and create a new `package-lock.json` file with the updated version.
|
|
299
|
-
6. Push the changes to Github and create a new pull request from `development` that points to the `release` branch.
|
|
300
|
-
7. Once approved and merged, a Github Action will run that will automatically deploy the static Storybook to Github Pages and publish the new version to npm.
|
|
162
|
+
**Example component docs header**
|
|
301
163
|
|
|
302
|
-
|
|
164
|
+
<ComponentDocsHeader
|
|
165
|
+
category="Basic Elements"
|
|
166
|
+
componentName="Hero"
|
|
167
|
+
summary="A full-width banner at the top of a page"
|
|
168
|
+
versionAdded="0.2.0"
|
|
169
|
+
versionLatest="Prerelease"
|
|
170
|
+
/>
|
|
303
171
|
|
|
304
|
-
|
|
172
|
+

|
|
305
173
|
|
|
306
|
-
|
|
174
|
+
### Unit testing
|
|
307
175
|
|
|
308
176
|
The Reservoir Design System runs unit tests with Jest and React Testing Library.
|
|
309
177
|
|
|
@@ -331,9 +199,9 @@ For example, to test the `Link` component, run:
|
|
|
331
199
|
$ npm test -- src/components/Link/Link.test.tsx
|
|
332
200
|
```
|
|
333
201
|
|
|
334
|
-
### Snapshot
|
|
202
|
+
### Snapshot testing
|
|
335
203
|
|
|
336
|
-
|
|
204
|
+
If a component's DOM or SCSS styling was unintentionally updated, we can catch those bugs through snapshot testing. The NYPL DS implements snapshot testing with `react-test-renderer` and `jest`.
|
|
337
205
|
|
|
338
206
|
The `react-test-renderer` package, will create a directory and a file to hold `.snap` files after a unit test is created. Using the `Notification` component as an example, this is the basic layout for a snapshot test:
|
|
339
207
|
|
|
@@ -379,15 +247,71 @@ $ npm test -- --updateSnapshot
|
|
|
379
247
|
|
|
380
248
|
Each snapshot file also includes a link to its [Jest Snapshot documentation](https://jestjs.io/docs/snapshot-testing) which is recommended to read!
|
|
381
249
|
|
|
382
|
-
### Storybook
|
|
250
|
+
### Storybook test addon
|
|
383
251
|
|
|
384
252
|
Through the [`@storybook/test`](https://www.npmjs.com/package/@storybook/test) plugin, we can see a component's suite of unit tests right Storybook. In the "Addons" panel, a "Test" tab will display all the tests for the current component and whether they pass or fail.
|
|
385
253
|
|
|
386
254
|
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.
|
|
387
255
|
|
|
256
|
+
### Static build
|
|
257
|
+
|
|
258
|
+
_Make sure not to commit the directory created from the following process_.
|
|
259
|
+
|
|
260
|
+
There should be no need to run the static Storybook instance while actively developing -- it's used exclusively for building out the `gh-pages` environment and deploying it to [Github Pages](https://nypl.github.io/nypl-design-system/reservoir/v3/?path=/docs/welcome--docs). In the event that you do want to run the static Storybook npm script, run:
|
|
261
|
+
|
|
262
|
+
```sh
|
|
263
|
+
$ npm run build-storybook:v4
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
You can then view `/reservoir/v4/index.html` in your browser. _Make sure not to commit this directory_.
|
|
267
|
+
|
|
268
|
+
## Git workflow and releases
|
|
269
|
+
|
|
270
|
+
There are currently three main branches for the DS:
|
|
271
|
+
|
|
272
|
+
- `development` is the main and default branch for the DS. All new feature and bug fix pull requests should be made against this branch.
|
|
273
|
+
- `release` is the production branch used to create Github releases, tags, and npm releases.
|
|
274
|
+
- `gh-pages` is the branch used to deploy the static Storybook instance to Github Pages, the DS' production Storybook instance.
|
|
275
|
+
|
|
276
|
+
When a new version of the DS is ready for release, the `development` branch is merged into the `release` branch through a pull request. Once merged, Github Actions will run to deploy the static Storybook as well as publish the new version to npm. Here is a [pull request](https://github.com/NYPL/nypl-design-system/pull/1532) that follows the convention outlined in [How to Run a Release](https://github.com/NYPL/nypl-design-system/wiki/How-to-Run-a-Release).
|
|
277
|
+
|
|
278
|
+
When working on a new feature or a bug fix:
|
|
279
|
+
|
|
280
|
+
1. Create a new branch off of `development` with the following naming convention: `[ticket-number]/your-feature-or-bug-name` (for example, `DSD-1234/add-more-animal-crossing-examples`).
|
|
281
|
+
2. Create a pull request that points to the `development` branch.
|
|
282
|
+
3. If your pull request is approved and _should_ be merged, a maintainer will add the "Ship It" Github label and you may merge it. Sometimes, features must wait; the "DO NOT MERGE" label will be added to these pull requests.
|
|
283
|
+
|
|
284
|
+
### Release candidates
|
|
285
|
+
|
|
286
|
+
For big feature updates, we'll often make a "release candidate" and test it in the [Turbine app](https://nypl-ds-test-app.vercel.app/) before the real release is made.
|
|
287
|
+
|
|
288
|
+
To create a release candidate:
|
|
289
|
+
|
|
290
|
+
1. Check out `development` or the feature branch containing your update
|
|
291
|
+
1. Update the `package.json` `version` to include the `-rc` suffix. For example, `1.5.0` becomes `1.5.0-rc`.
|
|
292
|
+
1. Delete the `package-lock.json` file and the `node_modules` directory.
|
|
293
|
+
1. Run `npm install` to install all the dependencies and create a new `package-lock.json` file with the updated version.
|
|
294
|
+
1. Run `npm publish` to publish the new release candidate version to npm. Make sure you have an npm account and have the correct permissions to publish to the `@nypl/design-system-react-components` package.
|
|
295
|
+
|
|
296
|
+
If a bug is found in testing:
|
|
297
|
+
|
|
298
|
+
1. Update or fix the bug in a new branch.
|
|
299
|
+
1. Once approved, merge the pull request into the feature or `development` branch.
|
|
300
|
+
1. Follow the same steps above to create a new release candidate version, but this time the `-rc` suffix should be incremented. For example, `1.5.0-rc` becomes `1.5.0-rc1`.
|
|
301
|
+
1. QA the new release candidate version in the Turbine test app.
|
|
302
|
+
|
|
303
|
+
If the release candidate version passed QA and is ready for production:
|
|
304
|
+
|
|
305
|
+
1. Celebrate.
|
|
306
|
+
1. Make sure all the new changes are merged into the `development` branch. Remove the `-rc` suffix from the version in the `package.json` file.
|
|
307
|
+
1. Delete the `package-lock.json` file and the `node_modules` directory.
|
|
308
|
+
1. Run `npm install` to install all the dependencies and create a new `package-lock.json` file with the updated version.
|
|
309
|
+
1. Push the changes to Github and create a new pull request from `development` that points to the `release` branch.
|
|
310
|
+
1. Once approved and merged, a Github Action will run that will automatically deploy the static Storybook to Github Pages and publish the new version to npm.
|
|
311
|
+
|
|
388
312
|
## CDN
|
|
389
313
|
|
|
390
|
-
You can also use the Design System styles in your project through the `unpkg` CDN, but
|
|
314
|
+
You can also use the Design System styles in your project through the `unpkg` CDN, but note that this is not recommended for production use.
|
|
391
315
|
|
|
392
316
|
```html
|
|
393
317
|
<link
|