@nypl/design-system-react-components 0.25.0 → 0.25.1

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 (236) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/components/Accordion/Accordion.d.ts +14 -14
  3. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +11 -14
  4. package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +6 -0
  5. package/dist/components/Button/ButtonTypes.d.ts +2 -1
  6. package/dist/components/Card/Card.d.ts +1 -1
  7. package/dist/components/Card/CardTypes.d.ts +2 -2
  8. package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +43 -0
  9. package/dist/components/CheckboxGroup/CheckboxGroupLayoutTypes.d.ts +4 -0
  10. package/dist/components/DatePicker/DatePicker.d.ts +3 -3
  11. package/dist/components/Form/Form.d.ts +13 -8
  12. package/dist/components/Form/FormTypes.d.ts +2 -8
  13. package/dist/components/Grid/GridTypes.d.ts +9 -0
  14. package/dist/components/Grid/SimpleGrid.d.ts +14 -0
  15. package/dist/components/Heading/Heading.d.ts +4 -4
  16. package/dist/components/Hero/Hero.d.ts +19 -14
  17. package/dist/components/Hero/HeroTypes.d.ts +10 -5
  18. package/dist/components/Icons/Icon.d.ts +13 -16
  19. package/dist/components/Icons/IconTypes.d.ts +78 -64
  20. package/dist/components/Label/Label.d.ts +5 -17
  21. package/dist/components/Link/Link.d.ts +8 -12
  22. package/dist/components/SearchBar/SearchBar.d.ts +45 -27
  23. package/dist/components/Select/Select.d.ts +32 -35
  24. package/dist/components/Select/SelectTypes.d.ts +4 -0
  25. package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +1 -1
  26. package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +2 -2
  27. package/dist/components/StatusBadge/StatusBadge.d.ts +8 -6
  28. package/dist/components/StatusBadge/StatusBadgeTypes.d.ts +5 -0
  29. package/dist/components/Template/Template.d.ts +91 -0
  30. package/dist/components/Text/Text.d.ts +16 -0
  31. package/dist/components/Text/TextTypes.d.ts +6 -0
  32. package/dist/components/TextInput/TextInput.d.ts +32 -31
  33. package/dist/components/TextInput/TextInputTypes.d.ts +5 -0
  34. package/dist/design-system-react-components.cjs.development.js +2597 -1170
  35. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  36. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  37. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  38. package/dist/design-system-react-components.esm.js +2580 -1173
  39. package/dist/design-system-react-components.esm.js.map +1 -1
  40. package/dist/index.d.ts +8 -1
  41. package/dist/styles.css +1 -1
  42. package/dist/theme/components/accordion.d.ts +25 -0
  43. package/dist/theme/components/breadcrumb.d.ts +90 -0
  44. package/dist/theme/components/button.d.ts +17 -7
  45. package/dist/theme/components/checkbox.d.ts +7 -7
  46. package/dist/theme/components/customCheckboxGroup.d.ts +18 -0
  47. package/dist/theme/components/customRadioGroup.d.ts +4 -3
  48. package/dist/theme/components/global.d.ts +55 -0
  49. package/dist/theme/components/globalMixins.d.ts +15 -0
  50. package/dist/theme/components/heading.d.ts +50 -20
  51. package/dist/theme/components/hero.d.ts +492 -0
  52. package/dist/theme/components/icon.d.ts +13 -0
  53. package/dist/theme/components/label.d.ts +16 -0
  54. package/dist/theme/components/link.d.ts +45 -0
  55. package/dist/theme/components/radio.d.ts +8 -7
  56. package/dist/theme/components/searchBar.d.ts +20 -0
  57. package/dist/theme/components/select.d.ts +58 -0
  58. package/dist/theme/components/statusBadge.d.ts +25 -0
  59. package/dist/theme/components/tabs.d.ts +9 -9
  60. package/dist/theme/components/template.d.ts +105 -0
  61. package/dist/theme/components/text.d.ts +20 -0
  62. package/dist/theme/components/textInput.d.ts +105 -0
  63. package/dist/theme/foundations/global.d.ts +3 -0
  64. package/dist/theme/foundations/shadows.d.ts +4 -0
  65. package/dist/utils/utils.d.ts +6 -0
  66. package/package.json +3 -2
  67. package/src/components/Accordion/Accordion.stories.mdx +227 -33
  68. package/src/components/Accordion/Accordion.test.tsx +135 -19
  69. package/src/components/Accordion/Accordion.tsx +81 -56
  70. package/src/components/Autosuggest/Autosuggest.stories.mdx +1 -1
  71. package/src/components/Autosuggest/Autosuggest.stories.tsx +1 -1
  72. package/src/components/Autosuggest/_Autosuggest.scss +2 -2
  73. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +46 -52
  74. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +31 -25
  75. package/src/components/Breadcrumbs/Breadcrumbs.tsx +71 -73
  76. package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +6 -0
  77. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +100 -0
  78. package/src/components/Button/Button.stories.mdx +31 -27
  79. package/src/components/Button/Button.test.tsx +17 -5
  80. package/src/components/Button/ButtonTypes.tsx +1 -0
  81. package/src/components/Button/_Button.scss +3 -27
  82. package/src/components/Button/__snapshots__/Button.test.tsx.snap +11 -0
  83. package/src/components/Card/Card.stories.mdx +24 -20
  84. package/src/components/Card/Card.test.tsx +13 -19
  85. package/src/components/Card/Card.tsx +1 -1
  86. package/src/components/Card/CardTypes.tsx +2 -2
  87. package/src/components/Card/_Card.scss +1 -1
  88. package/src/components/CardEdition/CardEdition.stories.tsx +11 -6
  89. package/src/components/CardEdition/CardEdition.test.tsx +23 -31
  90. package/src/components/CardEdition/_CardEdition.scss +2 -2
  91. package/src/components/Chakra/Center.stories.mdx +31 -14
  92. package/src/components/Chakra/Grid.stories.mdx +79 -0
  93. package/src/components/Chakra/Stack.stories.mdx +4 -4
  94. package/src/components/Checkbox/Checkbox.tsx +9 -12
  95. package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +2 -5
  96. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +249 -0
  97. package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +345 -0
  98. package/src/components/CheckboxGroup/CheckboxGroup.tsx +148 -0
  99. package/src/components/CheckboxGroup/CheckboxGroupLayoutTypes.tsx +4 -0
  100. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +1360 -0
  101. package/src/components/DatePicker/DatePicker.test.tsx +4 -4
  102. package/src/components/DatePicker/DatePicker.tsx +13 -13
  103. package/src/components/DatePicker/_DatePicker.scss +1 -0
  104. package/src/components/Form/Form.stories.mdx +46 -21
  105. package/src/components/Form/Form.test.tsx +58 -45
  106. package/src/components/Form/Form.tsx +49 -21
  107. package/src/components/Form/FormTypes.tsx +3 -8
  108. package/src/components/Form/__snapshots__/Form.test.tsx.snap +24 -14
  109. package/src/components/Grid/GridTypes.tsx +9 -0
  110. package/src/components/Grid/SimpleGrid.stories.mdx +275 -0
  111. package/src/components/Grid/SimpleGrid.test.tsx +66 -0
  112. package/src/components/Grid/SimpleGrid.tsx +37 -0
  113. package/src/components/Grid/__snapshots__/SimpleGrid.test.tsx.snap +8 -0
  114. package/src/components/Heading/Heading.stories.mdx +1 -0
  115. package/src/components/Heading/Heading.tsx +12 -6
  116. package/src/components/HelperErrorText/_HelperErrorText.scss +1 -1
  117. package/src/components/Hero/Hero.stories.mdx +188 -121
  118. package/src/components/Hero/Hero.test.tsx +537 -107
  119. package/src/components/Hero/Hero.tsx +79 -92
  120. package/src/components/Hero/HeroTypes.tsx +17 -5
  121. package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +307 -0
  122. package/src/components/HorizontalRule/_HorizontalRule.scss +1 -1
  123. package/src/components/Icons/Icon.stories.mdx +83 -74
  124. package/src/components/Icons/Icon.test.tsx +30 -22
  125. package/src/components/Icons/Icon.tsx +63 -61
  126. package/src/components/Icons/IconTypes.tsx +80 -64
  127. package/src/components/Input/_Input.scss +2 -2
  128. package/src/components/Label/Label.stories.mdx +28 -7
  129. package/src/components/Label/Label.test.tsx +43 -12
  130. package/src/components/Label/Label.tsx +21 -34
  131. package/src/components/Label/__snapshots__/Label.test.tsx.snap +41 -0
  132. package/src/components/Link/Link.stories.mdx +41 -41
  133. package/src/components/Link/Link.test.tsx +33 -44
  134. package/src/components/Link/Link.tsx +114 -100
  135. package/src/components/List/List.stories.mdx +0 -2
  136. package/src/components/List/List.stories.tsx +5 -5
  137. package/src/components/List/_List.scss +3 -3
  138. package/src/components/Modal/_Modal.scss +1 -1
  139. package/src/components/Notification/Notification.stories.mdx +12 -1
  140. package/src/components/Notification/Notification.test.tsx +3 -16
  141. package/src/components/Notification/Notification.tsx +9 -10
  142. package/src/components/Notification/_Notification.scss +4 -4
  143. package/src/components/Pagination/Pagination.test.tsx +16 -10
  144. package/src/components/RadioGroup/RadioGroup.stories.mdx +1 -1
  145. package/src/components/RadioGroup/RadioGroup.tsx +2 -10
  146. package/src/components/SearchBar/SearchBar.Test.tsx +151 -16
  147. package/src/components/SearchBar/SearchBar.stories.mdx +189 -219
  148. package/src/components/SearchBar/SearchBar.tsx +151 -46
  149. package/src/components/Select/Select.stories.mdx +188 -170
  150. package/src/components/Select/Select.test.tsx +125 -380
  151. package/src/components/Select/Select.tsx +118 -165
  152. package/src/components/Select/SelectTypes.tsx +4 -0
  153. package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +13 -25
  154. package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +7 -7
  155. package/src/components/SkeletonLoader/SkeletonLoader.tsx +4 -2
  156. package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +2 -2
  157. package/src/components/SkeletonLoader/_SkeletonLoader.scss +3 -3
  158. package/src/components/StatusBadge/StatusBadge.stories.mdx +91 -0
  159. package/src/components/StatusBadge/StatusBadge.test.tsx +35 -7
  160. package/src/components/StatusBadge/StatusBadge.tsx +24 -25
  161. package/src/components/StatusBadge/StatusBadgeTypes.tsx +5 -0
  162. package/src/components/StatusBadge/__snapshots__/StatusBadge.test.tsx.snap +28 -0
  163. package/src/components/StyleGuide/Bidirectionality.stories.mdx +16 -16
  164. package/src/components/StyleGuide/Buttons.stories.mdx +15 -15
  165. package/src/components/StyleGuide/Colors.stories.mdx +336 -0
  166. package/src/components/StyleGuide/Iconography.stories.mdx +88 -90
  167. package/src/components/StyleGuide/UIDocCard.tsx +1 -1
  168. package/src/components/Tabs/Tabs.tsx +7 -9
  169. package/src/components/Template/Template.stories.mdx +574 -0
  170. package/src/components/Template/Template.test.tsx +124 -0
  171. package/src/components/Template/Template.tsx +226 -0
  172. package/src/components/Text/Text.stories.mdx +70 -0
  173. package/src/components/Text/Text.test.tsx +63 -0
  174. package/src/components/Text/Text.tsx +55 -0
  175. package/src/components/Text/TextTypes.tsx +6 -0
  176. package/src/components/Text/__snapshots__/Text.test.tsx.snap +33 -0
  177. package/src/components/TextInput/TextInput.stories.mdx +89 -90
  178. package/src/components/TextInput/TextInput.test.tsx +65 -86
  179. package/src/components/TextInput/TextInput.tsx +101 -95
  180. package/src/components/TextInput/TextInputTypes.tsx +6 -0
  181. package/src/components/VideoPlayer/_VideoPlayer.scss +1 -1
  182. package/src/docs/Chakra.stories.mdx +4 -4
  183. package/src/docs/Intro.stories.mdx +15 -13
  184. package/src/index.ts +20 -0
  185. package/src/styles/01-colors/_colors-brand.scss +6 -0
  186. package/src/styles/01-colors/_colors-utility.scss +14 -12
  187. package/src/styles/base/_04-base.scss +2 -1
  188. package/src/styles/base/_place-holder.scss +1 -1
  189. package/src/styles.scss +10 -12
  190. package/src/theme/components/accordion.ts +30 -0
  191. package/src/theme/components/breadcrumb.ts +77 -0
  192. package/src/theme/components/button.ts +77 -63
  193. package/src/theme/components/checkbox.ts +15 -27
  194. package/src/theme/components/customCheckboxGroup.ts +12 -0
  195. package/src/theme/components/customRadioGroup.ts +4 -10
  196. package/src/theme/components/global.ts +71 -0
  197. package/src/theme/components/globalMixins.ts +16 -0
  198. package/src/theme/components/heading.ts +15 -8
  199. package/src/theme/components/hero.ts +239 -0
  200. package/src/theme/components/icon.ts +79 -0
  201. package/src/theme/components/label.ts +17 -0
  202. package/src/theme/components/link.ts +47 -0
  203. package/src/theme/components/radio.ts +20 -31
  204. package/src/theme/components/searchBar.ts +21 -0
  205. package/src/theme/components/select.ts +50 -0
  206. package/src/theme/components/statusBadge.ts +27 -0
  207. package/src/theme/components/tabs.ts +72 -69
  208. package/src/theme/components/template.ts +114 -0
  209. package/src/theme/components/text.ts +31 -0
  210. package/src/theme/components/textInput.ts +61 -0
  211. package/src/theme/foundations/colors.ts +29 -13
  212. package/src/theme/foundations/global.ts +3 -0
  213. package/src/theme/foundations/shadows.ts +5 -0
  214. package/src/theme/index.ts +37 -7
  215. package/src/utils/componentCategories.ts +8 -2
  216. package/src/utils/utils.ts +13 -0
  217. package/dist/components/Accordion/Accordion.stories.d.ts +0 -6
  218. package/dist/components/StatusBadge/StatusBadge.stories.d.ts +0 -8
  219. package/dist/components/StyleGuide/Colors.stories.d.ts +0 -25
  220. package/dist/components/Template/Template.stories.d.ts +0 -30
  221. package/src/components/Accordion/Accordion.stories.tsx +0 -66
  222. package/src/components/Accordion/_Accordion.scss +0 -81
  223. package/src/components/Breadcrumbs/_Breadcrumbs.scss +0 -97
  224. package/src/components/Form/_Form.scss +0 -67
  225. package/src/components/Hero/_Hero.scss +0 -256
  226. package/src/components/Icons/_Icons.scss +0 -116
  227. package/src/components/Label/_Label.scss +0 -22
  228. package/src/components/Link/_Link.scss +0 -73
  229. package/src/components/SearchBar/_SearchBar.scss +0 -16
  230. package/src/components/Select/_Select.scss +0 -82
  231. package/src/components/StatusBadge/StatusBadge.stories.tsx +0 -34
  232. package/src/components/StatusBadge/_StatusBadge.scss +0 -23
  233. package/src/components/StyleGuide/Colors.stories.tsx +0 -289
  234. package/src/components/Template/Template.stories.tsx +0 -86
  235. package/src/components/Template/_Template.scss +0 -63
  236. package/src/components/TextInput/_TextInput.scss +0 -59
@@ -1,106 +1,111 @@
1
1
  import * as React from "react";
2
- import bem from "../../utils/bem";
3
- import { TextInputTypes, TextInputFormats } from "./TextInputTypes";
2
+ import {
3
+ Box,
4
+ Input as ChakraInput,
5
+ Textarea as ChakraTextarea,
6
+ useMultiStyleConfig,
7
+ } from "@chakra-ui/react";
8
+
9
+ import {
10
+ TextInputTypes,
11
+ TextInputFormats,
12
+ TextInputVariants,
13
+ } from "./TextInputTypes";
4
14
  import Label from "../Label/Label";
5
15
  import HelperErrorText from "../HelperErrorText/HelperErrorText";
6
16
  import generateUUID from "../../helpers/generateUUID";
7
17
 
8
18
  export interface InputProps {
9
- /** Additional attributes to pass to the `<input>` tag */
19
+ /** Additional attributes to pass to the `<input>` or `<textarea>` element */
10
20
  attributes?: { [key: string]: any };
11
- /** HTML Input types as defined by MDN: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input */
12
- type?: TextInputTypes;
13
- /** Will add 'aria-required: true' to input */
14
- required?: boolean;
21
+ /** A class name for the TextInput parent div. */
22
+ className?: string;
23
+ /** Populates the HelperErrorText for the standard state */
24
+ helperText?: string;
25
+ /** ID that other components can cross reference for accessibility purposes */
26
+ id?: string;
27
+ /** Populates the HelperErrorText for the error state */
28
+ invalidText?: string;
29
+ /** Adds the `disabled` and `aria-disabled` prop to the input when true */
30
+ isDisabled?: boolean;
31
+ /** Adds errored styling to the input/textarea and helper text elements */
32
+ isInvalid?: boolean;
33
+ /** Will add `required` and `aria-required` props to the input/textarea elements */
34
+ isRequired?: boolean;
15
35
  /** Provides text for a `Label` component if `showLabel` is set to true;
16
- * populates a `aria-label` sttribute if `showLabel` is set to false. */
36
+ * populates an `aria-label` attribute if `showLabel` is set to false. */
17
37
  labelText: string;
38
+ /** The action to perform on the `input`/`textarea`'s onChange function */
39
+ onChange?: (
40
+ event:
41
+ | React.ChangeEvent<HTMLInputElement>
42
+ | React.ChangeEvent<HTMLTextAreaElement>
43
+ ) => void;
44
+ /** Populates the placeholder for the input/textarea elements */
45
+ placeholder?: string;
18
46
  /** Offers the ability to show the label onscreen or hide it. Refer to the
19
47
  * `labelText` property for more information. */
20
48
  showLabel?: boolean;
21
49
  /** Offers the ability to show the "Required"/"Optional" label onscreen or
22
50
  * hide it. True by default. */
23
51
  showOptReqLabel?: boolean;
24
- /** Populates the HelperErrorText for standard state */
25
- helperText?: string;
26
- /** Populates the HelperErrorText for error state */
27
- invalidText?: string;
28
- /** Populates the placeholder of the input */
29
- placeholder?: string;
30
- /** Populates the value of the input */
52
+ /** HTML Input types as defined by MDN: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input */
53
+ type?: TextInputTypes;
54
+ /** Populates the value of the input/textarea elements */
31
55
  value?: string;
32
- /** className you can add in addition to 'textinput' */
33
- className?: string;
34
- /** ID that other components can cross reference for accessibility purposes */
35
- id?: string;
36
- /** Helper for modifiers array; adds 'errored' styling */
37
- errored?: boolean;
38
- /** Adds the 'disabled' prop to the input when true */
39
- disabled?: boolean;
40
- /** Modifiers array for use with BEM. See how to work with modifiers and BEM
41
- * here: http://getbem.com/introduction/ */
42
- modifiers?: string[];
43
- /** The action to perform on the `<input>`'s onChange function */
44
- onChange?: (
45
- event:
46
- | React.ChangeEvent<HTMLInputElement>
47
- | React.ChangeEvent<HTMLTextAreaElement>
48
- ) => void;
56
+ /** The variant to display. */
57
+ variantType?: TextInputVariants;
49
58
  }
50
59
 
51
- /** The type used for `ref`s. We want to extend both `input` and `textarea`
60
+ /**
61
+ * The type used for `ref`s. We want to extend both `input` and `textarea`
52
62
  * since both are available to create through `TextInput`.
53
63
  */
54
64
  export type TextInputRefType = HTMLInputElement & HTMLTextAreaElement;
55
65
 
56
- /** Renders either an `input` element with a specified type or a `textarea`
57
- * element. All types will render an accessible Label component and an optional
58
- * HelperErrorText component.
66
+ /**
67
+ * Renders either an `input` element with a specified type or a `textarea`
68
+ * element. All types will render an accessible `Label` component and an
69
+ * optional `HelperErrorText` component.
59
70
  */
60
71
  const TextInput = React.forwardRef<TextInputRefType, InputProps>(
61
72
  (props, ref: React.Ref<TextInputRefType>) => {
62
73
  const {
63
74
  attributes = {},
64
- type = TextInputTypes.text,
65
- required,
66
- labelText,
67
- showLabel = true,
68
- showOptReqLabel = true,
75
+ className,
69
76
  helperText,
77
+ id = generateUUID(),
70
78
  invalidText,
79
+ isDisabled = false,
80
+ isInvalid = false,
81
+ isRequired = false,
82
+ labelText,
83
+ onChange,
71
84
  placeholder,
85
+ showLabel = true,
86
+ showOptReqLabel = true,
87
+ type = TextInputTypes.text,
72
88
  value,
73
- className,
74
- disabled,
75
- errored,
76
- onChange,
77
- modifiers = [],
78
- id = generateUUID(),
89
+ variantType = TextInputVariants.Default,
79
90
  } = props;
80
-
91
+ const styles = useMultiStyleConfig("TextInput", { variant: variantType });
81
92
  const isTextArea = type === TextInputTypes.textarea;
82
93
  const isHidden = type === TextInputTypes.hidden;
83
- const optReqFlag = required ? "Required" : "Optional";
84
- const errorOutput = invalidText
94
+ const optReqFlag = isRequired ? "Required" : "Optional";
95
+ const finalInvalidText = invalidText
85
96
  ? invalidText
86
97
  : "There is an error related to this field.";
87
- let footnote;
98
+ let footnote: string | React.ReactNode = isInvalid
99
+ ? finalInvalidText
100
+ : helperText;
101
+ let fieldOutput;
88
102
  let options;
89
103
 
90
- if (!showLabel) attributes["aria-label"] = labelText;
91
- if (helperText) attributes["aria-describedby"] = helperText;
92
-
93
- if (errored) {
94
- modifiers.push("error");
95
- }
96
- if (isTextArea) {
97
- modifiers.push("textarea");
98
- }
99
-
100
- if (errored) {
101
- footnote = errorOutput;
102
- } else {
103
- footnote = helperText;
104
+ if (!showLabel) {
105
+ attributes["aria-label"] =
106
+ labelText && footnote ? `${labelText} - ${footnote}` : labelText;
107
+ } else if (helperText) {
108
+ attributes["aria-describedby"] = `${id}-helperText`;
104
109
  }
105
110
 
106
111
  if (
@@ -118,54 +123,55 @@ const TextInput = React.forwardRef<TextInputRefType, InputProps>(
118
123
  );
119
124
  }
120
125
 
121
- options = {
122
- id,
123
- className: bem("inputfield", modifiers, "", [className]),
124
- "aria-required": required,
125
- "aria-hidden": isHidden,
126
- disabled,
127
- required,
128
- placeholder,
129
- onChange,
130
- ref,
131
- ...attributes,
132
- };
126
+ // When the type is "hidden", the input element needs fewer attributes.
127
+ options = isHidden
128
+ ? { id, "aria-hidden": isHidden, onChange, ref }
129
+ : {
130
+ id,
131
+ "aria-required": isRequired,
132
+ isDisabled,
133
+ isRequired,
134
+ isInvalid,
135
+ placeholder,
136
+ onChange,
137
+ ref,
138
+ ...attributes,
139
+ };
133
140
  // For `input` and `textarea`, all attributes are the same but `input`
134
141
  // also needs `type` and `value` to render correctly.
135
142
  if (!isTextArea) {
136
143
  options = { type, value, ...options } as any;
144
+ fieldOutput = <ChakraInput {...options} __css={styles.input} />;
145
+ } else {
146
+ fieldOutput = (
147
+ <ChakraTextarea {...options} __css={styles.textarea}>
148
+ {value}
149
+ </ChakraTextarea>
150
+ );
137
151
  }
138
152
 
139
- const fieldOutput = React.createElement(
140
- isTextArea ? "textarea" : "input",
141
- options,
142
- isTextArea ? value : null
143
- );
144
-
145
- const transformedInput = (
146
- <div className="textinput">
153
+ return (
154
+ <Box __css={styles} className={className}>
147
155
  {labelText && showLabel && !isHidden && (
148
156
  <Label
149
157
  htmlFor={id}
150
158
  optReqFlag={showOptReqLabel && optReqFlag}
151
- id={id + `-label`}
159
+ id={`${id}-label`}
152
160
  >
153
161
  {labelText}
154
162
  </Label>
155
163
  )}
156
164
  {fieldOutput}
157
- {((helperText && !isHidden) || errored) && (
158
- <HelperErrorText isError={errored} id={id + `-helperText`}>
159
- {footnote}
160
- </HelperErrorText>
165
+ {footnote && !isHidden && (
166
+ <Box __css={styles.helper} aria-disabled={isDisabled}>
167
+ <HelperErrorText isError={isInvalid} id={`${id}-helperText`}>
168
+ {footnote}
169
+ </HelperErrorText>
170
+ </Box>
161
171
  )}
162
- </div>
172
+ </Box>
163
173
  );
164
-
165
- return transformedInput;
166
174
  }
167
175
  );
168
176
 
169
- TextInput.displayName = "TextInput";
170
-
171
177
  export default TextInput;
@@ -23,6 +23,12 @@ export enum TextInputFormats {
23
23
  url = "https://domain.com",
24
24
  }
25
25
 
26
+ export enum TextInputVariants {
27
+ Default = "default",
28
+ SearchBar = "searchBar",
29
+ SearchBarSelect = "searchBarSelect",
30
+ }
31
+
26
32
  /*
27
33
  export enum TextInputPatterns {
28
34
  // eslint-disable-next-line prettier/prettier
@@ -14,7 +14,7 @@
14
14
  }
15
15
 
16
16
  &--errored {
17
- background-color: var(--ui-gray-warm-light);
17
+ background-color: var(--ui-gray-light-warm);
18
18
  height: auto;
19
19
  padding: var(--space-s);
20
20
  }
@@ -211,11 +211,11 @@ the `variants` object as in the following example.
211
211
  @include button-base;
212
212
 
213
213
  background-color: var(--ui-white);
214
- border: 1px solid var(--ui-gray-light);
214
+ border: 1px solid var(--ui-gray-light-cool);
215
215
  color: inherit;
216
216
 
217
217
  &:hover {
218
- background-color: var(--ui-gray-xxlight);
218
+ background-color: var(--ui-gray-xx-light-cool);
219
219
  }
220
220
  }
221
221
 
@@ -227,10 +227,10 @@ const Button = {
227
227
  secondary: {
228
228
  bg: "ui.white",
229
229
  border: "1px solid",
230
- borderColor: "ui.gray.light",
230
+ borderColor: "ui.gray.light-cool",
231
231
  color: "inherit",
232
232
  _hover: {
233
- bg: "ui.gray.xxlight",
233
+ bg: "ui.gray.xx-light-cool",
234
234
  },
235
235
  },
236
236
  // ... other variants,
@@ -4,24 +4,26 @@ import { HeroTypes } from "../components/Hero/HeroTypes.tsx";
4
4
  import Heading from "../components/Heading/Heading.tsx";
5
5
  import Image from "../components/Image/Image.tsx";
6
6
  import getCSSVariable from "../helpers/getCSSVariable";
7
+ import DSProvider from "../theme/provider";
7
8
 
8
9
  <Meta title="Introduction" />
9
10
 
10
11
  # NYPL Design System
11
12
 
12
- <Hero
13
- heroType={HeroTypes.FiftyFifty}
14
- subHeaderText="With 92 locations across the Bronx, Manhattan, and Staten Island, The New York Public Library is an essential part of neighborhoods across the city. Visit us today."
15
- image={
16
- <Image
17
- src="https://cdn-d8.nypl.org/s3fs-public/styles/2_1_960/public/2020-07/SASB_06_29_2020_Lions_mask-00207%20copy_0.jpeg?h=c8e955ed&itok=n_GLQgoe"
18
- blockName="hero"
19
- alt=""
20
- />
21
- }
22
- backgroundColor={getCSSVariable("--section-books-and-more-primary")}
23
- foregroundColor={getCSSVariable("--ui-white")}
24
- />
13
+ <DSProvider>
14
+ <Hero
15
+ heroType={HeroTypes.FiftyFifty}
16
+ subHeaderText="With 92 locations across the Bronx, Manhattan, and Staten Island, The New York Public Library is an essential part of neighborhoods across the city. Visit us today."
17
+ image={
18
+ <Image
19
+ src="https://cdn-d8.nypl.org/s3fs-public/styles/2_1_960/public/2020-07/SASB_06_29_2020_Lions_mask-00207%20copy_0.jpeg?h=c8e955ed&itok=n_GLQgoe"
20
+ alt=""
21
+ />
22
+ }
23
+ backgroundColor={getCSSVariable("--section-books-and-more-primary")}
24
+ foregroundColor={getCSSVariable("--ui-white")}
25
+ />
26
+ </DSProvider>
25
27
 
26
28
  <br />
27
29
 
package/src/index.ts CHANGED
@@ -6,6 +6,8 @@ export {
6
6
  Box,
7
7
  Center,
8
8
  Circle,
9
+ Grid,
10
+ GridItem,
9
11
  Square,
10
12
  Stack,
11
13
  HStack,
@@ -28,10 +30,13 @@ export {
28
30
  } from "./components/Card/CardTypes";
29
31
  export { default as CardEdition } from "./components/CardEdition/CardEdition";
30
32
  export { default as Checkbox } from "./components/Checkbox/Checkbox";
33
+ export { default as CheckboxGroup } from "./components/CheckboxGroup/CheckboxGroup";
34
+ export { CheckboxGroupLayoutTypes } from "./components/CheckboxGroup/CheckboxGroupLayoutTypes";
31
35
  export { default as DatePicker } from "./components/DatePicker/DatePicker";
32
36
  export { DatePickerTypes } from "./components/DatePicker/DatePickerTypes";
33
37
  export { default as Form, FormField, FormRow } from "./components/Form/Form";
34
38
  export { FormSpacing } from "./components/Form/FormTypes";
39
+ export { GridGaps } from "./components/Grid/GridTypes";
35
40
  export { default as Heading } from "./components/Heading/Heading";
36
41
  export {
37
42
  HeadingDisplaySizes,
@@ -69,6 +74,7 @@ export { default as Radio } from "./components/Radio/Radio";
69
74
  export { default as RadioGroup } from "./components/RadioGroup/RadioGroup";
70
75
  export { RadioGroupLayoutTypes } from "./components/RadioGroup/RadioGroupLayoutTypes";
71
76
  export { default as SearchBar } from "./components/SearchBar/SearchBar";
77
+ export { default as SimpleGrid } from "./components/Grid/SimpleGrid";
72
78
  export { default as SkeletonLoader } from "./components/SkeletonLoader/SkeletonLoader";
73
79
  export {
74
80
  SkeletonLoaderImageRatios,
@@ -83,6 +89,20 @@ export {
83
89
  TabPanels,
84
90
  TabPanel,
85
91
  } from "./components/Tabs/Tabs";
92
+ export { default as Text } from "./components/Text/Text";
93
+ export { TextDisplaySizes } from "./components/Text/TextTypes";
94
+ export {
95
+ TemplateAppContainer,
96
+ Template,
97
+ TemplateHeader,
98
+ TemplateBreakout,
99
+ TemplateContent,
100
+ TemplateContentTop,
101
+ TemplateContentPrimary,
102
+ TemplateContentSidebar,
103
+ TemplateFooter,
104
+ } from "./components/Template/Template";
105
+
86
106
  export {
87
107
  default as TextInput,
88
108
  TextInputRefType,
@@ -22,6 +22,10 @@ $research-secondary: #006166;
22
22
  $locations-primary: $brand-primary;
23
23
  $locations-secondary: $brand-secondary;
24
24
 
25
+ // Blogs is used for Blog pages.
26
+ $blogs-primary: #e0e0e0;
27
+ $blogs-secondary: #bdbdbd;
28
+
25
29
  // Research libraries with specific brand colors to adhere to.
26
30
  $research-library-lpa: #005d53;
27
31
  $research-library-schomburg: #a03e31;
@@ -44,6 +48,8 @@ $colors: (
44
48
  research-secondary: $research-secondary,
45
49
  locations-primary: $locations-primary,
46
50
  locations-secondary: $locations-secondary,
51
+ blogs-primary: $blogs-primary,
52
+ blogs-secondary: $blogs-secondary,
47
53
  research-library-lpa: $research-library-lpa,
48
54
  research-library-schomburg: $research-library-schomburg,
49
55
  research-library-schwartzman: $research-library-schwartzman,
@@ -9,16 +9,17 @@ $white: #ffffff;
9
9
  $gray-xdark: #424242;
10
10
  $gray-dark: #616161;
11
11
  $gray-medium: #bdbdbd;
12
- $gray-light: #e0e0e0;
13
- $gray-warm-light: #efedeb;
14
- $gray-xlight: #f5f5f5;
15
- $gray-warm-xlight: #f8f8f7;
16
- $gray-xxlight: #fafafa;
12
+ $gray-light-cool: #e0e0e0;
13
+ $gray-light-warm: #efedeb;
14
+ $gray-x-light-cool: #f5f5f5;
15
+ $gray-x-light-warm: #f8f8f7;
16
+ $gray-xx-light-cool: #fafafa;
17
17
 
18
18
  // State and link utilities
19
19
  $disabled-primary: #e0e0e0;
20
20
  $disabled-secondary: #fafafa;
21
- $error: #97272c;
21
+ $error-primary: #97272c;
22
+ $error-secondary: #6f0106;
22
23
  $focus: #4181f1;
23
24
  $link-primary: #0576d3;
24
25
  $link-secondary: #004b98;
@@ -39,14 +40,15 @@ $colors: (
39
40
  gray-xdark: $gray-xdark,
40
41
  gray-dark: $gray-dark,
41
42
  gray-medium: $gray-medium,
42
- gray-light: $gray-light,
43
- gray-warm-light: $gray-warm-light,
44
- gray-xlight: $gray-xlight,
45
- gray-warm-xlight: $gray-warm-xlight,
46
- gray-xxlight: $gray-xxlight,
43
+ gray-light-cool: $gray-light-cool,
44
+ gray-light-warm: $gray-light-warm,
45
+ gray-x-light-cool: $gray-x-light-cool,
46
+ gray-x-light-warm: $gray-x-light-warm,
47
+ gray-xx-light-cool: $gray-xx-light-cool,
47
48
  disabled-primary: $disabled-primary,
48
49
  disabled-secondary: $disabled-secondary,
49
- error: $error,
50
+ error-primary: $error-primary,
51
+ error-secondary: $error-secondary,
50
52
  focus: $focus,
51
53
  link-primary: $link-primary,
52
54
  link-secondary: $link-secondary,
@@ -8,7 +8,8 @@
8
8
  font-weight: 300;
9
9
  line-height: 1.5;
10
10
 
11
- // Users with non-overlay scrollbars have a small horiznotal scrollbar from our breakout mixin. Fix identified here: https://cloudfour.com/thinks/breaking-out-with-viewport-units-and-calc/#one-big-dumb-caveat
11
+ // Users with non-overlay scrollbars have a small horizontal scrollbar from
12
+ // our breakout mixin. Fix identified here: https://cloudfour.com/thinks/breaking-out-with-viewport-units-and-calc/#one-big-dumb-caveat
12
13
  overflow-x: hidden;
13
14
 
14
15
  *,
@@ -1,5 +1,5 @@
1
1
  .placeholder {
2
- --color-place-holder: var(--ui-gray-light);
2
+ --color-place-holder: var(--ui-gray-light-cool);
3
3
 
4
4
  @include space-stack-page;
5
5
  @include space-inset-s;
package/src/styles.scss CHANGED
@@ -42,11 +42,8 @@
42
42
  @import "./styles/base/_card-grid";
43
43
  @import "./styles/base/_place-holder";
44
44
  @import "./styles/base/_typography";
45
- @import "./components/Icons/_Icons.scss";
46
45
  @import "./components/Button/_Button.scss";
47
- @import "./components/Link/_Link.scss";
48
46
  @import "./components/Input/_Input.scss";
49
- @import "./components/TextInput/_TextInput.scss";
50
47
  @import "./components/Autosuggest/_Autosuggest.scss";
51
48
 
52
49
  fieldset {
@@ -55,25 +52,26 @@ fieldset {
55
52
  }
56
53
  }
57
54
 
55
+ // Copied over from Label.scss
56
+ .fieldset {
57
+ @include fieldset-reset;
58
+ }
59
+
60
+ .legend {
61
+ border: 0;
62
+ font-weight: 500;
63
+ }
64
+
58
65
  // Order not important
59
- @import "./components/Accordion/_Accordion.scss";
60
- @import "./components/Breadcrumbs/_Breadcrumbs.scss";
61
66
  @import "./components/Card/_Card.scss";
62
67
  @import "./components/CardEdition/_CardEdition.scss";
63
68
  @import "./components/DatePicker/_DatePicker.scss";
64
- @import "./components/Form/_Form.scss";
65
69
  @import "./components/HelperErrorText/_HelperErrorText.scss";
66
- @import "./components/Hero/_Hero.scss";
67
70
  @import "./components/HorizontalRule/_HorizontalRule.scss";
68
71
  @import "./components/Image/_Image.scss";
69
- @import "./components/Label/_Label.scss";
70
72
  @import "./components/List/_List.scss";
71
73
  @import "./components/Modal/_Modal.scss";
72
74
  @import "./components/Notification/_Notification.scss";
73
75
  @import "./components/Pagination/_Pagination.scss";
74
- @import "./components/SearchBar/_SearchBar.scss";
75
- @import "./components/Select/_Select.scss";
76
76
  @import "./components/SkeletonLoader/_SkeletonLoader.scss";
77
- @import "./components/StatusBadge/_StatusBadge.scss";
78
- @import "./components/Template/_Template.scss";
79
77
  @import "./components/VideoPlayer/_VideoPlayer.scss";
@@ -0,0 +1,30 @@
1
+ const containerStyles = {
2
+ borderLeftWidth: "1px",
3
+ borderRightWidth: "1px",
4
+ borderColor: "ui.gray.medium",
5
+ width: "100%",
6
+ };
7
+ const buttonStyles = {
8
+ border: "none",
9
+ fontWeight: 500,
10
+ _hover: {
11
+ bg: "ui.gray.light-cool",
12
+ },
13
+ };
14
+ const panelStyles = {
15
+ paddingTop: "xs",
16
+ paddingRight: "xxxl",
17
+ paddingLeft: "s",
18
+ paddingBottom: "xs",
19
+ };
20
+
21
+ const Accordion = {
22
+ parts: ["container", "button", "panel"],
23
+ baseStyle: {
24
+ container: containerStyles,
25
+ button: buttonStyles,
26
+ panel: panelStyles,
27
+ },
28
+ };
29
+
30
+ export default Accordion;
@@ -0,0 +1,77 @@
1
+ // Variant styling
2
+ const booksAndMore = {
3
+ bg: "section.books-and-more.secondary",
4
+ };
5
+ const locations = {
6
+ bg: "section.locations.secondary",
7
+ };
8
+ const research = {
9
+ bg: "section.research.secondary",
10
+ };
11
+ const whatsOn = {
12
+ bg: "section.whats-on.secondary",
13
+ };
14
+
15
+ const Breadcrumb = {
16
+ baseStyle: {
17
+ bg: "ui.black",
18
+ color: "ui.white",
19
+ fontSize: "-1",
20
+ fontWeight: "regular",
21
+ paddingBottom: "xs",
22
+ paddingTop: "xs",
23
+ ol: {
24
+ alignItems: { base: "center", md: "unset" },
25
+ display: { base: "flex", md: "block" },
26
+ margin: "auto",
27
+ maxWidth: "1280px",
28
+ paddingLeft: "s",
29
+ paddingRight: "s",
30
+ },
31
+ a: {
32
+ _hover: {
33
+ color: "ui.gray.light-cool",
34
+ },
35
+ },
36
+ "li:last-child": {
37
+ fontWeight: { base: "regular", md: "bold" },
38
+ ".chakra-breadcrumb__link": {
39
+ _hover: {
40
+ cursor: "default",
41
+ textDecoration: "none",
42
+ },
43
+ },
44
+ ".icon": {
45
+ display: "none",
46
+ },
47
+ },
48
+ "li:not(:last-child)": {
49
+ display: { base: "none", md: "inline-block" },
50
+ a: {
51
+ marginRight: { base: "xs", md: "0" },
52
+ },
53
+ ".icon": {
54
+ display: { base: "inline", md: "none" },
55
+ },
56
+ "span:not(.breadcrumb-label)": {
57
+ marginInlineEnd: "xxs",
58
+ marginInlineStart: "xxs",
59
+ },
60
+ },
61
+ "li:nth-last-child(2)": {
62
+ display: "inline-block",
63
+ span: {
64
+ display: { base: "none", md: "inline" },
65
+ },
66
+ },
67
+ },
68
+ // Available variants:
69
+ variants: {
70
+ booksAndMore,
71
+ locations,
72
+ research,
73
+ whatsOn,
74
+ },
75
+ };
76
+
77
+ export default Breadcrumb;