@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.
- package/CHANGELOG.md +96 -0
- package/README.md +4 -16
- package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +1 -0
- package/dist/components/DatePicker/DatePicker.d.ts +1 -1
- package/dist/components/Fieldset/Fieldset.d.ts +1 -3
- package/dist/components/Form/Form.d.ts +13 -12
- package/dist/components/Form/FormTypes.d.ts +2 -2
- package/dist/components/HorizontalRule/HorizontalRule.d.ts +1 -1
- package/dist/components/Icons/IconTypes.d.ts +9 -7
- package/dist/components/List/List.d.ts +1 -1
- package/dist/components/Logo/LogoSvgs.d.ts +23 -1
- package/dist/components/Logo/LogoTypes.d.ts +23 -1
- package/dist/components/Notification/Notification.d.ts +2 -0
- package/dist/components/Pagination/Pagination.d.ts +6 -2
- package/dist/components/RadioGroup/RadioGroup.d.ts +3 -3
- package/dist/components/SearchBar/SearchBar.d.ts +6 -6
- package/dist/components/Select/Select.d.ts +4 -0
- package/dist/components/Table/Table.d.ts +9 -3
- package/dist/components/Template/Template.d.ts +24 -5
- package/dist/design-system-react-components.cjs.development.js +2063 -548
- 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 +2056 -554
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/resources.scss +0 -2
- package/dist/styles.css +1 -1
- package/dist/theme/components/breadcrumb.d.ts +4 -1
- package/dist/theme/components/checkbox.d.ts +0 -2
- package/dist/theme/components/customTable.d.ts +12 -3
- package/dist/theme/components/fieldset.d.ts +2 -0
- package/dist/theme/components/global.d.ts +15 -14
- package/dist/theme/components/globalMixins.d.ts +8 -8
- package/dist/theme/components/list.d.ts +6 -0
- package/dist/theme/components/notification.d.ts +16 -4
- package/dist/theme/components/radio.d.ts +3 -2
- package/dist/theme/components/searchBar.d.ts +4 -0
- package/dist/theme/components/select.d.ts +2 -9
- package/dist/theme/components/slider.d.ts +8 -4
- package/dist/theme/components/structuredContent.d.ts +9 -9
- package/dist/theme/components/textInput.d.ts +10 -12
- package/dist/theme/components/toggle.d.ts +6 -2
- package/dist/theme/foundations/global.d.ts +31 -3
- package/dist/utils/utils.d.ts +10 -0
- package/package.json +40 -36
- package/src/components/Accordion/Accordion.stories.mdx +1 -1
- package/src/components/Accordion/Accordion.test.tsx +45 -1
- package/src/components/Accordion/Accordion.tsx +20 -8
- package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +243 -0
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +30 -2
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +25 -0
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +9 -3
- package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +1 -0
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +104 -5
- package/src/components/Card/Card.stories.mdx +1 -1
- package/src/components/Card/Card.tsx +4 -1
- package/src/components/Card/__snapshots__/Card.test.tsx.snap +1 -1
- package/src/components/Chakra/Flex.stories.mdx +113 -0
- package/src/components/Checkbox/Checkbox.stories.mdx +1 -1
- package/src/components/Checkbox/Checkbox.tsx +1 -0
- package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +6 -6
- package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +1 -1
- package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +18 -18
- package/src/components/DatePicker/DatePicker.stories.mdx +1 -1
- package/src/components/DatePicker/DatePicker.test.tsx +6 -6
- package/src/components/DatePicker/DatePicker.tsx +12 -10
- package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +28 -20
- package/src/components/Fieldset/Fieldset.stories.mdx +1 -1
- package/src/components/Fieldset/Fieldset.tsx +2 -4
- package/src/components/Form/Form.stories.mdx +34 -16
- package/src/components/Form/Form.test.tsx +92 -3
- package/src/components/Form/Form.tsx +25 -21
- package/src/components/Form/FormTypes.tsx +2 -2
- package/src/components/Form/__snapshots__/Form.test.tsx.snap +0 -1
- package/src/components/HelperErrorText/HelperErrorText.stories.mdx +1 -1
- package/src/components/Hero/Hero.stories.mdx +1 -1
- package/src/components/HorizontalRule/HorizontalRule.stories.mdx +3 -2
- package/src/components/HorizontalRule/HorizontalRule.tsx +2 -2
- package/src/components/HorizontalRule/__snapshots__/HorizontalRule.test.tsx.snap +4 -4
- package/src/components/Icons/Icon.stories.mdx +1 -1
- package/src/components/Icons/Icon.test.tsx +1 -1
- package/src/components/Icons/Icon.tsx +1 -1
- package/src/components/Icons/IconTypes.tsx +8 -6
- package/src/components/List/List.stories.mdx +24 -5
- package/src/components/List/List.test.tsx +1 -1
- package/src/components/List/List.tsx +2 -2
- package/src/components/List/__snapshots__/List.test.tsx.snap +3 -1
- package/src/components/Logo/Logo.stories.mdx +7 -5
- package/src/components/Logo/LogoSvgs.tsx +45 -1
- package/src/components/Logo/LogoTypes.tsx +22 -0
- package/src/components/Notification/Notification.stories.mdx +73 -1
- package/src/components/Notification/Notification.test.tsx +64 -5
- package/src/components/Notification/Notification.tsx +21 -11
- package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +103 -8
- package/src/components/Pagination/Pagination.stories.mdx +54 -12
- package/src/components/Pagination/Pagination.test.tsx +63 -5
- package/src/components/Pagination/Pagination.tsx +46 -24
- package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +3 -3
- package/src/components/Radio/Radio.stories.mdx +1 -1
- package/src/components/Radio/Radio.tsx +1 -0
- package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +5 -5
- package/src/components/RadioGroup/RadioGroup.stories.mdx +1 -1
- package/src/components/RadioGroup/RadioGroup.test.tsx +13 -11
- package/src/components/RadioGroup/RadioGroup.tsx +88 -89
- package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +18 -18
- package/src/components/SearchBar/SearchBar.Test.tsx +124 -28
- package/src/components/SearchBar/SearchBar.stories.mdx +9 -6
- package/src/components/SearchBar/SearchBar.tsx +24 -23
- package/src/components/Select/Select.stories.mdx +1 -1
- package/src/components/Select/Select.test.tsx +89 -0
- package/src/components/Select/Select.tsx +11 -2
- package/src/components/Select/__snapshots__/Select.test.tsx.snap +545 -0
- package/src/components/Slider/Slider.stories.mdx +1 -1
- package/src/components/Slider/Slider.tsx +4 -1
- package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +7 -0
- package/src/components/StructuredContent/StructuredContent.stories.mdx +1 -1
- package/src/components/StyleGuide/Bidirectionality.stories.mdx +4 -4
- package/src/components/StyleGuide/Colors.stories.mdx +33 -18
- package/src/components/Table/Table.stories.mdx +118 -19
- package/src/components/Table/Table.test.tsx +80 -3
- package/src/components/Table/Table.tsx +26 -16
- package/src/components/Table/__snapshots__/Table.test.tsx.snap +1179 -0
- package/src/components/Tabs/Tabs.stories.mdx +1 -1
- package/src/components/Tabs/Tabs.test.tsx +21 -5
- package/src/components/Tabs/Tabs.tsx +35 -20
- package/src/components/Tabs/__snapshots__/Tabs.test.tsx.snap +195 -0
- package/src/components/Template/Template.stories.mdx +79 -4
- package/src/components/Template/Template.test.tsx +65 -3
- package/src/components/Template/Template.tsx +60 -14
- package/src/components/Template/__snapshots__/Template.test.tsx.snap +94 -1
- package/src/components/TextInput/TextInput.stories.mdx +1 -1
- package/src/components/Toggle/Toggle.stories.mdx +1 -1
- package/src/components/Toggle/Toggle.tsx +2 -1
- package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +4 -4
- package/src/docs/Chakra.stories.mdx +1 -1
- package/src/index.ts +8 -2
- package/src/styles/base/_place-holder.scss +2 -0
- package/src/styles.scss +0 -2
- package/src/theme/components/breadcrumb.ts +5 -1
- package/src/theme/components/checkbox.ts +3 -7
- package/src/theme/components/customTable.ts +16 -3
- package/src/theme/components/fieldset.ts +2 -0
- package/src/theme/components/global.ts +19 -16
- package/src/theme/components/globalMixins.ts +8 -8
- package/src/theme/components/list.ts +6 -2
- package/src/theme/components/notification.ts +21 -8
- package/src/theme/components/radio.ts +3 -6
- package/src/theme/components/searchBar.ts +4 -0
- package/src/theme/components/select.ts +3 -3
- package/src/theme/components/slider.ts +12 -9
- package/src/theme/components/structuredContent.ts +26 -6
- package/src/theme/components/textInput.ts +3 -2
- package/src/theme/components/toggle.ts +42 -38
- package/src/theme/foundations/colors.ts +19 -12
- package/src/theme/foundations/global.ts +17 -5
- package/src/theme/foundations/typography.ts +2 -2
- package/src/utils/componentCategories.ts +2 -1
- package/src/utils/utils.ts +28 -0
- package/dist/components/Pagination/Pagination.stories.d.ts +0 -13
- package/src/components/Pagination/Pagination.stories.tsx +0 -54
- package/src/styles/base/_03-base.scss +0 -25
- package/src/styles/base/_04-focus.scss +0 -22
|
@@ -5,6 +5,7 @@ import renderer from "react-test-renderer";
|
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
Template,
|
|
8
|
+
TemplateAboveHeader,
|
|
8
9
|
TemplateHeader,
|
|
9
10
|
TemplateBreakout,
|
|
10
11
|
TemplateContent,
|
|
@@ -16,6 +17,7 @@ import {
|
|
|
16
17
|
} from "./Template";
|
|
17
18
|
import Placeholder from "../Placeholder/Placeholder";
|
|
18
19
|
|
|
20
|
+
const aboveHeader = <Placeholder variant="short">Above Header</Placeholder>;
|
|
19
21
|
const header = <Placeholder variant="short">NYPL Header</Placeholder>;
|
|
20
22
|
const breakout = (
|
|
21
23
|
<>
|
|
@@ -38,6 +40,7 @@ describe("TemplateAppContainer accessibility", () => {
|
|
|
38
40
|
it("passes axe accessibility test", async () => {
|
|
39
41
|
const { container } = render(
|
|
40
42
|
<TemplateAppContainer
|
|
43
|
+
aboveHeader={aboveHeader}
|
|
41
44
|
header={header}
|
|
42
45
|
breakout={breakout}
|
|
43
46
|
sidebar={sidebar}
|
|
@@ -55,6 +58,7 @@ describe("Template components accessibility", () => {
|
|
|
55
58
|
it("passes axe accessibility test", async () => {
|
|
56
59
|
const { container } = render(
|
|
57
60
|
<Template>
|
|
61
|
+
<TemplateAboveHeader>{aboveHeader}</TemplateAboveHeader>
|
|
58
62
|
<TemplateHeader>
|
|
59
63
|
{header}
|
|
60
64
|
<TemplateBreakout>{breakout}</TemplateBreakout>
|
|
@@ -75,6 +79,7 @@ describe("TemplateAppContainer component", () => {
|
|
|
75
79
|
it("renders each section", () => {
|
|
76
80
|
render(
|
|
77
81
|
<TemplateAppContainer
|
|
82
|
+
aboveHeader={aboveHeader}
|
|
78
83
|
header={header}
|
|
79
84
|
breakout={breakout}
|
|
80
85
|
sidebar={sidebar}
|
|
@@ -84,7 +89,7 @@ describe("TemplateAppContainer component", () => {
|
|
|
84
89
|
footer={footer}
|
|
85
90
|
/>
|
|
86
91
|
);
|
|
87
|
-
|
|
92
|
+
expect(screen.getByText("Above Header")).toBeInTheDocument();
|
|
88
93
|
expect(screen.getByText("NYPL Header")).toBeInTheDocument();
|
|
89
94
|
expect(screen.getByText("Breadcrumbs")).toBeInTheDocument();
|
|
90
95
|
expect(screen.getByText("Hero")).toBeInTheDocument();
|
|
@@ -95,6 +100,45 @@ describe("TemplateAppContainer component", () => {
|
|
|
95
100
|
expect(screen.getByText("Footer")).toBeInTheDocument();
|
|
96
101
|
});
|
|
97
102
|
|
|
103
|
+
it("renders only one header in a custom header component", () => {
|
|
104
|
+
const customHeader = <header>Custom header</header>;
|
|
105
|
+
render(
|
|
106
|
+
<TemplateAppContainer
|
|
107
|
+
header={customHeader}
|
|
108
|
+
renderHeaderElement={false}
|
|
109
|
+
breakout={breakout}
|
|
110
|
+
sidebar={sidebar}
|
|
111
|
+
contentTop={contentTop}
|
|
112
|
+
contentSidebar={contentSidebar}
|
|
113
|
+
contentPrimary={contentPrimary}
|
|
114
|
+
footer={footer}
|
|
115
|
+
/>
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
// The `<header>` HTML element has the same meaning as `role="banner"`.
|
|
119
|
+
expect(screen.getAllByRole("banner")).toHaveLength(1);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("consoles a warning when a header element was passed without setting `renderHeaderElement` to false", () => {
|
|
123
|
+
const warn = jest.spyOn(console, "warn");
|
|
124
|
+
const customHeader = <header>Custom header</header>;
|
|
125
|
+
render(
|
|
126
|
+
<TemplateAppContainer
|
|
127
|
+
header={customHeader}
|
|
128
|
+
breakout={breakout}
|
|
129
|
+
sidebar={sidebar}
|
|
130
|
+
contentTop={contentTop}
|
|
131
|
+
contentSidebar={contentSidebar}
|
|
132
|
+
contentPrimary={contentPrimary}
|
|
133
|
+
footer={footer}
|
|
134
|
+
/>
|
|
135
|
+
);
|
|
136
|
+
expect(warn).toHaveBeenCalledWith(
|
|
137
|
+
"`TemplateHeader`: An HTML `header` element was passed in. Set " +
|
|
138
|
+
"`renderHeaderElement` to `false` to avoid nested HTML `header` elements."
|
|
139
|
+
);
|
|
140
|
+
});
|
|
141
|
+
|
|
98
142
|
it("renders only one footer in a custom footer component", () => {
|
|
99
143
|
const customFooter = <footer>Custom Footer</footer>;
|
|
100
144
|
render(
|
|
@@ -138,6 +182,7 @@ describe("Template components", () => {
|
|
|
138
182
|
it("renders each section", () => {
|
|
139
183
|
render(
|
|
140
184
|
<Template>
|
|
185
|
+
<TemplateAboveHeader>{aboveHeader}</TemplateAboveHeader>
|
|
141
186
|
<TemplateHeader>
|
|
142
187
|
{header}
|
|
143
188
|
<TemplateBreakout>{breakout}</TemplateBreakout>
|
|
@@ -151,6 +196,7 @@ describe("Template components", () => {
|
|
|
151
196
|
</Template>
|
|
152
197
|
);
|
|
153
198
|
|
|
199
|
+
expect(screen.getByText("Above Header")).toBeInTheDocument();
|
|
154
200
|
expect(screen.getByText("NYPL Header")).toBeInTheDocument();
|
|
155
201
|
expect(screen.getByText("Breadcrumbs")).toBeInTheDocument();
|
|
156
202
|
expect(screen.getByText("Hero")).toBeInTheDocument();
|
|
@@ -162,9 +208,10 @@ describe("Template components", () => {
|
|
|
162
208
|
});
|
|
163
209
|
|
|
164
210
|
it("Renders the UI snapshot correctly", () => {
|
|
165
|
-
const
|
|
211
|
+
const templateComponents = renderer
|
|
166
212
|
.create(
|
|
167
213
|
<Template>
|
|
214
|
+
<TemplateAboveHeader>{aboveHeader}</TemplateAboveHeader>
|
|
168
215
|
<TemplateHeader>
|
|
169
216
|
{header}
|
|
170
217
|
<TemplateBreakout>{breakout}</TemplateBreakout>
|
|
@@ -178,7 +225,22 @@ describe("Template components", () => {
|
|
|
178
225
|
</Template>
|
|
179
226
|
)
|
|
180
227
|
.toJSON();
|
|
228
|
+
const singleComponent = renderer
|
|
229
|
+
.create(
|
|
230
|
+
<TemplateAppContainer
|
|
231
|
+
aboveHeader={aboveHeader}
|
|
232
|
+
header={header}
|
|
233
|
+
breakout={breakout}
|
|
234
|
+
sidebar={sidebar}
|
|
235
|
+
contentTop={contentTop}
|
|
236
|
+
contentSidebar={contentSidebar}
|
|
237
|
+
contentPrimary={contentPrimary}
|
|
238
|
+
footer={footer}
|
|
239
|
+
/>
|
|
240
|
+
)
|
|
241
|
+
.toJSON();
|
|
181
242
|
|
|
182
|
-
expect(
|
|
243
|
+
expect(templateComponents).toMatchSnapshot();
|
|
244
|
+
expect(singleComponent).toMatchSnapshot();
|
|
183
245
|
});
|
|
184
246
|
});
|
|
@@ -2,6 +2,10 @@ import * as React from "react";
|
|
|
2
2
|
import { Box, useStyleConfig } from "@chakra-ui/react";
|
|
3
3
|
|
|
4
4
|
export interface TemplateProps {}
|
|
5
|
+
export interface TemplateHeaderProps {
|
|
6
|
+
/** Flag to render an HTML header element. True by default. */
|
|
7
|
+
renderHeaderElement?: boolean;
|
|
8
|
+
}
|
|
5
9
|
export interface TemplateFooterProps {
|
|
6
10
|
/** Flag to render an HTML footer element. True by default. */
|
|
7
11
|
renderFooterElement?: boolean;
|
|
@@ -14,7 +18,11 @@ export interface TemplateSidebarProps {
|
|
|
14
18
|
export interface TemplateContentProps extends TemplateSidebarProps {}
|
|
15
19
|
export interface TemplateAppContainerProps
|
|
16
20
|
extends TemplateFooterProps,
|
|
21
|
+
TemplateHeaderProps,
|
|
17
22
|
TemplateSidebarProps {
|
|
23
|
+
/** DOM that will be rendered before the rest of the components in
|
|
24
|
+
* `TemplateAppContainer` and immediately before the `TemplateHeader` component. */
|
|
25
|
+
aboveHeader?: React.ReactElement;
|
|
18
26
|
/** DOM that will be rendered in the `TemplateBreakout` component section. */
|
|
19
27
|
breakout?: React.ReactElement;
|
|
20
28
|
/** DOM that will be rendered in the `TemplateContentPrimary` component section. */
|
|
@@ -31,28 +39,59 @@ export interface TemplateAppContainerProps
|
|
|
31
39
|
|
|
32
40
|
/**
|
|
33
41
|
* The main top-level parent component that wraps all template-related
|
|
34
|
-
* components.
|
|
42
|
+
* components.
|
|
35
43
|
*/
|
|
36
44
|
const Template = (props: React.PropsWithChildren<TemplateProps>) => {
|
|
37
45
|
const styles = useStyleConfig("Template", {});
|
|
38
|
-
return
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
return <Box __css={styles}>{props.children}</Box>;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* This optional component renders its children from edge-to-edge and should
|
|
51
|
+
* be used for alerts or notifications that are typically site-wide. This must
|
|
52
|
+
* be rendered immediately before the `TemplateHeader` component. This is meant
|
|
53
|
+
* for components that render an `aside` HTML element or HTML element with the
|
|
54
|
+
* `role="complementary"` attribute. These elements should *not* be rendered
|
|
55
|
+
* in the `header` HTML section since that's an accessibility violation.
|
|
56
|
+
*/
|
|
57
|
+
const TemplateAboveHeader = (props: React.PropsWithChildren<TemplateProps>) => {
|
|
58
|
+
const styles = useStyleConfig("TemplateBreakout", {});
|
|
59
|
+
return <Box __css={styles}>{props.children}</Box>;
|
|
43
60
|
};
|
|
44
61
|
|
|
45
62
|
/**
|
|
46
63
|
* This optional component should be the first child of the `Template`
|
|
47
|
-
* component. This is rendered as an HTML `<header>` element.
|
|
64
|
+
* component. This is rendered as an HTML `<header>` element. If an HTML
|
|
65
|
+
* `<header>` element is already passed in a custom component as the children,
|
|
66
|
+
* set `renderFooterElement` to `false`. Otherwise, the parent wrapper will
|
|
67
|
+
* render an HTML `<header>` element.
|
|
48
68
|
*/
|
|
49
|
-
const TemplateHeader = (
|
|
69
|
+
const TemplateHeader = ({
|
|
70
|
+
children,
|
|
71
|
+
renderHeaderElement = true,
|
|
72
|
+
}: React.PropsWithChildren<TemplateHeaderProps>) => {
|
|
50
73
|
const styles = useStyleConfig("TemplateHeader", {});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
74
|
+
let headerElement = <Box __css={styles}>{children}</Box>;
|
|
75
|
+
|
|
76
|
+
// The user wants to render the `header` HTML element.
|
|
77
|
+
if (renderHeaderElement) {
|
|
78
|
+
// But if they passed in a component that renders an HTML `<header>`,
|
|
79
|
+
// then log a warning.
|
|
80
|
+
React.Children.map(children, (child: React.ReactElement) => {
|
|
81
|
+
if (child?.type === "header" || child?.props?.mdxType === "header") {
|
|
82
|
+
console.warn(
|
|
83
|
+
"`TemplateHeader`: An HTML `header` element was passed in. Set " +
|
|
84
|
+
"`renderHeaderElement` to `false` to avoid nested HTML `header` elements."
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
headerElement = (
|
|
89
|
+
<Box as="header" __css={styles}>
|
|
90
|
+
{children}
|
|
91
|
+
</Box>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
return headerElement;
|
|
56
95
|
};
|
|
57
96
|
|
|
58
97
|
/**
|
|
@@ -194,6 +233,7 @@ const TemplateAppContainer = (
|
|
|
194
233
|
props: React.PropsWithChildren<TemplateAppContainerProps>
|
|
195
234
|
) => {
|
|
196
235
|
const {
|
|
236
|
+
aboveHeader,
|
|
197
237
|
breakout,
|
|
198
238
|
contentPrimary,
|
|
199
239
|
contentSidebar,
|
|
@@ -202,7 +242,11 @@ const TemplateAppContainer = (
|
|
|
202
242
|
header,
|
|
203
243
|
sidebar = "none",
|
|
204
244
|
renderFooterElement = true,
|
|
245
|
+
renderHeaderElement = true,
|
|
205
246
|
} = props;
|
|
247
|
+
const aboveHeaderElem = aboveHeader && (
|
|
248
|
+
<TemplateAboveHeader>{aboveHeader}</TemplateAboveHeader>
|
|
249
|
+
);
|
|
206
250
|
const breakoutElem = breakout && (
|
|
207
251
|
<TemplateBreakout>{breakout}</TemplateBreakout>
|
|
208
252
|
);
|
|
@@ -217,8 +261,9 @@ const TemplateAppContainer = (
|
|
|
217
261
|
);
|
|
218
262
|
return (
|
|
219
263
|
<Template>
|
|
264
|
+
{aboveHeaderElem}
|
|
220
265
|
{(header || breakoutElem) && (
|
|
221
|
-
<TemplateHeader>
|
|
266
|
+
<TemplateHeader renderHeaderElement={renderHeaderElement}>
|
|
222
267
|
{header}
|
|
223
268
|
{breakoutElem}
|
|
224
269
|
</TemplateHeader>
|
|
@@ -246,6 +291,7 @@ const TemplateAppContainer = (
|
|
|
246
291
|
export {
|
|
247
292
|
TemplateAppContainer,
|
|
248
293
|
Template,
|
|
294
|
+
TemplateAboveHeader,
|
|
249
295
|
TemplateHeader,
|
|
250
296
|
TemplateBreakout,
|
|
251
297
|
TemplateContent,
|
|
@@ -2,8 +2,101 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Template components Renders the UI snapshot correctly 1`] = `
|
|
4
4
|
<div
|
|
5
|
-
className="
|
|
5
|
+
className="css-0"
|
|
6
6
|
>
|
|
7
|
+
<div
|
|
8
|
+
className="css-0"
|
|
9
|
+
>
|
|
10
|
+
<div
|
|
11
|
+
className="placeholder placeholder-short"
|
|
12
|
+
>
|
|
13
|
+
Above Header
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
<header
|
|
17
|
+
className="css-0"
|
|
18
|
+
>
|
|
19
|
+
<div
|
|
20
|
+
className="placeholder placeholder-short"
|
|
21
|
+
>
|
|
22
|
+
NYPL Header
|
|
23
|
+
</div>
|
|
24
|
+
<div
|
|
25
|
+
className="css-0"
|
|
26
|
+
>
|
|
27
|
+
<div
|
|
28
|
+
className="placeholder placeholder-short"
|
|
29
|
+
>
|
|
30
|
+
Breadcrumbs
|
|
31
|
+
</div>
|
|
32
|
+
<div
|
|
33
|
+
className="placeholder placeholder-short"
|
|
34
|
+
>
|
|
35
|
+
Hero
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
</header>
|
|
39
|
+
<main
|
|
40
|
+
className="css-0"
|
|
41
|
+
>
|
|
42
|
+
<div
|
|
43
|
+
className="css-0"
|
|
44
|
+
>
|
|
45
|
+
<div
|
|
46
|
+
className="placeholder placeholder-undefined"
|
|
47
|
+
>
|
|
48
|
+
Content Top
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
<div
|
|
52
|
+
className="css-0"
|
|
53
|
+
>
|
|
54
|
+
<div
|
|
55
|
+
className="placeholder placeholder-undefined"
|
|
56
|
+
>
|
|
57
|
+
Left Sidebar
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
<div
|
|
61
|
+
className="css-0"
|
|
62
|
+
>
|
|
63
|
+
<div
|
|
64
|
+
className="placeholder placeholder-undefined"
|
|
65
|
+
>
|
|
66
|
+
Main Content
|
|
67
|
+
</div>
|
|
68
|
+
<div
|
|
69
|
+
className="placeholder placeholder-short"
|
|
70
|
+
>
|
|
71
|
+
More Content
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</main>
|
|
75
|
+
<footer
|
|
76
|
+
className="css-0"
|
|
77
|
+
>
|
|
78
|
+
<div
|
|
79
|
+
className="placeholder placeholder-short"
|
|
80
|
+
>
|
|
81
|
+
Footer
|
|
82
|
+
</div>
|
|
83
|
+
</footer>
|
|
84
|
+
</div>
|
|
85
|
+
`;
|
|
86
|
+
|
|
87
|
+
exports[`Template components Renders the UI snapshot correctly 2`] = `
|
|
88
|
+
<div
|
|
89
|
+
className="css-0"
|
|
90
|
+
>
|
|
91
|
+
<div
|
|
92
|
+
className="css-0"
|
|
93
|
+
>
|
|
94
|
+
<div
|
|
95
|
+
className="placeholder placeholder-short"
|
|
96
|
+
>
|
|
97
|
+
Above Header
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
7
100
|
<header
|
|
8
101
|
className="css-0"
|
|
9
102
|
>
|
|
@@ -77,7 +77,7 @@ const Toggle = React.forwardRef<HTMLInputElement, ToggleProps>(
|
|
|
77
77
|
const footnote: HelperErrorTextType = isInvalid ? invalidText : helperText;
|
|
78
78
|
const ariaAttributes = {};
|
|
79
79
|
const styles = useMultiStyleConfig("Toggle", {});
|
|
80
|
-
const switchStyles = useStyleConfig("Switch");
|
|
80
|
+
const switchStyles = useStyleConfig("Switch", { size });
|
|
81
81
|
ariaAttributes["aria-label"] =
|
|
82
82
|
labelText && footnote ? `${labelText} - ${footnote}` : labelText;
|
|
83
83
|
|
|
@@ -92,6 +92,7 @@ const Toggle = React.forwardRef<HTMLInputElement, ToggleProps>(
|
|
|
92
92
|
isRequired={isRequired}
|
|
93
93
|
ref={ref}
|
|
94
94
|
size={size === ToggleSizes.Large ? "lg" : "sm"}
|
|
95
|
+
lineHeight="1.5"
|
|
95
96
|
{...(isChecked !== undefined
|
|
96
97
|
? {
|
|
97
98
|
isChecked,
|
|
@@ -5,7 +5,7 @@ exports[`Toggle Renders the UI snapshot correctly 1`] = `
|
|
|
5
5
|
className="css-0"
|
|
6
6
|
>
|
|
7
7
|
<label
|
|
8
|
-
className="chakra-switch css-
|
|
8
|
+
className="chakra-switch css-18x0has"
|
|
9
9
|
onClick={[Function]}
|
|
10
10
|
>
|
|
11
11
|
<input
|
|
@@ -66,7 +66,7 @@ exports[`Toggle Renders the UI snapshot correctly 2`] = `
|
|
|
66
66
|
className="css-0"
|
|
67
67
|
>
|
|
68
68
|
<label
|
|
69
|
-
className="chakra-switch css-
|
|
69
|
+
className="chakra-switch css-18x0has"
|
|
70
70
|
data-checked=""
|
|
71
71
|
onClick={[Function]}
|
|
72
72
|
>
|
|
@@ -131,7 +131,7 @@ exports[`Toggle Renders the UI snapshot correctly 3`] = `
|
|
|
131
131
|
className="css-0"
|
|
132
132
|
>
|
|
133
133
|
<label
|
|
134
|
-
className="chakra-switch css-
|
|
134
|
+
className="chakra-switch css-18x0has"
|
|
135
135
|
data-invalid=""
|
|
136
136
|
onClick={[Function]}
|
|
137
137
|
>
|
|
@@ -195,7 +195,7 @@ exports[`Toggle Renders the UI snapshot correctly 4`] = `
|
|
|
195
195
|
className="css-0"
|
|
196
196
|
>
|
|
197
197
|
<label
|
|
198
|
-
className="chakra-switch css-
|
|
198
|
+
className="chakra-switch css-18x0has"
|
|
199
199
|
data-disabled=""
|
|
200
200
|
onClick={[Function]}
|
|
201
201
|
>
|
package/src/index.ts
CHANGED
|
@@ -7,9 +7,11 @@ export {
|
|
|
7
7
|
ButtonGroup,
|
|
8
8
|
Center,
|
|
9
9
|
Circle,
|
|
10
|
+
Flex,
|
|
10
11
|
Grid,
|
|
11
12
|
GridItem,
|
|
12
13
|
HStack,
|
|
14
|
+
Spacer,
|
|
13
15
|
Square,
|
|
14
16
|
Stack,
|
|
15
17
|
VStack,
|
|
@@ -29,12 +31,15 @@ export { CardLayouts } from "./components/Card/CardTypes";
|
|
|
29
31
|
export { default as Checkbox } from "./components/Checkbox/Checkbox";
|
|
30
32
|
export { default as CheckboxGroup } from "./components/CheckboxGroup/CheckboxGroup";
|
|
31
33
|
export { CheckboxGroupLayoutTypes } from "./components/CheckboxGroup/CheckboxGroupLayoutTypes";
|
|
32
|
-
export {
|
|
34
|
+
export {
|
|
35
|
+
default as DatePicker,
|
|
36
|
+
FullDateType,
|
|
37
|
+
} from "./components/DatePicker/DatePicker";
|
|
33
38
|
export { DatePickerTypes } from "./components/DatePicker/DatePickerTypes";
|
|
34
39
|
export { default as DSProvider } from "./theme/provider";
|
|
35
40
|
export { default as Fieldset } from "./components/Fieldset/Fieldset";
|
|
36
41
|
export { default as Form, FormField, FormRow } from "./components/Form/Form";
|
|
37
|
-
export {
|
|
42
|
+
export { FormGaps } from "./components/Form/FormTypes";
|
|
38
43
|
export { GridGaps } from "./components/Grid/GridTypes";
|
|
39
44
|
export { default as Heading } from "./components/Heading/Heading";
|
|
40
45
|
export {
|
|
@@ -102,6 +107,7 @@ export {
|
|
|
102
107
|
export {
|
|
103
108
|
TemplateAppContainer,
|
|
104
109
|
Template,
|
|
110
|
+
TemplateAboveHeader,
|
|
105
111
|
TemplateHeader,
|
|
106
112
|
TemplateBreakout,
|
|
107
113
|
TemplateContent,
|
package/src/styles.scss
CHANGED
|
@@ -13,8 +13,6 @@
|
|
|
13
13
|
// Order important
|
|
14
14
|
@import "./styles/base/_01-breakpoints";
|
|
15
15
|
@import "./styles/base/_02-mixins";
|
|
16
|
-
@import "./styles/base/_03-base";
|
|
17
|
-
@import "./styles/base/_04-focus";
|
|
18
16
|
@import "./styles/base/_place-holder";
|
|
19
17
|
@import "./styles/space/_space-inline";
|
|
20
18
|
@import "./styles/space/_space-inset";
|
|
@@ -11,6 +11,9 @@ const blogs = {
|
|
|
11
11
|
const booksAndMore = {
|
|
12
12
|
bg: "section.books-and-more.secondary",
|
|
13
13
|
};
|
|
14
|
+
const education = {
|
|
15
|
+
bg: "section.education.secondary",
|
|
16
|
+
};
|
|
14
17
|
const locations = {
|
|
15
18
|
bg: "section.locations.primary",
|
|
16
19
|
};
|
|
@@ -67,7 +70,7 @@ const Breadcrumb = {
|
|
|
67
70
|
marginInlineStart: "xxs",
|
|
68
71
|
},
|
|
69
72
|
},
|
|
70
|
-
"li:nth-last-
|
|
73
|
+
"li:nth-last-of-type(2)": {
|
|
71
74
|
display: "inline-block",
|
|
72
75
|
span: {
|
|
73
76
|
display: { base: "none", md: "inline" },
|
|
@@ -78,6 +81,7 @@ const Breadcrumb = {
|
|
|
78
81
|
variants: {
|
|
79
82
|
blogs,
|
|
80
83
|
booksAndMore,
|
|
84
|
+
education,
|
|
81
85
|
locations,
|
|
82
86
|
research,
|
|
83
87
|
whatsOn,
|
|
@@ -69,14 +69,10 @@ const baseStyleControl = {
|
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
// Style object for the Checkbox's label
|
|
72
|
-
const baseStyleLabel =
|
|
73
|
-
...checkboxRadioLabelStyles,
|
|
74
|
-
};
|
|
72
|
+
const baseStyleLabel = checkboxRadioLabelStyles;
|
|
75
73
|
|
|
76
74
|
// Style object for the Checkbox's helper text
|
|
77
|
-
const baseStyleHelper =
|
|
78
|
-
...checkboxRadioHelperStyle,
|
|
79
|
-
};
|
|
75
|
+
const baseStyleHelper = checkboxRadioHelperStyle;
|
|
80
76
|
|
|
81
77
|
const baseStyle = {
|
|
82
78
|
icon: baseStyleIcon,
|
|
@@ -94,7 +90,7 @@ const sizes = {
|
|
|
94
90
|
borderRadius: "sm",
|
|
95
91
|
},
|
|
96
92
|
// Controls the font-size of the label only.
|
|
97
|
-
label: { fontSize: "
|
|
93
|
+
label: { fontSize: "label.default" },
|
|
98
94
|
},
|
|
99
95
|
};
|
|
100
96
|
|
|
@@ -3,6 +3,15 @@ const baseStyle = ({
|
|
|
3
3
|
showRowDividers,
|
|
4
4
|
useRowHeaders,
|
|
5
5
|
}) => ({
|
|
6
|
+
// Headers `th` can be rendered as the first cell in every row through the
|
|
7
|
+
// `useRowHeaders`. Whereas the header `th` in the `thead` can be rendered
|
|
8
|
+
// with a custom color, the row header `th` in the `tbody` should always
|
|
9
|
+
// have text color black.
|
|
10
|
+
tbody: {
|
|
11
|
+
th: {
|
|
12
|
+
color: "var(--nypl-colors-ui-black)",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
6
15
|
th: {
|
|
7
16
|
border: showRowDividers ? undefined : "none",
|
|
8
17
|
borderBottom: showRowDividers ? undefined : "0px",
|
|
@@ -35,11 +44,15 @@ const baseStyle = ({
|
|
|
35
44
|
},
|
|
36
45
|
caption: {
|
|
37
46
|
captionSide: "top",
|
|
38
|
-
textAlign: "left",
|
|
39
|
-
fontSize: "heading.secondary",
|
|
40
47
|
color: "ui.black",
|
|
41
|
-
|
|
48
|
+
fontSize: "heading.secondary",
|
|
42
49
|
fontWeight: "heading.secondary",
|
|
50
|
+
marginBottom: "s",
|
|
51
|
+
marginLeft: "0",
|
|
52
|
+
marginRight: "0",
|
|
53
|
+
marginTop: "0",
|
|
54
|
+
padding: "0",
|
|
55
|
+
textAlign: "left",
|
|
43
56
|
},
|
|
44
57
|
});
|
|
45
58
|
|
|
@@ -4,26 +4,23 @@ export { wrapperStyles } from "./globalMixins";
|
|
|
4
4
|
/** Reusable component styles. */
|
|
5
5
|
|
|
6
6
|
// Used in `Select` and `TextInput`.
|
|
7
|
-
const activeFocus = {
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const activeFocus = (darkMode = false) => ({
|
|
8
|
+
outline: "2px solid",
|
|
9
|
+
outlineOffset: "2px",
|
|
10
|
+
outlineColor: darkMode ? "ui.white" : "ui.focus",
|
|
10
11
|
zIndex: "9999",
|
|
11
|
-
|
|
12
|
-
outlineColor: "ui.focus",
|
|
13
|
-
};
|
|
12
|
+
});
|
|
14
13
|
// Used in `Select` and `TextInput`.
|
|
15
14
|
const helperTextMargin = {
|
|
16
|
-
marginTop: "
|
|
15
|
+
marginTop: "xxs",
|
|
17
16
|
marginBottom: "0",
|
|
18
17
|
};
|
|
19
18
|
// Used in `Checkbox` and `Radio`.
|
|
20
19
|
const checkboxRadioLabelStyles = {
|
|
21
20
|
userSelect: "none",
|
|
22
|
-
fontSize: "text.default",
|
|
23
21
|
fontWeight: "text.default",
|
|
24
22
|
marginBottom: "0",
|
|
25
23
|
marginLeft: "xs",
|
|
26
|
-
verticalAlign: "middle",
|
|
27
24
|
_disabled: {
|
|
28
25
|
color: "ui.gray.dark",
|
|
29
26
|
opacity: 1,
|
|
@@ -47,6 +44,14 @@ const checkboxRadioHelperStyle = {
|
|
|
47
44
|
fontStyle: "italic",
|
|
48
45
|
},
|
|
49
46
|
};
|
|
47
|
+
const checkboxRadioGroupStyles = {
|
|
48
|
+
helper: {
|
|
49
|
+
marginTop: "s",
|
|
50
|
+
},
|
|
51
|
+
stack: {
|
|
52
|
+
width: "fit-content",
|
|
53
|
+
},
|
|
54
|
+
};
|
|
50
55
|
// Used in `Label` and `Fieldset`.
|
|
51
56
|
const labelLegendText = {
|
|
52
57
|
alignItems: "baseline",
|
|
@@ -62,13 +67,10 @@ const labelLegendText = {
|
|
|
62
67
|
fontWeight: "helper.default",
|
|
63
68
|
},
|
|
64
69
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
stack: {
|
|
70
|
-
width: "fit-content",
|
|
71
|
-
},
|
|
70
|
+
// Used for p, ul, and ol
|
|
71
|
+
const textMargin = {
|
|
72
|
+
margin: "0",
|
|
73
|
+
marginBottom: "s",
|
|
72
74
|
};
|
|
73
75
|
|
|
74
76
|
export {
|
|
@@ -79,4 +81,5 @@ export {
|
|
|
79
81
|
checkboxRadioLabelStyles,
|
|
80
82
|
helperTextMargin,
|
|
81
83
|
labelLegendText,
|
|
84
|
+
textMargin,
|
|
82
85
|
};
|