@utrecht/component-library-react 6.2.1 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/CHANGELOG.md +200 -0
  2. package/CONTRIBUTING.md +169 -0
  3. package/README.md +65 -76
  4. package/README.nl.md +82 -0
  5. package/TESTING.md +203 -0
  6. package/dist/.jest-test-results.json +1 -1
  7. package/dist/Accordion.d.ts +2 -2
  8. package/dist/Accordion.d.ts.map +1 -1
  9. package/dist/Blockquote.d.ts +4 -0
  10. package/dist/Blockquote.d.ts.map +1 -1
  11. package/dist/Calendar.js +8 -3
  12. package/dist/Calendar.js.map +1 -1
  13. package/dist/Calendar.mjs +9 -4
  14. package/dist/Calendar.mjs.map +1 -1
  15. package/dist/Checkbox.d.ts +1 -0
  16. package/dist/Checkbox.d.ts.map +1 -1
  17. package/dist/ColumnLayout.d.ts.map +1 -1
  18. package/dist/Fieldset.d.ts +1 -0
  19. package/dist/Fieldset.d.ts.map +1 -1
  20. package/dist/FormFieldCheckbox.d.ts +14 -0
  21. package/dist/FormFieldCheckbox.d.ts.map +1 -0
  22. package/dist/FormFieldTextarea.d.ts +14 -0
  23. package/dist/FormFieldTextarea.d.ts.map +1 -0
  24. package/dist/Icon.d.ts.map +1 -1
  25. package/dist/Logo.d.ts +5 -3
  26. package/dist/Logo.d.ts.map +1 -1
  27. package/dist/Textarea.d.ts +1 -0
  28. package/dist/Textarea.d.ts.map +1 -1
  29. package/dist/css-module/Accordion.d.ts +2 -2
  30. package/dist/css-module/Accordion.d.ts.map +1 -1
  31. package/dist/css-module/Blockquote.d.ts +4 -0
  32. package/dist/css-module/Blockquote.d.ts.map +1 -1
  33. package/dist/css-module/Calendar.js +8 -3
  34. package/dist/css-module/Calendar.js.map +1 -1
  35. package/dist/css-module/Calendar.mjs +9 -4
  36. package/dist/css-module/Calendar.mjs.map +1 -1
  37. package/dist/css-module/Checkbox.d.ts +1 -0
  38. package/dist/css-module/Checkbox.d.ts.map +1 -1
  39. package/dist/css-module/ColumnLayout.d.ts.map +1 -1
  40. package/dist/css-module/Fieldset.d.ts +1 -0
  41. package/dist/css-module/Fieldset.d.ts.map +1 -1
  42. package/dist/css-module/FormFieldCheckbox.d.ts +14 -0
  43. package/dist/css-module/FormFieldCheckbox.d.ts.map +1 -0
  44. package/dist/css-module/FormFieldTextarea.d.ts +14 -0
  45. package/dist/css-module/FormFieldTextarea.d.ts.map +1 -0
  46. package/dist/css-module/Icon.d.ts.map +1 -1
  47. package/dist/css-module/Logo.d.ts +5 -3
  48. package/dist/css-module/Logo.d.ts.map +1 -1
  49. package/dist/css-module/Textarea.d.ts +1 -0
  50. package/dist/css-module/Textarea.d.ts.map +1 -1
  51. package/dist/css-module/css-module/Accordion.d.ts +1 -0
  52. package/dist/css-module/css-module/Accordion.d.ts.map +1 -1
  53. package/dist/css-module/css-module/Button.d.ts +1 -1
  54. package/dist/css-module/css-module/Button.d.ts.map +1 -1
  55. package/dist/css-module/css-module/FormFieldCheckbox.d.ts +10 -0
  56. package/dist/css-module/css-module/FormFieldCheckbox.d.ts.map +1 -0
  57. package/dist/css-module/css-module/FormFieldTextarea.d.ts +10 -0
  58. package/dist/css-module/css-module/FormFieldTextarea.d.ts.map +1 -0
  59. package/dist/css-module/css-module/index.d.ts +6 -2
  60. package/dist/css-module/css-module/index.d.ts.map +1 -1
  61. package/dist/css-module/index.d.ts +4 -0
  62. package/dist/css-module/index.d.ts.map +1 -1
  63. package/dist/css-module/index.js +1012 -713
  64. package/dist/css-module/index.js.map +1 -1
  65. package/dist/css-module/index.mjs +1011 -714
  66. package/dist/css-module/index.mjs.map +1 -1
  67. package/dist/index.cjs.js +794 -556
  68. package/dist/index.cjs.js.map +1 -1
  69. package/dist/index.d.ts +4 -0
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/index.esm.js +794 -558
  72. package/dist/index.esm.js.map +1 -1
  73. package/package.json +24 -23
  74. package/tsconfig.md +51 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,200 @@
1
+ # @utrecht/component-library-react
2
+
3
+ ## 7.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - a26f139: Add `FormFieldTextarea` component to the React component library.
8
+ - b520118: Support `restProps` for React `ColumnLayout` component.
9
+ - 4c0f337: Add `inputRequired` property to React `Textarea`.
10
+ - b8b8100: Add `<FormFieldCheckbox>` component.
11
+
12
+ ### Patch Changes
13
+
14
+ - ecaf6a6: Fix missing CSS when loading `Button` from `dist/css-module/`.
15
+
16
+ ## 7.0.0
17
+
18
+ ### Major Changes
19
+
20
+ - c3660c1: Rename design token `utrecht.button.icon.gap` to `utrecht.button.column-gap`
21
+
22
+ ### Minor Changes
23
+
24
+ - 200e34b: Add `utrecht.number-badge.border-color` and `utrecht.number-badge.border-width` design tokens.
25
+ - 27f15a9: Add `required` state to the `Fieldset` component in React.'
26
+ - c09705f: Add "heading" to the accordion provider.
27
+ Add "heading level" to the accordion provider.
28
+ - 24b4813: Add an optional `label` property to React `Button` component, to support better styling of icons.
29
+
30
+ ### Patch Changes
31
+
32
+ - 27f15a9: Fix `Fieldset` component in React to only render `aria-invalid` for `role="radiogroup"`.
33
+ - 9e32a67: - Refactored Icon component: default role="presentation", conditional aria-hidden
34
+ - Added possibility for custom roles and ARIA labels
35
+ - edited unit tests for accessibility tree hidden or not
36
+ - tested in React Storybook
37
+
38
+ ## 6.2.1
39
+
40
+ ### Patch Changes
41
+
42
+ - 8622506: Fix errors for missing TypeScript definitions in `@utrecht/component-library-react`.
43
+
44
+ ## 6.2.0
45
+
46
+ ### Minor Changes
47
+
48
+ - 6c0db88: Add Superscript React component.
49
+ - 1227678: Add Table of Contents component for the PDF component library.
50
+ - f3d47bb: Add `errorMessage` property to FormField.
51
+ - a6a2187: Add Subscript React component.
52
+ - a919a87: Add new `type` options to the `SpotlightSection` component: `error` and `ok`.
53
+ - 38c31c8: - Support `...restProps`, `className` and `forwardRef` for `NavList` React component.
54
+ - Support `className` for `NavListLink` and `NavListButton` React components.
55
+
56
+ ### Patch Changes
57
+
58
+ - f3d47bb: Fix FormField to render the description before the input.
59
+
60
+ ## 6.1.0
61
+
62
+ ### Minor Changes
63
+
64
+ - 8431fb9: Add the following design tokens to breadcrumb navigation:
65
+
66
+ - `utrecht.breadcrumb-nav.line-height`
67
+ - `utrecht.breadcrumb-nav.link.active.color`
68
+ - `utrecht.breadcrumb-nav.link.active.text-decoration`
69
+
70
+ - d6bb92d: Add Number badge component as replacement for Badge counter
71
+ - 48ccd57: Support bold form controls.
72
+
73
+ Add the following design tokens:
74
+
75
+ - `utrecht.form-control.font-weight` (common token)
76
+ - `utrecht.listbox.font-weight`
77
+ - `utrecht.select.font-weight`
78
+ - `utrecht.textarea.font-weight`
79
+ - `utrecht.textbox.font-weight`
80
+
81
+ ### Patch Changes
82
+
83
+ - 5695c6c: Improve table component CSS to explicitly fallback to `background-color: transparent` to have a valid CSS value. ([GitHub Issue nl-design-system/utrecht#2435](https://github.com/nl-design-system/utrecht/issues/2435))
84
+ - 9aa2be4: Fix regression in `utrecht.button.font-family` support.
85
+
86
+ ## 6.0.0
87
+
88
+ ### Major Changes
89
+
90
+ - ecf877a: Refactor the Alert component for more consistent token names and use flex instead of grid layout. Adding support for content and message sections.
91
+
92
+ - Rename `utrecht.alert.icon.gap` to `utrecht.alert.column-gap`
93
+ - Add `utrecht.alert.message.row-gap` token
94
+ - Add `utrecht.alert.content.row-gap` token
95
+ - Add `utrecht.alert.icon.size` token
96
+ - Add `utrecht.alert.icon.inset-block-start` token
97
+ - Add `utrecht-alert__content` class
98
+ - Change implementation of layout from grid to flex
99
+
100
+ ## 5.0.0
101
+
102
+ ### Major Changes
103
+
104
+ - 886b038: Breaking change: Changed Heading to HTML Heading, so the class name 'utrecht-heading-x' is no longer used.
105
+
106
+ ### Minor Changes
107
+
108
+ - 4037f4c: Add two new design tokens to "Badge counter":
109
+
110
+ - `utrecht.badge-counter.min-block-size`
111
+ - `utrecht.badge-counter.min-inline-size`: the primary token to configure the size.
112
+
113
+ The following design token is now deprecated. Reason for deprecation: it does not follow naming conventions, to use existing CSS property names — "`min-size`" is a made-up property.
114
+
115
+ - `utrecht.badge-counter.min-size`
116
+
117
+ - a045934: Add HTML Heading component to the React component library.
118
+ - 5299695: Button now support two new design tokens for each appearance: `font-size` and a matching `line-height`. These are optional, by default the button still uses `utrecht.button.font-size` and `utrecht.button.line-height`.
119
+
120
+ These are the 6 new design tokens:
121
+
122
+ - `utrecht.button.primary-action.font-size`
123
+ - `utrecht.button.primary-action.line-height`
124
+ - `utrecht.button.secondary-action.font-size`
125
+ - `utrecht.button.secondary-action.line-height`
126
+ - `utrecht.button.subtle.font-size`
127
+ - `utrecht.button.subtle.line-height`
128
+
129
+ ## 4.2.0
130
+
131
+ ### Minor Changes
132
+
133
+ - c5a7e71: Add margin tokens to the Accordion component:
134
+
135
+ - `utrecht.accordion.margin-block-end`
136
+ - `utrecht.accordion.margin-block-start`
137
+
138
+ ## 4.1.0
139
+
140
+ ### Minor Changes
141
+
142
+ - a07687b: Add new component: RichText - a container component around components such as paragraph, table, list, accordion etcetera.
143
+
144
+ ## 4.0.0
145
+
146
+ ### Major Changes
147
+
148
+ - 14c8559: Replace `utrecht.link-list.item.margin-block-start` design token with `utrecht.link-list.row-gap`.
149
+ - bd0514c: Rename tokens in the Link list component, because they should be on `link` instead of on `item`. "Item" currently only exists in CSS, but is not necessary to build the Link list in Figma.
150
+
151
+ - Rename `utrecht.link-list.item.font-weight` to `utrecht.link-list.link.font-weight`.
152
+ - Rename `utrecht.link-list.item.column-gap` to `utrecht.link-list.link.column-gap`.
153
+
154
+ ### Minor Changes
155
+
156
+ - c5c2eff: Checkbox supports the `indeterminate` boolean property: `<Checkbox indeterminate />`.
157
+
158
+ - It renders the `utrecht-checkbox--indeterminate` class name.
159
+ - It renders the `aria-checked="mixed"` attribute.
160
+ - It sets the `indeterminate` property in the DOM, so the `:indeterminate` CSS pseudo selector is supported too.
161
+
162
+ Important note: you must implement behavior for removing the `indeterminate` state after `onChange` yourself.
163
+
164
+ - 482aa36: Add `FormFieldTextbox` component, that combines `FormField`, `FormLabel`, `Textbox`, `FormFieldDescription` and `FormFieldErrorMessage` in one.
165
+ - b007c47: Allow any `string` for Textbox `type`, in addition to the existing enumeration of supported types.
166
+ - 12abd0c: Add Blockquote component for React.
167
+ - e2b188d: Add design token to Link list component: `utrecht.link-list.link.text-decoration`, so you can enable or disable the underline. By default the links have no underline.
168
+
169
+ ### Patch Changes
170
+
171
+ - c401145: Use `<ul role="list">` for the `LinkList` component, so VoiceOver in Safari recognizes the list. See ["Fixing" lists (by Scott O'Hara)](https://www.scottohara.me/blog/2019/01/12/lists-and-safari.html) for context.
172
+ - 0e2e4da: Fix rendering of the checkbox component in the combined indeterminate and checked state, to have an indeterminate icon instead of a checked icon.'
173
+
174
+ ## 3.1.0
175
+
176
+ ### Minor Changes
177
+
178
+ - f9c23c6: Add `icon` and `appearance` properties to `<AccordionProvider>` and `<AccordionSection>`.
179
+ - f9c23c6: Add `utrecht-accordion__button-icon--utrecht` mixin
180
+ - f9c23c6: Add `utrecht.accordion.button.icon.gap` design token.
181
+
182
+ ## 3.0.0
183
+
184
+ ### Major Changes
185
+
186
+ - af24025682: `ButtonGroup` boolean property `vertical` now is `direction="column"`'
187
+
188
+ ## 1.0.1
189
+
190
+ ### Patch Changes
191
+
192
+ - 0e434e0a19: fix rendering glitch in Firefox when hovering over a button
193
+
194
+ ## 1.0.0
195
+
196
+ ### Patch Changes
197
+
198
+ - c7cae76a0d: allow word wrap for URL data, so it is fully readable in print and on screen
199
+ - 28a3ef848a: Support rendering of `<select>` element with multiple attribute.
200
+ - b1ac291a45: Omit rendering `aria-required="false"` for `required={false}` in React `Select` component.
@@ -0,0 +1,169 @@
1
+ <!-- @license CC0-1.0 -->
2
+
3
+ # Developing components
4
+
5
+ Warning: the code examples are deliberately simplified to show one concept at a time. Do not use the code snippets as-is.
6
+
7
+ For more complete examples, look at the source code of existing components.
8
+
9
+ ## Develop for extensibility
10
+
11
+ ### Class names
12
+
13
+ Enable front-end developers to add their own class names to the outermost HTML element of your component. Since all components have BEM class names, you must combine your BEM class names with any class names from the parameters. We typically use `clsx` to format the `class` attribute.
14
+
15
+ ```jsx
16
+ import clsx from "clsx";
17
+
18
+ export const MyComponent = ({ children, className }) => (
19
+ <div className={clsx("my-component", className)}>{children}</div>
20
+ );
21
+ ```
22
+
23
+ ### Allow rich text content
24
+
25
+ Allow `ReactNode` contents for text parameters, so front-end developers can use accessible and meaningful markup. Using `PropsWithChildren` is recommended for non-empty components, because it allows `ReactNode` for children.
26
+
27
+ ```tsx
28
+ import clsx from "clsx";
29
+ import type { PropsWithChildren } from "react";
30
+
31
+ export interface MyComponentProps {
32
+ // ...
33
+ }
34
+
35
+ export const MyComponent = ({ children }: PropsWithChildren<MyComponentProps>) => <div>{children}</div>;
36
+ ```
37
+
38
+ For other parameters using `ReactNode` might not be as obvious, since you might feel like starting with `string`. For example:
39
+
40
+ ```tsx
41
+ import clsx from "clsx";
42
+ import type { PropsWithChildren } from "react";
43
+
44
+ export interface MyLandmarkComponentProps {
45
+ label: ReactNode;
46
+ }
47
+
48
+ export const MyLandmarkComponent = ({ children, label }: PropsWithChildren<MyComponentProps>) => {
49
+ const headingId = useId();
50
+ return (
51
+ <div role="region" aria-labelledby={label ? labelId : undefined}>
52
+ {label && <div id={labelId}>{label}</div>}
53
+ {children}
54
+ </div>
55
+ );
56
+ };
57
+ ```
58
+
59
+ This allows front-end developers to use any markup:
60
+
61
+ ```jsx
62
+ <MyLandmarkComponent
63
+ label={
64
+ <>
65
+ <LandmarkIcon /> Landmark label
66
+ </>
67
+ }
68
+ >
69
+ <p>Landmark content</p>
70
+ </MyLandmarkComponent>
71
+ ```
72
+
73
+ Allowing rich text is one more reason to use `aria-labelledby` instead of `aria-label`.
74
+
75
+ ## Export interfaces and types
76
+
77
+ Export the type definitions for parameters, so other developers can easily use those to develop wrapper components.
78
+
79
+ ```tsx
80
+ export type TextboxTypes = "password" | "text";
81
+
82
+ export interface TextboxProps extends InputHTMLAttributes<HTMLInputElement> {
83
+ type?: TextboxTypes;
84
+ }
85
+
86
+ export const Textbox = ({ type }: TextboxProps) => <input {...restProps} type={type} />;
87
+ ```
88
+
89
+ This way another developer could extend your component:
90
+
91
+ ```tsx
92
+ import type { TextboxProps, TextboxTypes } from "@my/textbox";
93
+
94
+ export interface AdvancedTextboxProps extends TextboxProps {
95
+ type?: TextboxTypes | "date";
96
+ }
97
+
98
+ export const AdvancedTextbox = ({ type }: AdvancedTextboxProps) => <input {...restProps} type={type} />;
99
+ ```
100
+
101
+ ## Use `forwardRef`
102
+
103
+ Use [`forwardRef`](https://react.dev/reference/react/forwardRef) to expose the DOM node with a [ref](https://react.dev/learn/manipulating-the-dom-with-refs).
104
+
105
+ ```tsx
106
+ import clsx from "clsx";
107
+ import type { ForwardedRef, HTMLAttributes, PropsWithChildren } from "react";
108
+
109
+ export interface MyComponentProps extends HTMLAttributes<HTMLDivElement> {}
110
+
111
+ export const MyComponent = forwardRef(
112
+ ({ children, ...restProps }: PropsWithChildren<MyComponentProps>, ref: ForwardedRef<HTMLDivElement>) => (
113
+ <div ref={ref} {...restProps}>
114
+ {children}
115
+ </div>
116
+ ),
117
+ );
118
+ ```
119
+
120
+ This allows front-end developers to perform actions that need access to the DOM, such as focusing an element:
121
+
122
+ ```tsx
123
+ const ref = useRef<HTMLDivElement>(null);
124
+
125
+ render(<MyComponent tabIndex={0} ref={ref} />);
126
+
127
+ ref.current?.focus();
128
+ ```
129
+
130
+ ## Don't break native HTML
131
+
132
+ ### Global attributes
133
+
134
+ Use `restProps` to allow front-end developers to global attributes as well as specific attributes to an HTML element:
135
+
136
+ ```jsx
137
+ import clsx from "clsx";
138
+
139
+ export const MyComponent = ({ children, ...restProps }) => <div {...restProps}>{children}</div>;
140
+ ```
141
+
142
+ With TypeScript you will need to extend the interface with the `HTMLAttributes` of the outermost element, and it will look like this:
143
+
144
+ ```tsx
145
+ import clsx from "clsx";
146
+ import type { HTMLAttributes, PropsWithChildren } from "react";
147
+
148
+ export interface MyComponentProps extends HTMLAttributes<HTMLDivElement> {}
149
+
150
+ export const MyComponent = ({ children, ...restProps }) => <div {...restProps}>{children}</div>;
151
+ ```
152
+
153
+ For different elements you need to import different types `HTMLAttributes`, but I don't think React offers documentation on this subject. The most effective approach might be using an IDE like Visual Code with a TypeScript plugin, to find out which interface you need — or simply check existing components that use the same HTML element.
154
+
155
+ ### Prevent duplicate IDs
156
+
157
+ Generate `id` attributes with [`useId()` from React](https://react.dev/reference/react/useId). Do not use hardcoded `id` values, because that could break accessibility.
158
+
159
+ ```jsx
160
+ export const MyLandmarkComponent = ({ children, label }) => {
161
+ const headingId = useId();
162
+ return (
163
+ <div role="region" aria-labelledby={label ? labelId : undefined}>
164
+ {label && <div id={labelId}>{label}</div>}
165
+ {children}
166
+ </div>
167
+ );
168
+ };
169
+ ```
package/README.md CHANGED
@@ -1,22 +1,12 @@
1
1
  <!-- @license CC0-1.0 -->
2
2
 
3
- # Component library for React apps
3
+ # Component library for React
4
4
 
5
- The `@utrecht/component-library-react` package contains React implementations of various components. You can use this package in React apps, both client side and server side, to render the right HTML elements with the Utrecht design system class names.
5
+ You can use React components from [`@utrecht/component-library-react` npm package](https://www.npmjs.com/package/@utrecht/component-library-react) for your website. The components are "white label", which means they do not have Utrecht branding you can choose your own design with design tokens.
6
6
 
7
- The CSS components that implement the Utrecht design system class names are published in a separate npm package, so don't forget to install and include `@utrecht/component-library-css` too for the styling of the white-label components, as well as a package with design tokens for your theme.
7
+ You can use this package in React apps, both client side and server side, to render the right HTML elements with the Utrecht design system class names.
8
8
 
9
- ## Stability of the components
10
-
11
- The React components are released as _alpha_ version, which means the components are still work in progress and it is likely that some APIs will between releases.
12
-
13
- Make sure you specify the exact version as dependency, so you can schedule to upgrade to the latest version when you have time to test for regression bugs.
14
-
15
- ## React Component or React Web Component?
16
-
17
- We currently have two packages with React components, and you might wonder which to choose. Our Web Components are still experimental and since the Shadow DOM prevents you from simply extending the CSS implementation, you wouldn't be able to easily tweak it to your needs. Therefore we suggest using the React components when they are available.
18
-
19
- In the future this advice might change since some components could be released exclusively as Web Component while others will remain available as CSS component with React wrapper only.
9
+ Documentation is in the [Storybook for Utrecht React components](http://nl-design-system.github.io/utrecht/storybook-react/).
20
10
 
21
11
  ## Getting started
22
12
 
@@ -27,8 +17,7 @@ npm install --save-dev --save-exact @utrecht/component-library-react
27
17
  With this package available, you can render any component from the library in your page. For example:
28
18
 
29
19
  ```jsx
30
- import { Document } from "@utrecht/component-library-react/Document";
31
- import { Heading1 } from "@utrecht/component-library-react/Heading1";
20
+ import { Document, Heading1 } from "@utrecht/component-library-react/dist/css-module";
32
21
 
33
22
  export const MyPage = () => (
34
23
  <Document>
@@ -37,6 +26,63 @@ export const MyPage = () => (
37
26
  );
38
27
  ```
39
28
 
29
+ If you don't want to use CSS injection, you can import the same components from another path (without `/dist/css-module`):
30
+
31
+ ```jsx
32
+ import { Document, Heading1 } from "@utrecht/component-library-react";
33
+
34
+ export const MyPage = () => (
35
+ <Document>
36
+ <Heading1>Page styled with NL Design System</Heading1>
37
+ </Document>
38
+ );
39
+ ```
40
+
41
+ ## Add the design using a theme
42
+
43
+ Add your own design using a theme.
44
+
45
+ 1. [Make your own theme based on design tokens.](https://nldesignsystem.nl/handboek/developer/thema-maken/)
46
+ 2. Load the CSS for your theme. It contains CSS variables for the visual design of the components.
47
+ 3. Insert the CSS class name for your theme in your HTML code, at the level above the components.
48
+
49
+ ### Add the Utrecht theme
50
+
51
+ Install the npm package that contains the CSS:
52
+
53
+ ```shell
54
+ npm install --save-dev @utrecht/design-tokens
55
+ ```
56
+
57
+ In many React projects it is possible to import the CSS file in JavaScript. Add the `import` for the theme CSS, and use the `utrecht-theme` class name at the level above the React components.
58
+
59
+ ```jsx
60
+ import { Document, Heading1 } from "@utrecht/component-library-react";
61
+ import "@utrecht/design-tokens/dist/index.css";
62
+
63
+ export const MyPage = () => (
64
+ <div className="utrecht-theme">
65
+ <Document>
66
+ <Heading1>Page styled with NL Design System</Heading1>
67
+ </Document>
68
+ </div>
69
+ );
70
+ ```
71
+
72
+ ## TypeScript
73
+
74
+ TypeScript declarations for React componenten are shipped by default in this package, you don't need to install them separately.
75
+
76
+ ## Support
77
+
78
+ Ask you support questions in the [#nl-design-system-developers Slack channel](https://codefornl.slack.com/archives/C01DAT4TRPF).
79
+
80
+ ## React Component or React Web Component?
81
+
82
+ We currently have two packages with React components, and you might wonder which to choose. Our Web Components are still experimental and since the Shadow DOM prevents you from simply extending the CSS implementation, you wouldn't be able to easily tweak it to your needs. Therefore we suggest using the React components when they are available.
83
+
84
+ In the future this advice might change since some components could be released exclusively as Web Component while others will remain available as CSS component with React wrapper only.
85
+
40
86
  Additionally you should also include the CSS for the components and the design tokens to configure the CSS components. For example:
41
87
 
42
88
  ```js
@@ -83,65 +129,8 @@ export const MyPage = () => (
83
129
  );
84
130
  ```
85
131
 
86
- ## Components overview
87
-
88
- We make components for React available when needed in a project. Not every component is available yet, and we welcome you to discuss contributions.
89
-
90
- Currently the following components are available:
91
-
92
- ```js
93
- import { Article } from "@utrecht/component-library-react/Article";
94
- import { Backdrop } from "@utrecht/component-library-react/Backdrop";
95
- import { Button } from "@utrecht/component-library-react/Button";
96
- import { Checkbox } from "@utrecht/component-library-react/Checkbox";
97
- import { Document } from "@utrecht/component-library-react/Document";
98
- import { Fieldset } from "@utrecht/component-library-react/Fieldset";
99
- import { FieldsetLegend } from "@utrecht/component-library-react/FieldsetLegend";
100
- import { FormField } from "@utrecht/component-library-react/FormField";
101
- import { FormFieldDescription } from "@utrecht/component-library-react/FormFieldDescription";
102
- import { FormLabel } from "@utrecht/component-library-react/FormLabel";
103
- import { HTMLContent } from "@utrecht/component-library-react/HTMLContent";
104
- import { Heading1 } from "@utrecht/component-library-react/Heading1";
105
- import { Heading2 } from "@utrecht/component-library-react/Heading2";
106
- import { Heading3 } from "@utrecht/component-library-react/Heading3";
107
- import { Heading4 } from "@utrecht/component-library-react/Heading4";
108
- import { Heading5 } from "@utrecht/component-library-react/Heading5";
109
- import { Heading6 } from "@utrecht/component-library-react/Heading6";
110
- import { Link } from "@utrecht/component-library-react/Link";
111
- import { OrderedList } from "@utrecht/component-library-react/OrderedList";
112
- import { OrderedListItem } from "@utrecht/component-library-react/OrderedListItem";
113
- import { Page } from "@utrecht/component-library-react/Page";
114
- import { PageContent } from "@utrecht/component-library-react/PageContent";
115
- import { PageFooter } from "@utrecht/component-library-react/PageFooter";
116
- import { PageHeader } from "@utrecht/component-library-react/PageHeader";
117
- import { Paragraph } from "@utrecht/component-library-react/Paragraph";
118
- import { RadioButton } from "@utrecht/component-library-react/RadioButton";
119
- import { Select, SelectOption } from "@utrecht/component-library-react/Select";
120
- import { Separator } from "@utrecht/component-library-react/Separator";
121
- import { Surface } from "@utrecht/component-library-react/Surface";
122
- import { Table } from "@utrecht/component-library-react/Table";
123
- import { TableBody } from "@utrecht/component-library-react/TableBody";
124
- import { TableCaption } from "@utrecht/component-library-react/TableCaption";
125
- import { TableCell } from "@utrecht/component-library-react/TableCell";
126
- import { TableFooter } from "@utrecht/component-library-react/TableFooter";
127
- import { TableHeader } from "@utrecht/component-library-react/TableHeader";
128
- import { TableHeaderCell } from "@utrecht/component-library-react/TableHeaderCell";
129
- import { TableRow } from "@utrecht/component-library-react/TableRow";
130
- import { Textarea } from "@utrecht/component-library-react/Textarea";
131
- import { Textbox } from "@utrecht/component-library-react/Textbox";
132
- import { URLData } from "@utrecht/component-library-react/URLData";
133
- import { UnorderedList } from "@utrecht/component-library-react/UnorderedList";
134
- import { UnorderedListItem } from "@utrecht/component-library-react/UnorderedListItem";
135
- ```
136
-
137
- Alternatively it is possible to include them via the collection of components too, but be careful: you will likely need to take additional steps prevent your site from also including the code for components you don't actually use. Including unused components would negatively impact the performance of your site.
138
-
139
- For example:
140
-
141
- ```js
142
- import { Document, Heading1, Link, Paragraph } from "@utrecht/component-library-react";
143
- ```
132
+ ## Stability of the components
144
133
 
145
- ## Contributing
134
+ Most components are used in production for Utrecht websites, but it is likely that some APIs will between releases. For breaking changes we release a new major version, so pay special attention to the changelog of major versions.
146
135
 
147
- When a project needs a component from the design system that already exists as CSS component with an HTML example, they will create a React component for it internally. Projects that have new React components can let the design system team know and create a pull request to include it in this component library. No
136
+ Make sure you specify the exact version as dependency, so you can schedule to upgrade to the latest version when you have time to test for regression bugs.
package/README.nl.md ADDED
@@ -0,0 +1,82 @@
1
+ <!-- @license CC0-1.0 -->
2
+
3
+ # Component library voor React
4
+
5
+ Je kunt de React componenten van de [`@utrecht/component-library-react` npm package](https://www.npmjs.com/package/@utrecht/component-library-react) gebruiken voor je eigen website. Het zijn "white label" componenten, dat betekent dat ze niet de Utrecht huisstijl hebben — je kunt je eigen ontwerp gebruiken met design tokens.
6
+
7
+ Je kunt deze package gebruiken in React apps, zowel client side als server side, om de juiste HTML elementen te renderen met CSS class names van het Utrecht Design System.
8
+
9
+ Documentation staat in de [Storybook voor Utrecht React componenten](http://nl-design-system.github.io/utrecht/storybook-react/).
10
+
11
+ ## Aan de slag
12
+
13
+ ```shell
14
+ npm install --save-dev --save-exact @utrecht/component-library-react
15
+ ```
16
+
17
+ Wanneer je dit pakketje hebt geïnstalleerd, dan kun je elke component uit de React component gebruiken voor je pagina. Bijvoorbeeld:
18
+
19
+ ```jsx
20
+ import { Document, Heading1 } from "@utrecht/component-library-react/dist/css-module";
21
+
22
+ export const MyPage = () => (
23
+ <div className="voorbeeld-theme">
24
+ <Document>
25
+ <Heading1>Page styled with NL Design System</Heading1>
26
+ </Document>
27
+ </div>
28
+ );
29
+ ```
30
+
31
+ Als je geen CSS injection wilt, dan kun je dezelfde componenten importeren uit een andere plek (zonder `/dist/css-module`). CSS injection levert soms problemen op bij websites met een stricte `Content-Security-Policy`.
32
+
33
+ ```jsx
34
+ import { Document, Heading1 } from "@utrecht/component-library-react";
35
+
36
+ export const MyPage = () => (
37
+ <div className="voorbeeld-theme">
38
+ <Document>
39
+ <Heading1>Page styled with NL Design System</Heading1>
40
+ </Document>
41
+ </div>
42
+ );
43
+ ```
44
+
45
+ ## Design toevoegen met een thema
46
+
47
+ Gebruik je eigen design met de volgende stappen:
48
+
49
+ 1. [Maak een eigen thema op basis van design tokens.](https://nldesignsystem.nl/handboek/developer/thema-maken/)
50
+ 2. Laad de CSS van je thema in. Daarin zitten de CSS variables voor het ontwerp van de componenten.
51
+ 3. Voeg in HTML de CSS class name toe van je theme, op het niveau boven je componenten.
52
+
53
+ ### Utrecht huisstijl toevoegen
54
+
55
+ Installeer de npm package met de CSS:
56
+
57
+ ```shell
58
+ npm install --save-dev @utrecht/design-tokens
59
+ ```
60
+
61
+ In veel React projecten is het mogelijk de CSS te importeren in JavaScript. Voeg de `import` voor de thema CSS toe, en gebruik de `utrecht-theme` class name op een niveau boven de React componenten.
62
+
63
+ ```jsx
64
+ import { Document, Heading1 } from "@utrecht/component-library-react";
65
+ import "@utrecht/design-tokens/dist/index.css";
66
+
67
+ export const MyPage = () => (
68
+ <div className="utrecht-theme">
69
+ <Document>
70
+ <Heading1>Page styled with NL Design System</Heading1>
71
+ </Document>
72
+ </div>
73
+ );
74
+ ```
75
+
76
+ ## TypeScript
77
+
78
+ De TypeScript declarations voor de React componenten worden standaard meegeleverd.
79
+
80
+ ## Support
81
+
82
+ Stel je support-vragen in het [#nl-design-system-developers Slack-kanaal](https://codefornl.slack.com/archives/C01DAT4TRPF).