@nypl/design-system-react-components 0.25.9 → 0.25.12

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 (163) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/README.md +4 -16
  3. package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +1 -0
  4. package/dist/components/DatePicker/DatePicker.d.ts +1 -1
  5. package/dist/components/Fieldset/Fieldset.d.ts +1 -3
  6. package/dist/components/Form/Form.d.ts +13 -12
  7. package/dist/components/Form/FormTypes.d.ts +2 -2
  8. package/dist/components/HorizontalRule/HorizontalRule.d.ts +1 -1
  9. package/dist/components/Icons/IconTypes.d.ts +9 -7
  10. package/dist/components/List/List.d.ts +1 -1
  11. package/dist/components/Logo/LogoSvgs.d.ts +23 -1
  12. package/dist/components/Logo/LogoTypes.d.ts +23 -1
  13. package/dist/components/Notification/Notification.d.ts +2 -0
  14. package/dist/components/Pagination/Pagination.d.ts +6 -2
  15. package/dist/components/RadioGroup/RadioGroup.d.ts +3 -3
  16. package/dist/components/SearchBar/SearchBar.d.ts +6 -6
  17. package/dist/components/Select/Select.d.ts +4 -0
  18. package/dist/components/Table/Table.d.ts +9 -3
  19. package/dist/components/Template/Template.d.ts +24 -5
  20. package/dist/design-system-react-components.cjs.development.js +2063 -548
  21. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  22. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  23. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  24. package/dist/design-system-react-components.esm.js +2056 -554
  25. package/dist/design-system-react-components.esm.js.map +1 -1
  26. package/dist/index.d.ts +4 -4
  27. package/dist/resources.scss +0 -2
  28. package/dist/styles.css +1 -1
  29. package/dist/theme/components/breadcrumb.d.ts +4 -1
  30. package/dist/theme/components/checkbox.d.ts +0 -2
  31. package/dist/theme/components/customTable.d.ts +12 -3
  32. package/dist/theme/components/fieldset.d.ts +2 -0
  33. package/dist/theme/components/global.d.ts +15 -14
  34. package/dist/theme/components/globalMixins.d.ts +8 -8
  35. package/dist/theme/components/list.d.ts +6 -0
  36. package/dist/theme/components/notification.d.ts +16 -4
  37. package/dist/theme/components/radio.d.ts +3 -2
  38. package/dist/theme/components/searchBar.d.ts +4 -0
  39. package/dist/theme/components/select.d.ts +2 -9
  40. package/dist/theme/components/slider.d.ts +8 -4
  41. package/dist/theme/components/structuredContent.d.ts +9 -9
  42. package/dist/theme/components/textInput.d.ts +10 -12
  43. package/dist/theme/components/toggle.d.ts +6 -2
  44. package/dist/theme/foundations/global.d.ts +31 -3
  45. package/dist/utils/utils.d.ts +10 -0
  46. package/package.json +40 -36
  47. package/src/components/Accordion/Accordion.stories.mdx +1 -1
  48. package/src/components/Accordion/Accordion.test.tsx +45 -1
  49. package/src/components/Accordion/Accordion.tsx +20 -8
  50. package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +243 -0
  51. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +30 -2
  52. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +25 -0
  53. package/src/components/Breadcrumbs/Breadcrumbs.tsx +9 -3
  54. package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +1 -0
  55. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +104 -5
  56. package/src/components/Card/Card.stories.mdx +1 -1
  57. package/src/components/Card/Card.tsx +4 -1
  58. package/src/components/Card/__snapshots__/Card.test.tsx.snap +1 -1
  59. package/src/components/Chakra/Flex.stories.mdx +113 -0
  60. package/src/components/Checkbox/Checkbox.stories.mdx +1 -1
  61. package/src/components/Checkbox/Checkbox.tsx +1 -0
  62. package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +6 -6
  63. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +1 -1
  64. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +18 -18
  65. package/src/components/DatePicker/DatePicker.stories.mdx +1 -1
  66. package/src/components/DatePicker/DatePicker.test.tsx +6 -6
  67. package/src/components/DatePicker/DatePicker.tsx +12 -10
  68. package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +28 -20
  69. package/src/components/Fieldset/Fieldset.stories.mdx +1 -1
  70. package/src/components/Fieldset/Fieldset.tsx +2 -4
  71. package/src/components/Form/Form.stories.mdx +34 -16
  72. package/src/components/Form/Form.test.tsx +92 -3
  73. package/src/components/Form/Form.tsx +25 -21
  74. package/src/components/Form/FormTypes.tsx +2 -2
  75. package/src/components/Form/__snapshots__/Form.test.tsx.snap +0 -1
  76. package/src/components/HelperErrorText/HelperErrorText.stories.mdx +1 -1
  77. package/src/components/Hero/Hero.stories.mdx +1 -1
  78. package/src/components/HorizontalRule/HorizontalRule.stories.mdx +3 -2
  79. package/src/components/HorizontalRule/HorizontalRule.tsx +2 -2
  80. package/src/components/HorizontalRule/__snapshots__/HorizontalRule.test.tsx.snap +4 -4
  81. package/src/components/Icons/Icon.stories.mdx +1 -1
  82. package/src/components/Icons/Icon.test.tsx +1 -1
  83. package/src/components/Icons/Icon.tsx +1 -1
  84. package/src/components/Icons/IconTypes.tsx +8 -6
  85. package/src/components/List/List.stories.mdx +24 -5
  86. package/src/components/List/List.test.tsx +1 -1
  87. package/src/components/List/List.tsx +2 -2
  88. package/src/components/List/__snapshots__/List.test.tsx.snap +3 -1
  89. package/src/components/Logo/Logo.stories.mdx +7 -5
  90. package/src/components/Logo/LogoSvgs.tsx +45 -1
  91. package/src/components/Logo/LogoTypes.tsx +22 -0
  92. package/src/components/Notification/Notification.stories.mdx +73 -1
  93. package/src/components/Notification/Notification.test.tsx +64 -5
  94. package/src/components/Notification/Notification.tsx +21 -11
  95. package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +103 -8
  96. package/src/components/Pagination/Pagination.stories.mdx +54 -12
  97. package/src/components/Pagination/Pagination.test.tsx +63 -5
  98. package/src/components/Pagination/Pagination.tsx +46 -24
  99. package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +3 -3
  100. package/src/components/Radio/Radio.stories.mdx +1 -1
  101. package/src/components/Radio/Radio.tsx +1 -0
  102. package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +5 -5
  103. package/src/components/RadioGroup/RadioGroup.stories.mdx +1 -1
  104. package/src/components/RadioGroup/RadioGroup.test.tsx +13 -11
  105. package/src/components/RadioGroup/RadioGroup.tsx +88 -89
  106. package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +18 -18
  107. package/src/components/SearchBar/SearchBar.Test.tsx +124 -28
  108. package/src/components/SearchBar/SearchBar.stories.mdx +9 -6
  109. package/src/components/SearchBar/SearchBar.tsx +24 -23
  110. package/src/components/Select/Select.stories.mdx +1 -1
  111. package/src/components/Select/Select.test.tsx +89 -0
  112. package/src/components/Select/Select.tsx +11 -2
  113. package/src/components/Select/__snapshots__/Select.test.tsx.snap +545 -0
  114. package/src/components/Slider/Slider.stories.mdx +1 -1
  115. package/src/components/Slider/Slider.tsx +4 -1
  116. package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +7 -0
  117. package/src/components/StructuredContent/StructuredContent.stories.mdx +1 -1
  118. package/src/components/StyleGuide/Bidirectionality.stories.mdx +4 -4
  119. package/src/components/StyleGuide/Colors.stories.mdx +33 -18
  120. package/src/components/Table/Table.stories.mdx +118 -19
  121. package/src/components/Table/Table.test.tsx +80 -3
  122. package/src/components/Table/Table.tsx +26 -16
  123. package/src/components/Table/__snapshots__/Table.test.tsx.snap +1179 -0
  124. package/src/components/Tabs/Tabs.stories.mdx +1 -1
  125. package/src/components/Tabs/Tabs.test.tsx +21 -5
  126. package/src/components/Tabs/Tabs.tsx +35 -20
  127. package/src/components/Tabs/__snapshots__/Tabs.test.tsx.snap +195 -0
  128. package/src/components/Template/Template.stories.mdx +79 -4
  129. package/src/components/Template/Template.test.tsx +65 -3
  130. package/src/components/Template/Template.tsx +60 -14
  131. package/src/components/Template/__snapshots__/Template.test.tsx.snap +94 -1
  132. package/src/components/TextInput/TextInput.stories.mdx +1 -1
  133. package/src/components/Toggle/Toggle.stories.mdx +1 -1
  134. package/src/components/Toggle/Toggle.tsx +2 -1
  135. package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +4 -4
  136. package/src/docs/Chakra.stories.mdx +1 -1
  137. package/src/index.ts +8 -2
  138. package/src/styles/base/_place-holder.scss +2 -0
  139. package/src/styles.scss +0 -2
  140. package/src/theme/components/breadcrumb.ts +5 -1
  141. package/src/theme/components/checkbox.ts +3 -7
  142. package/src/theme/components/customTable.ts +16 -3
  143. package/src/theme/components/fieldset.ts +2 -0
  144. package/src/theme/components/global.ts +19 -16
  145. package/src/theme/components/globalMixins.ts +8 -8
  146. package/src/theme/components/list.ts +6 -2
  147. package/src/theme/components/notification.ts +21 -8
  148. package/src/theme/components/radio.ts +3 -6
  149. package/src/theme/components/searchBar.ts +4 -0
  150. package/src/theme/components/select.ts +3 -3
  151. package/src/theme/components/slider.ts +12 -9
  152. package/src/theme/components/structuredContent.ts +26 -6
  153. package/src/theme/components/textInput.ts +3 -2
  154. package/src/theme/components/toggle.ts +42 -38
  155. package/src/theme/foundations/colors.ts +19 -12
  156. package/src/theme/foundations/global.ts +17 -5
  157. package/src/theme/foundations/typography.ts +2 -2
  158. package/src/utils/componentCategories.ts +2 -1
  159. package/src/utils/utils.ts +28 -0
  160. package/dist/components/Pagination/Pagination.stories.d.ts +0 -13
  161. package/src/components/Pagination/Pagination.stories.tsx +0 -54
  162. package/src/styles/base/_03-base.scss +0 -25
  163. package/src/styles/base/_04-focus.scss +0 -22
@@ -2,6 +2,14 @@
2
2
  * These objects are also SCSS mixins but are now JS objects in the
3
3
  * context of css-in-js and the custom NYPL-theme.
4
4
  */
5
+ const screenreaderOnly = {
6
+ clip: "rect(1px, 1px, 1px, 1px)",
7
+ height: "1px",
8
+ overflow: "hidden",
9
+ position: "absolute !important",
10
+ width: "1px",
11
+ wordWrap: "normal",
12
+ };
5
13
  const wrapperStyles = {
6
14
  marginY: "0",
7
15
  marginX: "auto",
@@ -12,13 +20,5 @@ const wrapperStyles = {
12
20
  paddingLeft: "0",
13
21
  width: "100%",
14
22
  };
15
- const screenreaderOnly = {
16
- clip: "rect(1px, 1px, 1px, 1px)",
17
- height: "1px",
18
- overflow: "hidden",
19
- position: "absolute !important",
20
- width: "1px",
21
- wordWrap: "normal",
22
- };
23
23
 
24
24
  export { screenreaderOnly, wrapperStyles };
@@ -1,3 +1,5 @@
1
+ import { textMargin } from "./global";
2
+
1
3
  const List = {
2
4
  baseStyle: ({ inline, noStyling }) => ({
3
5
  // Browser automatically applies margin, so by default we unset it.
@@ -8,15 +10,16 @@ const List = {
8
10
  padding: noStyling ? "0" : null,
9
11
  display: inline ? "flex" : null,
10
12
  li: {
11
- marginRight: inline ? "xs" : null,
13
+ marginRight: inline ? "m" : null,
12
14
  listStyleType: inline ? "none" : null,
13
15
  _notFirst: {
14
- marginTop: "xxs",
16
+ marginTop: inline ? null : "xxs",
15
17
  },
16
18
  },
17
19
  }),
18
20
  variants: {
19
21
  ul: ({ noStyling }) => ({
22
+ ...textMargin,
20
23
  listStyle: "none",
21
24
  li: {
22
25
  _before: {
@@ -33,6 +36,7 @@ const List = {
33
36
  },
34
37
  },
35
38
  }),
39
+ ol: textMargin,
36
40
  dl: {
37
41
  borderBottom: "1px solid",
38
42
  borderColor: "ui.gray.light-cool",
@@ -2,31 +2,34 @@ import { NotificationTypes } from "../../components/Notification/NotificationTyp
2
2
 
3
3
  const Notification = {
4
4
  parts: ["container", "dismissibleButton", "icon"],
5
- baseStyle: ({ centered, noMargin, notificationType }) => {
5
+ baseStyle: ({ centered, dismissible, noMargin, notificationType }) => {
6
6
  let bg = "ui.status.primary";
7
- if (notificationType === NotificationTypes.Announcement) {
8
- bg = "ui.gray.light-cool";
9
- } else if (notificationType === NotificationTypes.Warning) {
10
- bg = "ui.gray.xx-light-cool";
7
+ if (
8
+ notificationType === NotificationTypes.Announcement ||
9
+ notificationType === NotificationTypes.Warning
10
+ ) {
11
+ bg = "ui.gray.x-light-cool";
11
12
  }
12
13
  return {
13
14
  bg,
14
15
  display: "flex",
15
16
  fontSize: "-1", // slightly smaller than the default size
16
- padding: "var(--nypl-space-s) var(--nypl-space-l)",
17
17
  position: "relative",
18
18
  textAlign: centered ? "center" : null,
19
19
  borderRadius: noMargin ? "0" : "4px",
20
20
  margin: noMargin ? "0" : "s",
21
21
  container: {
22
22
  margin: "auto",
23
+ maxWidth: "var(--nypl-breakpoint-xl)",
24
+ padding: "s",
25
+ paddingRight: dismissible ? "l" : null,
26
+ paddingLeft: centered && dismissible ? "l" : null,
23
27
  width: "100%",
24
- maxWidth: "var(--nypl-breakpoint-large)",
25
28
  },
26
29
  dismissibleButton: {
27
30
  border: "none",
28
- alignItems: "center",
29
31
  bgColor: "inherit",
32
+ alignItems: "center",
30
33
  color: "ui.black",
31
34
  display: "flex",
32
35
  height: "32px",
@@ -35,6 +38,9 @@ const Notification = {
35
38
  position: "absolute",
36
39
  right: "0",
37
40
  top: "0",
41
+ svg: {
42
+ marginTop: "0",
43
+ },
38
44
  _hover: {
39
45
  bg: "inherit",
40
46
  },
@@ -62,6 +68,13 @@ const NotificationContent = {
62
68
  ? "calc(var(--nypl-space-m) + var(--nypl-space-s))"
63
69
  : null,
64
70
  width: "100%",
71
+ // Links should always be black and underlined.
72
+ a: {
73
+ color: "ui.black",
74
+ _hover: {
75
+ color: "ui.black",
76
+ },
77
+ },
65
78
  },
66
79
  }),
67
80
  };
@@ -67,14 +67,10 @@ const baseStyleControl = {
67
67
  };
68
68
 
69
69
  // Style object for the Radio's label
70
- const baseStyleLabel = {
71
- ...checkboxRadioLabelStyles,
72
- };
70
+ const baseStyleLabel = checkboxRadioLabelStyles;
73
71
 
74
72
  // Style object for the Radio's helper text
75
- const baseStyleHelper = {
76
- ...checkboxRadioHelperStyle,
77
- };
73
+ const baseStyleHelper = checkboxRadioHelperStyle;
78
74
 
79
75
  const baseStyle = {
80
76
  // Chakra-inserted elements in the Chakra Radio component
@@ -90,6 +86,7 @@ const sizes = {
90
86
  control: {
91
87
  ...checkboxRadioControlSize,
92
88
  },
89
+ label: { fontSize: "label.default" },
93
90
  },
94
91
  };
95
92
 
@@ -1,4 +1,5 @@
1
1
  const SearchBar = {
2
+ parts: ["select"],
2
3
  baseStyle: {
3
4
  display: "flex",
4
5
  marginBottom: {
@@ -9,6 +10,9 @@ const SearchBar = {
9
10
  base: "column nowrap",
10
11
  md: "row nowrap",
11
12
  },
13
+ select: {
14
+ marginBottom: "0",
15
+ },
12
16
  },
13
17
  };
14
18
 
@@ -4,15 +4,15 @@ const select = {
4
4
  backgroundColor: "ui.white",
5
5
  borderRadius: "sm",
6
6
  borderColor: "ui.gray.medium",
7
+ fontSize: "text.caption",
7
8
  paddingTop: "xs",
8
9
  paddingRight: "xl",
9
10
  paddingBottom: "xs",
10
11
  paddingLeft: "s",
11
12
  _hover: {
12
- borderColor: "ui.gray.medium",
13
+ borderColor: "ui.gray.dark",
13
14
  },
14
- _active: activeFocus,
15
- _focus: activeFocus,
15
+ _active: activeFocus(),
16
16
  _disabled: {
17
17
  color: "ui.gray.xdark",
18
18
  bg: "ui.gray.xx-light-cool",
@@ -3,7 +3,7 @@ const staticValues = {
3
3
  marginTop: "xs",
4
4
  marginBottom: "xs",
5
5
  marginRight: "s",
6
- marginLeft: "s",
6
+ marginLeft: "0",
7
7
  };
8
8
  const CustomSlider = {
9
9
  parts: [
@@ -12,11 +12,12 @@ const CustomSlider = {
12
12
  "leftValue",
13
13
  "rightValue",
14
14
  "textInput",
15
+ "sliderContainer",
15
16
  "filledTrack",
16
17
  "track",
17
18
  "thumb",
18
19
  ],
19
- baseStyle: ({ isDisabled, isInvalid, isRangeSlider, showBoxes }) => {
20
+ baseStyle: ({ isDisabled, isInvalid, showBoxes, showValues }) => {
20
21
  let baseColor = "ui.link.primary";
21
22
  if (isInvalid) {
22
23
  baseColor = "ui.error.primary";
@@ -32,15 +33,10 @@ const CustomSlider = {
32
33
  helper: {
33
34
  marginTop: "xs",
34
35
  },
35
- leftValue: {
36
- ...staticValues,
37
- // If the text input boxes are shown, then there already is a
38
- // margin, so we can set this static value to "0". But for the
39
- // single Slider, we *do* need the margin set.
40
- marginLeft: showBoxes && isRangeSlider ? "0" : "s",
41
- },
36
+ leftValue: staticValues,
42
37
  rightValue: {
43
38
  ...staticValues,
39
+ marginLeft: "s",
44
40
  // If the text input boxes are shown, then there already is
45
41
  // a margin, so we can set this static value to "0".
46
42
  marginRight: showBoxes ? "0" : "s",
@@ -51,6 +47,13 @@ const CustomSlider = {
51
47
  minWidth: "65px",
52
48
  color: isInvalid ? "ui.error.primary" : "ui.black",
53
49
  },
50
+ // This is added to the container so that the slider thumbs don't
51
+ // overflow past the container when the value boxes or min/max values
52
+ // are not shown.
53
+ sliderContainer: {
54
+ marginLeft: !showValues ? "xs" : null,
55
+ marginRight: !showBoxes && !showValues ? "xs" : null,
56
+ },
54
57
  // Filled track doesn't have a _disabled or _invalid state...
55
58
  // so we manually do it through the props.
56
59
  filledTrack: {
@@ -3,19 +3,29 @@ const StructuredContent = {
3
3
  baseStyle: ({ hasFigureImage, imageAspectRatio, imagePosition }) => {
4
4
  const styles: { maxWidth?: string } = {};
5
5
  const wrapperStyles = {
6
- float: imagePosition !== "center" ? imagePosition : undefined,
7
- marginLeft:
6
+ float: [
7
+ "none",
8
+ "none",
9
+ imagePosition !== "center" ? imagePosition : undefined,
10
+ ],
11
+ marginLeft: [
12
+ "auto",
13
+ "auto",
8
14
  imagePosition === "center"
9
15
  ? null
10
16
  : imagePosition === "left"
11
17
  ? "0"
12
18
  : "m",
13
- marginRight:
19
+ ],
20
+ marginRight: [
21
+ "auto",
22
+ "auto",
14
23
  imagePosition === "center"
15
24
  ? null
16
25
  : imagePosition === "left"
17
26
  ? "m"
18
27
  : "0",
28
+ ],
19
29
  width: imagePosition !== "center" ? "100%" : undefined,
20
30
  ...styles,
21
31
  };
@@ -34,15 +44,25 @@ const StructuredContent = {
34
44
  image: {
35
45
  // To handle the case when the image does not have a container,
36
46
  // e.g. when there is no image caption or credit.
37
- float: imagePosition !== "center" ? imagePosition : undefined,
38
- marginLeft:
47
+ float: [
48
+ "none",
49
+ "none",
50
+ imagePosition !== "center" ? imagePosition : undefined,
51
+ ],
52
+ marginLeft: [
53
+ "auto",
54
+ "auto",
39
55
  imagePosition === "right" && imageAspectRatio === "original"
40
56
  ? "m"
41
57
  : undefined,
42
- marginRight:
58
+ ],
59
+ marginRight: [
60
+ "auto",
61
+ "auto",
43
62
  imagePosition === "left" && imageAspectRatio === "original"
44
63
  ? "m"
45
64
  : undefined,
65
+ ],
46
66
  marginBottom:
47
67
  !hasFigureImage || imageAspectRatio === "original" ? "m" : null,
48
68
  ...styles,
@@ -5,6 +5,7 @@ const input = {
5
5
  border: "1px solid",
6
6
  borderColor: "ui.gray.medium",
7
7
  borderRadius: "sm",
8
+ fontSize: "text.caption",
8
9
  py: "xs",
9
10
  px: "s",
10
11
  _hover: {
@@ -15,8 +16,8 @@ const input = {
15
16
  color: "ui.gray.xdark",
16
17
  opacity: "1",
17
18
  },
18
- _active: activeFocus,
19
- _focus: activeFocus,
19
+ _active: activeFocus(),
20
+ _focus: activeFocus(),
20
21
  _placeholder: {
21
22
  color: "ui.gray.dark",
22
23
  fontStyle: "italic",
@@ -1,56 +1,60 @@
1
1
  import { helperTextMargin } from "./global";
2
2
 
3
3
  const baseStyle = {
4
- label: { display: "flex", alignItems: "center", width: "fit-content" },
4
+ label: { alignItems: "start", display: "flex", width: "fit-content" },
5
5
  helper: {
6
6
  ...helperTextMargin,
7
- marginLeft: "xs",
7
+ marginLeft: "xxs",
8
8
  },
9
9
  };
10
10
 
11
11
  const Switch = {
12
- baseStyle: {
13
- opacity: 0.4,
14
- track: {
15
- border: "1px solid",
16
- borderColor: "ui.gray.medium",
17
- p: "4px",
18
- _checked: {
19
- bg: "ui.link.primary",
20
- borderColor: "ui.link.primary",
21
- opacity: 1,
22
- },
23
- _invalid: {
24
- bg: "inherit",
25
- borderColor: "ui.error.primary",
26
- "> span": {
27
- bg: "ui.error.primary",
28
- },
29
- },
30
- _disabled: {
31
- bg: "ui.gray.medium",
12
+ baseStyle: ({ size }) => {
13
+ return {
14
+ alignItems: "start",
15
+ opacity: 0.4,
16
+ track: {
17
+ border: "1px solid",
32
18
  borderColor: "ui.gray.medium",
19
+ p: "4px",
33
20
  _checked: {
34
- opacity: 0.4,
21
+ bg: "ui.link.primary",
22
+ borderColor: "ui.link.primary",
23
+ opacity: 1,
24
+ },
25
+ _invalid: {
26
+ bg: "inherit",
27
+ borderColor: "ui.error.primary",
28
+ "> span": {
29
+ bg: "ui.error.primary",
30
+ },
31
+ },
32
+ _disabled: {
33
+ bg: "ui.gray.medium",
34
+ borderColor: "ui.gray.medium",
35
+ _checked: {
36
+ opacity: 0.4,
37
+ },
38
+ },
39
+ _focus: {
40
+ outline: "2px solid",
41
+ outlineColor: "ui.focus",
42
+ outlineOffset: "2px",
43
+ zIndex: "9999",
35
44
  },
36
45
  },
37
- _focus: {
38
- outline: "2px solid",
39
- outlineColor: "ui.focus",
40
- outlineOffset: "2px",
41
- zIndex: "9999",
46
+ label: {
47
+ fontSize: "label.default",
48
+ marginLeft: "xs",
49
+ marginTop: size === "lg" ? "6px" : null,
50
+ _disabled: { fontStyle: "italic" },
42
51
  },
43
- },
44
- label: {
45
- fontSize: "label.default",
46
- marginLeft: "xs",
47
- _disabled: { fontStyle: "italic" },
48
- },
49
- thumb: {
50
- _disabled: {
51
- bg: "ui.error.primary",
52
+ thumb: {
53
+ _disabled: {
54
+ bg: "ui.error.primary",
55
+ },
52
56
  },
53
- },
57
+ };
54
58
  },
55
59
  defaultProps: {
56
60
  colorScheme: "white",
@@ -82,30 +82,31 @@ const colors: Colors = {
82
82
 
83
83
  /** Brand fills for sections on NYPL pages. */
84
84
  section: {
85
- /** What's On is used for Exhibitions & Events. */
86
- "whats-on": {
87
- primary: "#242424",
88
- secondary: "#000000",
85
+ /** Blogs is used for the Blogs section. */
86
+ blogs: {
87
+ primary: grayLightCool,
88
+ secondary: grayMedium,
89
89
  },
90
90
 
91
91
  /** Books and More is used for the Catalog, Staff Picks, Recommendations,
92
92
  * New Arrivals, and E-Book Central. */
93
93
  "books-and-more": brandObj,
94
94
 
95
- /** Research is used for the Research Catalog and SCC. */
96
- research: {
97
- primary: "#00838a",
98
- secondary: "#006166",
95
+ /** Education is used for the Education section front and associated
96
+ * sub-sections. */
97
+ education: {
98
+ primary: "#1D62E6",
99
+ secondary: "#2540A4",
99
100
  },
100
101
 
101
102
  /** Locations is used for Location Finder and all branch pages with
102
103
  * the exceptions of some research libraries. */
103
104
  locations: brandObj,
104
105
 
105
- /** Blogs is used for the Blogs section. */
106
- blogs: {
107
- primary: grayLightCool,
108
- secondary: grayMedium,
106
+ /** Research is used for the Research Catalog and SCC. */
107
+ research: {
108
+ primary: "#00838a",
109
+ secondary: "#006166",
109
110
  },
110
111
 
111
112
  /** Research libraries with specific brand colors to adhere to. */
@@ -114,6 +115,12 @@ const colors: Colors = {
114
115
  schomburg: "#a03e31",
115
116
  schwartzman: brandSecondary,
116
117
  },
118
+
119
+ /** What's On is used for Exhibitions & Events. */
120
+ "whats-on": {
121
+ primary: "#242424",
122
+ secondary: "#000000",
123
+ },
117
124
  },
118
125
 
119
126
  /**
@@ -1,8 +1,9 @@
1
+ import { activeFocus } from "../components/global";
2
+ import { textMargin } from "../components/global";
3
+
1
4
  /**
2
5
  * These rules affect all the global elements on the `body` element of the
3
- * page when the `DSProvider` component is used. This means that even if the
4
- * `nypl-ds` CSS class name is not used in a consuming application, these
5
- * rules will still take effect.
6
+ * page when the `DSProvider` component is used.
6
7
  */
7
8
  const global = {
8
9
  // styles for the `body` element
@@ -23,8 +24,19 @@ const global = {
23
24
  svg: {
24
25
  display: "inline",
25
26
  },
26
- p: {
27
- margin: "0 0 var(--nypl-space-s",
27
+ "button, select, input, textarea": {
28
+ "&:not([disabled])": {
29
+ _focus: activeFocus(),
30
+ },
31
+ },
32
+ "iframe, [href], [tabindex], [contentEditable='true']": {
33
+ _focus: activeFocus(),
34
+ },
35
+ p: textMargin,
36
+ ul: textMargin,
37
+ ol: textMargin,
38
+ "*, *::before, &::after": {
39
+ boxSizing: "inherit",
28
40
  },
29
41
  };
30
42
 
@@ -28,7 +28,7 @@ const typography: Typography = {
28
28
  // Values from "src/styles/02-typography/_typeface.css"
29
29
  fonts: {
30
30
  body: "-apple-system, BlinkMacSystemFont, system-ui, sans-serif",
31
- heading: "-apple-system, BlinkMacSystemFont, system-ui, sans-seri",
31
+ heading: "-apple-system, BlinkMacSystemFont, system-ui, sans-serif",
32
32
  },
33
33
  // Values from "src/styles/02-typography/_type-scale.css"
34
34
  fontSizes: {
@@ -55,7 +55,7 @@ const typography: Typography = {
55
55
  callout: fontSizeValues["1"],
56
56
  },
57
57
  helper: {
58
- default: fontSizeValues["-1"],
58
+ default: fontSizeValues["-2"],
59
59
  },
60
60
  label: {
61
61
  default: fontSizeValues["-1"],
@@ -90,9 +90,10 @@ const categories = {
90
90
  components: ["Breadcrumbs", "Link", "Menu", "Pagination", "Subnavigation"],
91
91
  },
92
92
  chakra: {
93
- title: "Chakra/Layout",
93
+ title: "Chakra/Chakra COmponent/Layout",
94
94
  components: [
95
95
  "Box",
96
+ "Flex",
96
97
  "Grid",
97
98
  "Center, Circle, Square",
98
99
  "Stack, HStack, VStack",
@@ -44,3 +44,31 @@ export const getStorybookEnumValues = (enumObject, name) => {
44
44
  };
45
45
  return { options, getValue };
46
46
  };
47
+
48
+ /**
49
+ * Given a pagination's pageCount, this will return (1) a page number,
50
+ * derived from the current URL, and (2) a function that, when passed to
51
+ * Pagination component, makes the URL change and refreshes the page.
52
+ * @NOTE this is only used for Storybook documentation.
53
+ */
54
+ export const getStorybookHrefProps = (pageCount) => {
55
+ // This uses the `addon-queryparams` Storybook addon.
56
+ const urlParams = new URLSearchParams(document.location.search);
57
+ const pageParam = urlParams.get("page");
58
+
59
+ const getPageNumber = (page: number, pageCount: number) => {
60
+ return page > 0 && page <= pageCount ? page : 1;
61
+ };
62
+ const computedCurrentPage =
63
+ pageParam &&
64
+ Number(pageParam) &&
65
+ getPageNumber(Number(pageParam), pageCount);
66
+ const location = window.location;
67
+ // Passing this function into `Pagination` makes the URL to change
68
+ // and refreshes the page.
69
+ const getPageHref = (selectedPage) => {
70
+ return `${location.href}&page=${selectedPage}`;
71
+ };
72
+
73
+ return { computedCurrentPage, getPageHref };
74
+ };
@@ -1,13 +0,0 @@
1
- import { Story } from "@storybook/react/types-6-0";
2
- import { PaginationProps } from "./Pagination";
3
- /**
4
- * PaginationGetPageHref will refresh the browser as a new page is selected.
5
- * In this example, `getPageHref` creates the `href` attribute for each
6
- * page URL.
7
- */
8
- export declare const PaginationGetPageHref: Story<PaginationProps>;
9
- /**
10
- * PaginationOnPageChange will update the current page to the value that is
11
- * selected but will not change the URL or refresh the page.
12
- */
13
- export declare const PaginationOnPageChange: Story<PaginationProps>;
@@ -1,54 +0,0 @@
1
- import React from "react";
2
- import { Story } from "@storybook/react/types-6-0";
3
-
4
- import Pagination, { PaginationProps } from "./Pagination";
5
-
6
- /**
7
- * PaginationGetPageHref will refresh the browser as a new page is selected.
8
- * In this example, `getPageHref` creates the `href` attribute for each
9
- * page URL.
10
- */
11
- export const PaginationGetPageHref: Story<PaginationProps> = (args) => {
12
- // This uses the `addon-queryparams` Storybook addon.
13
- const urlParams = new URLSearchParams(document.location.search);
14
- const pageParam = urlParams.get("page");
15
- const getPageNumber = (page: number, pageCount: number) => {
16
- return page > 0 && page <= pageCount ? page : 1;
17
- };
18
- const computedCurrentPage =
19
- pageParam &&
20
- Number(pageParam) &&
21
- getPageNumber(Number(pageParam), args.pageCount);
22
- const location = window.location;
23
- // Passing this function into `Pagination` makes the URL to change
24
- // and refreshes the page.
25
- const getPageHref = (selectedPage) => {
26
- return `${location.href}&page=${selectedPage}`;
27
- };
28
-
29
- return (
30
- <Pagination
31
- pageCount={args.pageCount}
32
- initialPage={computedCurrentPage || args.initialPage}
33
- getPageHref={getPageHref}
34
- />
35
- );
36
- };
37
-
38
- /**
39
- * PaginationOnPageChange will update the current page to the value that is
40
- * selected but will not change the URL or refresh the page.
41
- */
42
- export const PaginationOnPageChange: Story<PaginationProps> = (args) => {
43
- const onPageChange = (currentPage: number) => {
44
- console.log(`Current page: ${currentPage}`);
45
- };
46
-
47
- return (
48
- <Pagination
49
- pageCount={args.pageCount}
50
- initialPage={args.initialPage}
51
- onPageChange={onPageChange}
52
- />
53
- );
54
- };
@@ -1,25 +0,0 @@
1
- // Kept for backwards compatibility.
2
- .nypl-ds {
3
- box-sizing: border-box;
4
- color: var(--nypl-colors-ui-black);
5
- font-family: var(--nypl-fonts-body);
6
-
7
- // Sets up the base font-size, 1rem, for the system
8
- font-size: var(--nypl-fontSizes-text-default);
9
- font-weight: 300;
10
- line-height: 1.5;
11
-
12
- // Users with non-overlay scrollbars have a small horizontal scrollbar from
13
- // our breakout mixin. Fix identified here: https://cloudfour.com/thinks/breaking-out-with-viewport-units-and-calc/#one-big-dumb-caveat
14
- overflow-x: hidden;
15
-
16
- p {
17
- margin: 0 0 var(--nypl-space-s);
18
- }
19
-
20
- *,
21
- *::after,
22
- *::before {
23
- box-sizing: inherit;
24
- }
25
- }