@nypl/design-system-react-components 0.28.0 → 1.0.2
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 +39 -0
- package/README.md +10 -10
- package/dist/components/Checkbox/Checkbox.d.ts +0 -1
- package/dist/components/ComponentWrapper/ComponentWrapper.d.ts +8 -0
- package/dist/components/Heading/Heading.d.ts +2 -0
- package/dist/components/Logo/Logo.d.ts +1 -1
- package/dist/components/Logo/LogoSvgs.d.ts +4 -0
- package/dist/design-system-react-components.cjs.development.js +1021 -683
- 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 +1022 -684
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/theme/components/button.d.ts +1 -0
- package/dist/theme/components/card.d.ts +98 -13
- package/dist/theme/components/checkboxGroup.d.ts +1 -1
- package/dist/theme/components/global.d.ts +1 -1
- package/dist/theme/components/heading.d.ts +4 -16
- package/dist/theme/components/image.d.ts +6 -0
- package/dist/theme/components/radioGroup.d.ts +1 -1
- package/dist/theme/components/skipNavigation.d.ts +3 -0
- package/dist/theme/components/structuredContent.d.ts +0 -5
- package/dist/utils/utils.d.ts +15 -0
- package/package.json +6 -6
- package/src/components/Accordion/Accordion.stories.mdx +18 -46
- package/src/components/Accordion/Accordion.tsx +3 -2
- package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +12 -12
- package/src/components/Button/Button.stories.mdx +1 -1
- package/src/components/ButtonGroup/ButtonGroup.stories.mdx +33 -2
- package/src/components/ButtonGroup/ButtonGroup.tsx +2 -1
- package/src/components/Card/Card.stories.mdx +2 -4
- package/src/components/Card/Card.tsx +2 -1
- package/src/components/Chakra/Box.stories.mdx +1 -1
- package/src/components/Chakra/Center.stories.mdx +1 -1
- package/src/components/Chakra/Flex.stories.mdx +1 -1
- package/src/components/Chakra/Grid.stories.mdx +1 -1
- package/src/components/Chakra/Stack.stories.mdx +1 -1
- package/src/components/Checkbox/Checkbox.stories.mdx +1 -1
- package/src/components/Checkbox/Checkbox.test.tsx +42 -11
- package/src/components/Checkbox/Checkbox.tsx +25 -39
- package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +589 -544
- package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +1 -1
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +1 -1
- package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +1540 -1420
- package/src/components/ComponentWrapper/ComponentWrapper.tsx +12 -3
- package/src/components/ComponentWrapper/__snapshots__/ComponentWrapper.test.tsx.snap +5 -0
- package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +36 -17
- package/src/components/Grid/SimpleGrid.stories.mdx +1 -3
- package/src/components/Heading/Heading.stories.mdx +4 -1
- package/src/components/Heading/Heading.tsx +4 -1
- package/src/components/Image/Image.stories.mdx +1 -1
- package/src/components/Logo/Logo.stories.mdx +10 -5
- package/src/components/Logo/Logo.tsx +4 -0
- package/src/components/Logo/LogoSvgs.tsx +8 -0
- package/src/components/Modal/Modal.stories.mdx +83 -90
- package/src/components/Pagination/Pagination.stories.mdx +1 -1
- package/src/components/Radio/Radio.stories.mdx +1 -1
- package/src/components/Radio/Radio.tsx +22 -31
- package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +405 -365
- package/src/components/RadioGroup/RadioGroup.stories.mdx +2 -1
- package/src/components/RadioGroup/RadioGroup.tsx +2 -1
- package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +1236 -1116
- package/src/components/SearchBar/SearchBar.stories.mdx +3 -3
- package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +32 -10
- package/src/components/Select/Select.stories.mdx +1 -1
- package/src/components/Select/Select.tsx +24 -22
- package/src/components/Select/__snapshots__/Select.test.tsx.snap +21 -11
- package/src/components/SkipNavigation/SkipNavigation.stories.mdx +2 -2
- package/src/components/Slider/Slider.stories.mdx +1 -1
- package/src/components/Slider/Slider.tsx +14 -14
- package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +66 -33
- package/src/components/StyleGuide/Buttons.stories.mdx +1 -1
- package/src/components/StyleGuide/Colors.stories.mdx +2 -2
- package/src/components/StyleGuide/Forms.stories.mdx +2 -1
- package/src/components/StyleGuide/Iconography.stories.mdx +2 -2
- package/src/components/StyleGuide/Spacing.stories.mdx +1 -1
- package/src/components/StyleGuide/Typography.stories.mdx +1 -1
- package/src/components/Table/Table.stories.mdx +1 -5
- package/src/components/Table/Table.test.tsx +33 -0
- package/src/components/Table/Table.tsx +21 -0
- package/src/components/Template/Template.stories.mdx +9 -5
- package/src/components/TextInput/TextInput.stories.mdx +1 -1
- package/src/components/TextInput/TextInput.tsx +21 -21
- package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +19 -9
- package/src/components/Toggle/Toggle.stories.mdx +1 -1
- package/src/components/Toggle/Toggle.tsx +22 -20
- package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +400 -372
- package/src/components/VideoPlayer/VideoPlayer.stories.mdx +1 -0
- package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +5 -0
- package/src/docs/Chakra.stories.mdx +2 -2
- package/src/theme/components/button.ts +1 -0
- package/src/theme/components/card.ts +9 -3
- package/src/theme/components/componentWrapper.ts +1 -1
- package/src/theme/components/global.ts +1 -1
- package/src/theme/components/heading.ts +3 -3
- package/src/theme/components/image.ts +1 -0
- package/src/theme/components/skipNavigation.ts +3 -0
- package/src/theme/foundations/colors.ts +6 -9
- package/src/utils/utils.ts +40 -0
|
@@ -8,6 +8,7 @@ exports[`VideoPlayer renders the UI snapshot correctly 1`] = `
|
|
|
8
8
|
>
|
|
9
9
|
<div
|
|
10
10
|
className="css-1xdhyk6"
|
|
11
|
+
id="video-player-without-text-componentWrapper-wrapper"
|
|
11
12
|
>
|
|
12
13
|
<div
|
|
13
14
|
className="css-0"
|
|
@@ -33,6 +34,7 @@ exports[`VideoPlayer renders the UI snapshot correctly 2`] = `
|
|
|
33
34
|
>
|
|
34
35
|
<div
|
|
35
36
|
className="css-1xdhyk6"
|
|
37
|
+
id="video-player-with-text-componentWrapper-wrapper"
|
|
36
38
|
>
|
|
37
39
|
<h2
|
|
38
40
|
className="chakra-heading css-1xdhyk6"
|
|
@@ -81,6 +83,7 @@ exports[`VideoPlayer renders the UI snapshot correctly 3`] = `
|
|
|
81
83
|
>
|
|
82
84
|
<div
|
|
83
85
|
className="css-1xdhyk6"
|
|
86
|
+
id="video-player-with-text-componentWrapper-wrapper"
|
|
84
87
|
>
|
|
85
88
|
<h2
|
|
86
89
|
className="chakra-heading css-1xdhyk6"
|
|
@@ -144,6 +147,7 @@ exports[`VideoPlayer renders the UI snapshot correctly 5`] = `
|
|
|
144
147
|
>
|
|
145
148
|
<div
|
|
146
149
|
className="css-1xdhyk6"
|
|
150
|
+
id="chakra-componentWrapper-wrapper"
|
|
147
151
|
>
|
|
148
152
|
<div
|
|
149
153
|
className="css-0"
|
|
@@ -169,6 +173,7 @@ exports[`VideoPlayer renders the UI snapshot correctly 6`] = `
|
|
|
169
173
|
>
|
|
170
174
|
<div
|
|
171
175
|
className="css-1xdhyk6"
|
|
176
|
+
id="props-componentWrapper-wrapper"
|
|
172
177
|
>
|
|
173
178
|
<div
|
|
174
179
|
className="css-0"
|
|
@@ -444,13 +444,13 @@ In the following example, the `Button` component has been passed `p` and `maxW`
|
|
|
444
444
|
props which are shorthand for "padding" and "max-width", respectively.
|
|
445
445
|
|
|
446
446
|
```jsx
|
|
447
|
-
<Button id="
|
|
447
|
+
<Button id="styled-button" p="s" maxH="none" maxW="200px">
|
|
448
448
|
Button
|
|
449
449
|
</Button>
|
|
450
450
|
```
|
|
451
451
|
|
|
452
452
|
<DSProvider>
|
|
453
|
-
<Button id="
|
|
453
|
+
<Button id="styled-button" p="s" maxH="none" maxW="200px">
|
|
454
454
|
Button
|
|
455
455
|
</Button>
|
|
456
456
|
</DSProvider>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
interface CardBaseStyleProps {
|
|
2
2
|
hasImage: boolean;
|
|
3
3
|
imageIsAtEnd: boolean;
|
|
4
|
+
isAlignedRightActions: boolean;
|
|
4
5
|
isBordered: boolean;
|
|
5
6
|
isCentered: boolean;
|
|
6
7
|
layout: string;
|
|
@@ -69,6 +70,7 @@ const Card = {
|
|
|
69
70
|
baseStyle: ({
|
|
70
71
|
hasImage,
|
|
71
72
|
imageIsAtEnd,
|
|
73
|
+
isAlignedRightActions,
|
|
72
74
|
isBordered,
|
|
73
75
|
isCentered,
|
|
74
76
|
layout,
|
|
@@ -112,15 +114,19 @@ const Card = {
|
|
|
112
114
|
flexFlow: "column wrap",
|
|
113
115
|
textAlign: isCentered ? "center" : null,
|
|
114
116
|
actions: {
|
|
115
|
-
|
|
116
|
-
marginLeft:
|
|
117
|
-
marginTop:
|
|
117
|
+
flexShrink: { base: isAlignedRightActions ? "0" : null, md: "0" },
|
|
118
|
+
marginLeft: { base: "0", md: "m" },
|
|
119
|
+
marginTop: { base: "xs", md: "0" },
|
|
120
|
+
maxWidth: { base: "100%", md: "180px" },
|
|
121
|
+
width: "100%",
|
|
118
122
|
},
|
|
119
123
|
body: {
|
|
120
124
|
display: { md: "block" },
|
|
125
|
+
flexBasis: { sm: isRow ? "100%" : null },
|
|
121
126
|
flexFlow: { md: "row nowrap" },
|
|
122
127
|
margin: bodyMargin,
|
|
123
128
|
padding: bodyPadding,
|
|
129
|
+
width: { base: "100%", md: "auto" },
|
|
124
130
|
},
|
|
125
131
|
heading: {
|
|
126
132
|
marginBottom: "xs",
|
|
@@ -4,7 +4,6 @@ const margins = {
|
|
|
4
4
|
marginTop: "0",
|
|
5
5
|
marginLeft: "0",
|
|
6
6
|
marginRight: "0",
|
|
7
|
-
marginBottom: "s",
|
|
8
7
|
};
|
|
9
8
|
|
|
10
9
|
// Heading Styles
|
|
@@ -62,11 +61,12 @@ const variants = {
|
|
|
62
61
|
};
|
|
63
62
|
|
|
64
63
|
const Heading = {
|
|
65
|
-
baseStyle: {
|
|
64
|
+
baseStyle: ({ noSpace }) => ({
|
|
66
65
|
// This is to help target custom anchor elements
|
|
67
66
|
// passed as children to the Heading component.
|
|
68
67
|
a: baseLinkStyles,
|
|
69
|
-
|
|
68
|
+
marginBottom: noSpace ? "0" : "s",
|
|
69
|
+
}),
|
|
70
70
|
// Available variants:
|
|
71
71
|
// h1, h2, h3, h4, h5, h6,
|
|
72
72
|
// primary, secondary, tertiary, callout
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { Colors } from "@chakra-ui/react";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* All colors can be found in Storybook:
|
|
5
|
+
* https://nypl.github.io/nypl-design-system/reservoir/v1/?path=/docs/style-guide-colors--page
|
|
5
6
|
*
|
|
6
|
-
* All UI colors can be found in
|
|
7
|
-
* https://
|
|
8
|
-
* and in Figma:
|
|
9
|
-
* https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Master?node-id=14989%3A37
|
|
7
|
+
* All UI colors can be found in Figma:
|
|
8
|
+
* https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Main?node-id=47083%3A27674
|
|
10
9
|
*
|
|
11
|
-
* All Brand colors can be found in
|
|
12
|
-
* https://
|
|
13
|
-
* and in Figma:
|
|
14
|
-
* https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Master?node-id=15454%3A47007
|
|
10
|
+
* All Brand colors can be found in Figma:
|
|
11
|
+
* https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Main?node-id=15454%3A47007
|
|
15
12
|
*
|
|
16
13
|
* At the end of this file, there are objects that extend Chakra's default
|
|
17
14
|
* color shade palette for individual colors. WE DO NOT RECOMMEND to use them
|
package/src/utils/utils.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { HelperErrorTextType } from "../components/HelperErrorText/HelperErrorText";
|
|
2
|
+
import { AriaAttributes } from "./interfaces";
|
|
3
|
+
|
|
1
4
|
// Utility functions to use throughout the codebase
|
|
2
5
|
|
|
3
6
|
/**
|
|
@@ -42,3 +45,40 @@ export const getStorybookHrefProps = (pageCount: number) => {
|
|
|
42
45
|
|
|
43
46
|
return { computedCurrentPage, getPageHref };
|
|
44
47
|
};
|
|
48
|
+
|
|
49
|
+
interface GetAriaAttrsProps {
|
|
50
|
+
footnote: HelperErrorTextType;
|
|
51
|
+
id: string;
|
|
52
|
+
labelText: HelperErrorTextType;
|
|
53
|
+
name: string;
|
|
54
|
+
showLabel: boolean;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get aria-* attributes for input components. This sets the `aria-label` and
|
|
58
|
+
* `aria-describedby` attributes, based on the label and footnote values.
|
|
59
|
+
*/
|
|
60
|
+
export const getAriaAttrs = ({
|
|
61
|
+
footnote,
|
|
62
|
+
id,
|
|
63
|
+
labelText,
|
|
64
|
+
name,
|
|
65
|
+
showLabel,
|
|
66
|
+
}: GetAriaAttrsProps): AriaAttributes => {
|
|
67
|
+
let ariaAttributes: AriaAttributes = {};
|
|
68
|
+
|
|
69
|
+
if (!showLabel) {
|
|
70
|
+
if (typeof labelText !== "string") {
|
|
71
|
+
console.warn(
|
|
72
|
+
`NYPL Reservoir ${name}: \`labelText\` must be a string when \`showLabel\` is false.`
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
ariaAttributes["aria-label"] =
|
|
76
|
+
labelText && footnote
|
|
77
|
+
? `${labelText} - ${footnote}`
|
|
78
|
+
: (labelText as string);
|
|
79
|
+
} else if (footnote) {
|
|
80
|
+
ariaAttributes["aria-describedby"] = `${id}-helperText`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return ariaAttributes;
|
|
84
|
+
};
|