@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.
Files changed (99) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +10 -10
  3. package/dist/components/Checkbox/Checkbox.d.ts +0 -1
  4. package/dist/components/ComponentWrapper/ComponentWrapper.d.ts +8 -0
  5. package/dist/components/Heading/Heading.d.ts +2 -0
  6. package/dist/components/Logo/Logo.d.ts +1 -1
  7. package/dist/components/Logo/LogoSvgs.d.ts +4 -0
  8. package/dist/design-system-react-components.cjs.development.js +1021 -683
  9. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  10. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  11. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  12. package/dist/design-system-react-components.esm.js +1022 -684
  13. package/dist/design-system-react-components.esm.js.map +1 -1
  14. package/dist/theme/components/button.d.ts +1 -0
  15. package/dist/theme/components/card.d.ts +98 -13
  16. package/dist/theme/components/checkboxGroup.d.ts +1 -1
  17. package/dist/theme/components/global.d.ts +1 -1
  18. package/dist/theme/components/heading.d.ts +4 -16
  19. package/dist/theme/components/image.d.ts +6 -0
  20. package/dist/theme/components/radioGroup.d.ts +1 -1
  21. package/dist/theme/components/skipNavigation.d.ts +3 -0
  22. package/dist/theme/components/structuredContent.d.ts +0 -5
  23. package/dist/utils/utils.d.ts +15 -0
  24. package/package.json +6 -6
  25. package/src/components/Accordion/Accordion.stories.mdx +18 -46
  26. package/src/components/Accordion/Accordion.tsx +3 -2
  27. package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +12 -12
  28. package/src/components/Button/Button.stories.mdx +1 -1
  29. package/src/components/ButtonGroup/ButtonGroup.stories.mdx +33 -2
  30. package/src/components/ButtonGroup/ButtonGroup.tsx +2 -1
  31. package/src/components/Card/Card.stories.mdx +2 -4
  32. package/src/components/Card/Card.tsx +2 -1
  33. package/src/components/Chakra/Box.stories.mdx +1 -1
  34. package/src/components/Chakra/Center.stories.mdx +1 -1
  35. package/src/components/Chakra/Flex.stories.mdx +1 -1
  36. package/src/components/Chakra/Grid.stories.mdx +1 -1
  37. package/src/components/Chakra/Stack.stories.mdx +1 -1
  38. package/src/components/Checkbox/Checkbox.stories.mdx +1 -1
  39. package/src/components/Checkbox/Checkbox.test.tsx +42 -11
  40. package/src/components/Checkbox/Checkbox.tsx +25 -39
  41. package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +589 -544
  42. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +1 -1
  43. package/src/components/CheckboxGroup/CheckboxGroup.tsx +1 -1
  44. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +1540 -1420
  45. package/src/components/ComponentWrapper/ComponentWrapper.tsx +12 -3
  46. package/src/components/ComponentWrapper/__snapshots__/ComponentWrapper.test.tsx.snap +5 -0
  47. package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +36 -17
  48. package/src/components/Grid/SimpleGrid.stories.mdx +1 -3
  49. package/src/components/Heading/Heading.stories.mdx +4 -1
  50. package/src/components/Heading/Heading.tsx +4 -1
  51. package/src/components/Image/Image.stories.mdx +1 -1
  52. package/src/components/Logo/Logo.stories.mdx +10 -5
  53. package/src/components/Logo/Logo.tsx +4 -0
  54. package/src/components/Logo/LogoSvgs.tsx +8 -0
  55. package/src/components/Modal/Modal.stories.mdx +83 -90
  56. package/src/components/Pagination/Pagination.stories.mdx +1 -1
  57. package/src/components/Radio/Radio.stories.mdx +1 -1
  58. package/src/components/Radio/Radio.tsx +22 -31
  59. package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +405 -365
  60. package/src/components/RadioGroup/RadioGroup.stories.mdx +2 -1
  61. package/src/components/RadioGroup/RadioGroup.tsx +2 -1
  62. package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +1236 -1116
  63. package/src/components/SearchBar/SearchBar.stories.mdx +3 -3
  64. package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +32 -10
  65. package/src/components/Select/Select.stories.mdx +1 -1
  66. package/src/components/Select/Select.tsx +24 -22
  67. package/src/components/Select/__snapshots__/Select.test.tsx.snap +21 -11
  68. package/src/components/SkipNavigation/SkipNavigation.stories.mdx +2 -2
  69. package/src/components/Slider/Slider.stories.mdx +1 -1
  70. package/src/components/Slider/Slider.tsx +14 -14
  71. package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +66 -33
  72. package/src/components/StyleGuide/Buttons.stories.mdx +1 -1
  73. package/src/components/StyleGuide/Colors.stories.mdx +2 -2
  74. package/src/components/StyleGuide/Forms.stories.mdx +2 -1
  75. package/src/components/StyleGuide/Iconography.stories.mdx +2 -2
  76. package/src/components/StyleGuide/Spacing.stories.mdx +1 -1
  77. package/src/components/StyleGuide/Typography.stories.mdx +1 -1
  78. package/src/components/Table/Table.stories.mdx +1 -5
  79. package/src/components/Table/Table.test.tsx +33 -0
  80. package/src/components/Table/Table.tsx +21 -0
  81. package/src/components/Template/Template.stories.mdx +9 -5
  82. package/src/components/TextInput/TextInput.stories.mdx +1 -1
  83. package/src/components/TextInput/TextInput.tsx +21 -21
  84. package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +19 -9
  85. package/src/components/Toggle/Toggle.stories.mdx +1 -1
  86. package/src/components/Toggle/Toggle.tsx +22 -20
  87. package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +400 -372
  88. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +1 -0
  89. package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +5 -0
  90. package/src/docs/Chakra.stories.mdx +2 -2
  91. package/src/theme/components/button.ts +1 -0
  92. package/src/theme/components/card.ts +9 -3
  93. package/src/theme/components/componentWrapper.ts +1 -1
  94. package/src/theme/components/global.ts +1 -1
  95. package/src/theme/components/heading.ts +3 -3
  96. package/src/theme/components/image.ts +1 -0
  97. package/src/theme/components/skipNavigation.ts +3 -0
  98. package/src/theme/foundations/colors.ts +6 -9
  99. package/src/utils/utils.ts +40 -0
@@ -98,6 +98,7 @@ is `16:9`.
98
98
  {...args}
99
99
  aspectRatio={args.aspectRatio}
100
100
  embedCode={args.embedCode}
101
+ videoId={args.videoId && args.videoId}
101
102
  videoType={args.videoType && args.videoType}
102
103
  />
103
104
  )}
@@ -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="styleprops" p="s" maxW="200px">
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="styleprops" p="s" maxW="200px">
453
+ <Button id="styled-button" p="s" maxH="none" maxW="200px">
454
454
  Button
455
455
  </Button>
456
456
  </DSProvider>
@@ -88,6 +88,7 @@ const iconOnly = {
88
88
  color: "inherit",
89
89
  _hover: {
90
90
  bg: "ui.gray.xx-light-cool",
91
+ borderColor: "ui.gray.medium",
91
92
  },
92
93
  paddingInlineStart: "inset.narrow",
93
94
  paddingInlineEnd: "inset.narrow",
@@ -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
- width: ["100%", "100%", "180px"],
116
- marginLeft: ["0", "0", "m"],
117
- marginTop: ["xs", "xs", "0"],
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",
@@ -6,7 +6,7 @@ const ComponentWrapper = {
6
6
  parts: ["helperErrorText"],
7
7
  baseStyle: ({ hasChildren }: ComponentWrapperProps) => ({
8
8
  helperErrorText: {
9
- marginTop: hasChildren ? "xs" : "0",
9
+ marginTop: hasChildren ? null : "0",
10
10
  },
11
11
  }),
12
12
  };
@@ -45,7 +45,7 @@ const checkboxRadioGroupStyles = (isFullWidth = false) => ({
45
45
  helperErrorText: {
46
46
  marginTop: "xs",
47
47
  },
48
- stack: {
48
+ label: {
49
49
  width: isFullWidth ? "100%" : "fit-content",
50
50
  },
51
51
  });
@@ -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
@@ -86,6 +86,7 @@ const CustomImage = {
86
86
  baseStyle: ({ size = "default" }: CustomImageBaseStyle) => ({
87
87
  figure: {
88
88
  margin: "auto",
89
+ width: "100%",
89
90
  ...imageSizes[size],
90
91
  img: {
91
92
  marginBottom: "xxs",
@@ -1,5 +1,8 @@
1
1
  const SkipNavigation = {
2
2
  baseStyle: {
3
+ ul: {
4
+ margin: "0",
5
+ },
3
6
  // Don't display links by default...
4
7
  a: {
5
8
  backgroundColor: "ui.white",
@@ -1,17 +1,14 @@
1
1
  import { Colors } from "@chakra-ui/react";
2
2
 
3
3
  /**
4
- * Colors taken from "../../styles/01-colors/*.scss"
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 Storybook:
7
- * https://nypl.github.io/nypl-design-system/storybook-static/?path=/story/documentation-style-guide-colors--colors-utility
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 Storybook:
12
- * https://nypl.github.io/nypl-design-system/storybook-static/?path=/story/documentation-style-guide-colors--colors-brand
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
@@ -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
+ };