@nypl/design-system-react-components 0.25.9 → 0.25.10
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 +45 -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/RadioGroup/RadioGroup.d.ts +3 -3
- package/dist/components/SearchBar/SearchBar.d.ts +5 -5
- package/dist/components/Table/Table.d.ts +9 -3
- package/dist/components/Template/Template.d.ts +23 -4
- package/dist/design-system-react-components.cjs.development.js +197 -89
- 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 +186 -91
- 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/theme/components/breadcrumb.d.ts +1 -1
- package/dist/theme/components/customTable.d.ts +12 -3
- 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 +13 -2
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +15 -0
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +9 -3
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +5 -5
- package/src/components/Card/Card.stories.mdx +1 -1
- package/src/components/Card/Card.tsx +4 -1
- package/src/components/Chakra/Flex.stories.mdx +113 -0
- package/src/components/DatePicker/DatePicker.stories.mdx +1 -1
- package/src/components/DatePicker/DatePicker.test.tsx +6 -6
- package/src/components/DatePicker/DatePicker.tsx +3 -4
- 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/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/List/List.stories.mdx +1 -1
- package/src/components/List/List.tsx +1 -1
- package/src/components/Pagination/Pagination.stories.mdx +1 -1
- package/src/components/Pagination/Pagination.tsx +2 -2
- 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 +106 -28
- package/src/components/SearchBar/SearchBar.stories.mdx +7 -4
- package/src/components/SearchBar/SearchBar.tsx +19 -20
- package/src/components/Select/Select.test.tsx +89 -0
- package/src/components/Select/Select.tsx +7 -1
- package/src/components/Select/__snapshots__/Select.test.tsx.snap +545 -0
- package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +7 -0
- 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 +33 -18
- 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 +58 -8
- package/src/components/Template/__snapshots__/Template.test.tsx.snap +93 -0
- package/src/index.ts +8 -2
- package/src/theme/components/breadcrumb.ts +1 -1
- package/src/theme/components/customTable.ts +16 -3
- package/src/utils/componentCategories.ts +1 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { render, screen } from "@testing-library/react";
|
|
3
|
-
import { axe } from "jest-axe";
|
|
4
3
|
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import { axe } from "jest-axe";
|
|
5
|
+
import renderer from "react-test-renderer";
|
|
5
6
|
|
|
6
7
|
import { Tabs, TabList, Tab, TabPanels, TabPanel } from "./Tabs";
|
|
7
8
|
|
|
@@ -208,7 +209,15 @@ describe("Tabs", () => {
|
|
|
208
209
|
expect(selectedIndex).toEqual(1);
|
|
209
210
|
});
|
|
210
211
|
|
|
211
|
-
it("should throw warning when
|
|
212
|
+
it("should throw a warning when no data is passed", () => {
|
|
213
|
+
const warn = jest.spyOn(console, "warn");
|
|
214
|
+
render(<Tabs />);
|
|
215
|
+
expect(warn).toHaveBeenCalledWith(
|
|
216
|
+
"Tabs: Pass data in the `data` props or as children."
|
|
217
|
+
);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it("should throw a warning when both the 'data' prop and children are passed", () => {
|
|
212
221
|
const warn = jest.spyOn(console, "warn");
|
|
213
222
|
render(
|
|
214
223
|
<Tabs contentData={animalCrossing}>
|
|
@@ -238,11 +247,11 @@ describe("Tabs", () => {
|
|
|
238
247
|
</Tabs>
|
|
239
248
|
);
|
|
240
249
|
expect(warn).toHaveBeenCalledWith(
|
|
241
|
-
"Only pass children or data in the `data` props but not both."
|
|
250
|
+
"Tabs: Only pass children or data in the `data` props but not both."
|
|
242
251
|
);
|
|
243
252
|
});
|
|
244
253
|
|
|
245
|
-
it("should throw warning when more than six object tabs are passed", () => {
|
|
254
|
+
it("should throw a warning when more than six object tabs are passed", () => {
|
|
246
255
|
const warn = jest.spyOn(console, "warn");
|
|
247
256
|
render(
|
|
248
257
|
<Tabs
|
|
@@ -258,7 +267,14 @@ describe("Tabs", () => {
|
|
|
258
267
|
/>
|
|
259
268
|
);
|
|
260
269
|
expect(warn).toHaveBeenCalledWith(
|
|
261
|
-
"We recommend to use no more than six tabs. If more than six tabs are needed, consider other navigational patterns."
|
|
270
|
+
"Tabs: We recommend to use no more than six tabs. If more than six tabs are needed, consider other navigational patterns."
|
|
262
271
|
);
|
|
263
272
|
});
|
|
273
|
+
|
|
274
|
+
it("renders the UI snapshot correctly", () => {
|
|
275
|
+
const basic = renderer
|
|
276
|
+
.create(<Tabs contentData={animalCrossing} id="basic" />)
|
|
277
|
+
.toJSON();
|
|
278
|
+
expect(basic).toMatchSnapshot();
|
|
279
|
+
});
|
|
264
280
|
});
|
|
@@ -17,6 +17,12 @@ import Button from "../Button/Button";
|
|
|
17
17
|
import useCarouselStyles from "../../hooks/useCarouselStyles";
|
|
18
18
|
import useWindowSize from "../../hooks/useWindowSize";
|
|
19
19
|
|
|
20
|
+
// Internal interface used for rendering `Tabs` tab and panel
|
|
21
|
+
// elements, either from data or from children.
|
|
22
|
+
interface TabPanelProps {
|
|
23
|
+
tabs: React.ReactNode[] | React.ReactNode;
|
|
24
|
+
panels: React.ReactNode[] | React.ReactNode;
|
|
25
|
+
}
|
|
20
26
|
// The general shape of the data object for each Tab.
|
|
21
27
|
export interface TabsContentDataProps {
|
|
22
28
|
label: string;
|
|
@@ -49,18 +55,18 @@ const onClickHash = (tabHash) => {
|
|
|
49
55
|
* This returns an object with `Tab` and `TabPanel` components to rendered in
|
|
50
56
|
* `TabList` and `TabPanels` components respectively.
|
|
51
57
|
*/
|
|
52
|
-
const getElementsFromContentData = (data, useHash) => {
|
|
58
|
+
const getElementsFromContentData = (data, useHash): TabPanelProps => {
|
|
53
59
|
const tabs = [];
|
|
54
60
|
const panels = [];
|
|
55
61
|
|
|
56
62
|
if (!data?.length) {
|
|
57
|
-
return {};
|
|
63
|
+
return { tabs: [], panels: [] };
|
|
58
64
|
}
|
|
59
65
|
|
|
60
66
|
if (data?.length > 6) {
|
|
61
67
|
console.warn(
|
|
62
|
-
"We recommend to use no more than six tabs. If more than six tabs
|
|
63
|
-
"needed, consider other navigational patterns."
|
|
68
|
+
"Tabs: We recommend to use no more than six tabs. If more than six tabs " +
|
|
69
|
+
"are needed, consider other navigational patterns."
|
|
64
70
|
);
|
|
65
71
|
}
|
|
66
72
|
data.forEach((tab, index) => {
|
|
@@ -78,8 +84,8 @@ const getElementsFromContentData = (data, useHash) => {
|
|
|
78
84
|
if (typeof tab.content === "string") {
|
|
79
85
|
tempPanel = (
|
|
80
86
|
<TabPanel
|
|
81
|
-
key={index}
|
|
82
87
|
dangerouslySetInnerHTML={{ __html: tab.content }}
|
|
88
|
+
key={index}
|
|
83
89
|
/>
|
|
84
90
|
);
|
|
85
91
|
} else {
|
|
@@ -100,12 +106,12 @@ const getElementsFromContentData = (data, useHash) => {
|
|
|
100
106
|
* This returns an object with `TabList` and `TabPanels` components to help format
|
|
101
107
|
* the DOM when building up the `Tabs` component using child component.
|
|
102
108
|
*/
|
|
103
|
-
const getElementsFromChildren = (children) => {
|
|
109
|
+
const getElementsFromChildren = (children): TabPanelProps => {
|
|
104
110
|
const tabs = [];
|
|
105
111
|
const panels = [];
|
|
106
112
|
|
|
107
113
|
if (!children?.length) {
|
|
108
|
-
return {};
|
|
114
|
+
return { tabs: [], panels: [] };
|
|
109
115
|
}
|
|
110
116
|
|
|
111
117
|
children.forEach((child) => {
|
|
@@ -115,8 +121,8 @@ const getElementsFromChildren = (children) => {
|
|
|
115
121
|
const childTabs = React.Children.count(child.props.children);
|
|
116
122
|
if (childTabs > 6) {
|
|
117
123
|
console.warn(
|
|
118
|
-
"We recommend to use no more than six tabs. If more than six
|
|
119
|
-
"needed, consider other navigational patterns."
|
|
124
|
+
"Tabs: We recommend to use no more than six tabs. If more than six " +
|
|
125
|
+
"tabs are needed, consider other navigational patterns."
|
|
120
126
|
);
|
|
121
127
|
}
|
|
122
128
|
}
|
|
@@ -149,9 +155,14 @@ function Tabs(props: React.PropsWithChildren<TabsProps>) {
|
|
|
149
155
|
const mediumTabWidth = 40;
|
|
150
156
|
const [tabWidth, setTabWidth] = React.useState(initTabWidth);
|
|
151
157
|
const windowDimensions = useWindowSize();
|
|
152
|
-
const { tabs, panels } = contentData
|
|
158
|
+
const { tabs, panels }: any = contentData
|
|
153
159
|
? getElementsFromContentData(contentData, useHash)
|
|
154
160
|
: getElementsFromChildren(children);
|
|
161
|
+
|
|
162
|
+
if (!tabs.length || !panels.length) {
|
|
163
|
+
console.warn("Tabs: Pass data in the `data` props or as children.");
|
|
164
|
+
}
|
|
165
|
+
|
|
155
166
|
// `tabs` is an array for the children component approach but an object for
|
|
156
167
|
// the `contentData` prop approach. We need to get the right props key value
|
|
157
168
|
// to set the carousel's length.
|
|
@@ -173,34 +184,38 @@ function Tabs(props: React.PropsWithChildren<TabsProps>) {
|
|
|
173
184
|
}, [goToStart, windowDimensions.width]);
|
|
174
185
|
const previousButton = (
|
|
175
186
|
<Button
|
|
176
|
-
buttonType={ButtonTypes.Primary}
|
|
177
187
|
attributes={{
|
|
178
188
|
"aria-label": "Previous",
|
|
179
189
|
...styles.buttonArrows,
|
|
180
190
|
left: "0",
|
|
181
191
|
}}
|
|
192
|
+
buttonType={ButtonTypes.Primary}
|
|
193
|
+
id={`tabs-previous-${id}`}
|
|
182
194
|
onClick={prevSlide}
|
|
183
195
|
>
|
|
184
196
|
<Icon
|
|
185
|
-
name={IconNames.Arrow}
|
|
186
197
|
iconRotation={IconRotationTypes.Rotate90}
|
|
198
|
+
id={`tabs-previous-icon-${id}`}
|
|
199
|
+
name={IconNames.Arrow}
|
|
187
200
|
size={IconSizes.Small}
|
|
188
201
|
/>
|
|
189
202
|
</Button>
|
|
190
203
|
);
|
|
191
204
|
const nextButton = (
|
|
192
205
|
<Button
|
|
193
|
-
buttonType={ButtonTypes.Primary}
|
|
194
206
|
attributes={{
|
|
195
207
|
"aria-label": "Next",
|
|
196
208
|
...styles.buttonArrows,
|
|
197
209
|
right: "0",
|
|
198
210
|
}}
|
|
211
|
+
buttonType={ButtonTypes.Primary}
|
|
212
|
+
id={`tabs-next-${id}`}
|
|
199
213
|
onClick={nextSlide}
|
|
200
214
|
>
|
|
201
215
|
<Icon
|
|
202
|
-
name={IconNames.Arrow}
|
|
203
216
|
iconRotation={IconRotationTypes.Rotate270}
|
|
217
|
+
id={`tabs-next-icon-${id}`}
|
|
218
|
+
name={IconNames.Arrow}
|
|
204
219
|
size={IconSizes.Small}
|
|
205
220
|
/>
|
|
206
221
|
</Button>
|
|
@@ -208,18 +223,18 @@ function Tabs(props: React.PropsWithChildren<TabsProps>) {
|
|
|
208
223
|
|
|
209
224
|
if (children && contentData?.length) {
|
|
210
225
|
console.warn(
|
|
211
|
-
"Only pass children or data in the `data` props but not both."
|
|
226
|
+
"Tabs: Only pass children or data in the `data` props but not both."
|
|
212
227
|
);
|
|
213
228
|
}
|
|
214
229
|
|
|
215
230
|
return (
|
|
216
231
|
<ChakraTabs
|
|
217
|
-
id={id}
|
|
218
|
-
onChange={onChange}
|
|
219
232
|
defaultIndex={defaultIndex}
|
|
220
|
-
|
|
233
|
+
id={id}
|
|
221
234
|
// The following lazy loads each panel whenever it is needed.
|
|
222
235
|
isLazy
|
|
236
|
+
onChange={onChange}
|
|
237
|
+
variant="enclosed"
|
|
223
238
|
>
|
|
224
239
|
<Box
|
|
225
240
|
__css={styles.tablistWrapper}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Tabs renders the UI snapshot correctly 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
className="chakra-tabs css-0"
|
|
6
|
+
id="basic"
|
|
7
|
+
>
|
|
8
|
+
<div
|
|
9
|
+
className="css-l3f8vc"
|
|
10
|
+
>
|
|
11
|
+
<button
|
|
12
|
+
aria-label="Previous"
|
|
13
|
+
className="chakra-button css-fg6w03"
|
|
14
|
+
data-testid="button"
|
|
15
|
+
id="tabs-previous-basic"
|
|
16
|
+
onClick={[Function]}
|
|
17
|
+
type="button"
|
|
18
|
+
>
|
|
19
|
+
<svg
|
|
20
|
+
aria-hidden={true}
|
|
21
|
+
className="chakra-icon css-onkibi"
|
|
22
|
+
focusable={false}
|
|
23
|
+
id="tabs-previous-icon-basic"
|
|
24
|
+
role="img"
|
|
25
|
+
title="arrow icon"
|
|
26
|
+
viewBox="0 0 24 24"
|
|
27
|
+
>
|
|
28
|
+
<g
|
|
29
|
+
stroke="currentColor"
|
|
30
|
+
strokeWidth="1.5"
|
|
31
|
+
>
|
|
32
|
+
<path
|
|
33
|
+
d="M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"
|
|
34
|
+
fill="none"
|
|
35
|
+
strokeLinecap="round"
|
|
36
|
+
/>
|
|
37
|
+
<path
|
|
38
|
+
d="M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"
|
|
39
|
+
fill="currentColor"
|
|
40
|
+
strokeLinecap="round"
|
|
41
|
+
/>
|
|
42
|
+
<circle
|
|
43
|
+
cx="12"
|
|
44
|
+
cy="12"
|
|
45
|
+
fill="none"
|
|
46
|
+
r="11.25"
|
|
47
|
+
strokeMiterlimit="10"
|
|
48
|
+
/>
|
|
49
|
+
</g>
|
|
50
|
+
</svg>
|
|
51
|
+
</button>
|
|
52
|
+
<div
|
|
53
|
+
className="css-0"
|
|
54
|
+
>
|
|
55
|
+
<div
|
|
56
|
+
className="css-16fuzwj"
|
|
57
|
+
>
|
|
58
|
+
<div
|
|
59
|
+
aria-orientation="horizontal"
|
|
60
|
+
className="chakra-tabs__tablist css-k008qs"
|
|
61
|
+
onKeyDown={[Function]}
|
|
62
|
+
role="tablist"
|
|
63
|
+
>
|
|
64
|
+
<button
|
|
65
|
+
aria-controls="basic--tabpanel--1"
|
|
66
|
+
aria-selected={false}
|
|
67
|
+
className="chakra-tabs__tab css-abpfcx"
|
|
68
|
+
id="basic--tab--1"
|
|
69
|
+
onClick={[Function]}
|
|
70
|
+
onFocus={[Function]}
|
|
71
|
+
role="tab"
|
|
72
|
+
tabIndex={-1}
|
|
73
|
+
type="button"
|
|
74
|
+
>
|
|
75
|
+
Tom Nook
|
|
76
|
+
</button>
|
|
77
|
+
<button
|
|
78
|
+
aria-controls="basic--tabpanel--1"
|
|
79
|
+
aria-selected={false}
|
|
80
|
+
className="chakra-tabs__tab css-abpfcx"
|
|
81
|
+
id="basic--tab--1"
|
|
82
|
+
onClick={[Function]}
|
|
83
|
+
onFocus={[Function]}
|
|
84
|
+
role="tab"
|
|
85
|
+
tabIndex={-1}
|
|
86
|
+
type="button"
|
|
87
|
+
>
|
|
88
|
+
Isabelle
|
|
89
|
+
</button>
|
|
90
|
+
<button
|
|
91
|
+
aria-controls="basic--tabpanel--1"
|
|
92
|
+
aria-selected={false}
|
|
93
|
+
className="chakra-tabs__tab css-abpfcx"
|
|
94
|
+
id="basic--tab--1"
|
|
95
|
+
onClick={[Function]}
|
|
96
|
+
onFocus={[Function]}
|
|
97
|
+
role="tab"
|
|
98
|
+
tabIndex={-1}
|
|
99
|
+
type="button"
|
|
100
|
+
>
|
|
101
|
+
K.K. Slider
|
|
102
|
+
</button>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
<button
|
|
107
|
+
aria-label="Next"
|
|
108
|
+
className="chakra-button css-1whvqek"
|
|
109
|
+
data-testid="button"
|
|
110
|
+
id="tabs-next-basic"
|
|
111
|
+
onClick={[Function]}
|
|
112
|
+
type="button"
|
|
113
|
+
>
|
|
114
|
+
<svg
|
|
115
|
+
aria-hidden={true}
|
|
116
|
+
className="chakra-icon css-onkibi"
|
|
117
|
+
focusable={false}
|
|
118
|
+
id="tabs-next-icon-basic"
|
|
119
|
+
role="img"
|
|
120
|
+
title="arrow icon"
|
|
121
|
+
viewBox="0 0 24 24"
|
|
122
|
+
>
|
|
123
|
+
<g
|
|
124
|
+
stroke="currentColor"
|
|
125
|
+
strokeWidth="1.5"
|
|
126
|
+
>
|
|
127
|
+
<path
|
|
128
|
+
d="M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"
|
|
129
|
+
fill="none"
|
|
130
|
+
strokeLinecap="round"
|
|
131
|
+
/>
|
|
132
|
+
<path
|
|
133
|
+
d="M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"
|
|
134
|
+
fill="currentColor"
|
|
135
|
+
strokeLinecap="round"
|
|
136
|
+
/>
|
|
137
|
+
<circle
|
|
138
|
+
cx="12"
|
|
139
|
+
cy="12"
|
|
140
|
+
fill="none"
|
|
141
|
+
r="11.25"
|
|
142
|
+
strokeMiterlimit="10"
|
|
143
|
+
/>
|
|
144
|
+
</g>
|
|
145
|
+
</svg>
|
|
146
|
+
</button>
|
|
147
|
+
</div>
|
|
148
|
+
<div
|
|
149
|
+
className="chakra-tabs__tab-panels css-8atqhb"
|
|
150
|
+
>
|
|
151
|
+
<div
|
|
152
|
+
aria-labelledby="basic--tab-0"
|
|
153
|
+
className="chakra-tabs__tab-panel css-sjt5nk"
|
|
154
|
+
hidden={false}
|
|
155
|
+
id="basic--tabpanel-0"
|
|
156
|
+
role="tabpanel"
|
|
157
|
+
tabIndex={0}
|
|
158
|
+
>
|
|
159
|
+
<p>
|
|
160
|
+
Tom Nook,
|
|
161
|
+
<b>
|
|
162
|
+
known in Japan as Tanukichi
|
|
163
|
+
</b>
|
|
164
|
+
, is a fictional character in the Animal Crossing series who operates the village store.
|
|
165
|
+
</p>
|
|
166
|
+
</div>
|
|
167
|
+
<div
|
|
168
|
+
aria-labelledby="basic--tab-1"
|
|
169
|
+
className="chakra-tabs__tab-panel css-sjt5nk"
|
|
170
|
+
dangerouslySetInnerHTML={
|
|
171
|
+
Object {
|
|
172
|
+
"__html": "Isabelle, known as Shizue in Japan, is a fictional character from the Animal Crossing series of video games. She is a kindly Shih Tzu that debuted in the 2012 release Animal Crossing: New Leaf, where she serves as the secretary to the player character.",
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
hidden={true}
|
|
176
|
+
id="basic--tabpanel-1"
|
|
177
|
+
role="tabpanel"
|
|
178
|
+
tabIndex={0}
|
|
179
|
+
/>
|
|
180
|
+
<div
|
|
181
|
+
aria-labelledby="basic--tab-2"
|
|
182
|
+
className="chakra-tabs__tab-panel css-sjt5nk"
|
|
183
|
+
dangerouslySetInnerHTML={
|
|
184
|
+
Object {
|
|
185
|
+
"__html": "<p>Totakeke, more commonly known as <b>K.K. Slider or K.K.</b>, is a fictional character within the Animal Crossing franchise. One of the franchise's most popular characters, he debuted in the title Animal Crossing, and has appeared in every installment since.</p>",
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
hidden={true}
|
|
189
|
+
id="basic--tabpanel-2"
|
|
190
|
+
role="tabpanel"
|
|
191
|
+
tabIndex={0}
|
|
192
|
+
/>
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
`;
|
|
@@ -29,6 +29,7 @@ import Notification, {
|
|
|
29
29
|
import Placeholder from "../Placeholder/Placeholder";
|
|
30
30
|
import {
|
|
31
31
|
Template,
|
|
32
|
+
TemplateAboveHeader,
|
|
32
33
|
TemplateHeader,
|
|
33
34
|
TemplateBreakout,
|
|
34
35
|
TemplateContent,
|
|
@@ -49,7 +50,7 @@ import { getCategory } from "../../utils/componentCategories";
|
|
|
49
50
|
parameters={{
|
|
50
51
|
design: {
|
|
51
52
|
type: "figma",
|
|
52
|
-
url: "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/
|
|
53
|
+
url: "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Main?node-id=36835%3A26688",
|
|
53
54
|
},
|
|
54
55
|
}}
|
|
55
56
|
/>
|
|
@@ -59,14 +60,25 @@ import { getCategory } from "../../utils/componentCategories";
|
|
|
59
60
|
| Component Version | DS Version |
|
|
60
61
|
| ----------------- | ---------- |
|
|
61
62
|
| Added | `0.3.6` |
|
|
62
|
-
| Latest | `0.25.
|
|
63
|
+
| Latest | `0.25.10` |
|
|
63
64
|
|
|
64
65
|
## TemplateAppContainer Component
|
|
65
66
|
|
|
66
67
|
<Description of={TemplateAppContainer} />
|
|
67
68
|
|
|
68
|
-
If you have a custom `
|
|
69
|
-
element, set `
|
|
69
|
+
If you have a custom `Header` component that _already_ renders an HTML `<header>`
|
|
70
|
+
element, set `renderHeaderElement` to false so only one `<header>` element is
|
|
71
|
+
rendered.
|
|
72
|
+
|
|
73
|
+
Likewise, if you have a custom `Footer` component that _already_ renders an HTML
|
|
74
|
+
`<footer>` element, set `renderFooterElement` to false so only one `<footer>`
|
|
75
|
+
element is rendered.
|
|
76
|
+
|
|
77
|
+
If you need to render an alert or notification at the top of the page with an
|
|
78
|
+
`aside` HTML element or HTML element with the `role="complementary"` attribute,
|
|
79
|
+
then pass that alert or notification component to the `aboveHeader` prop. These
|
|
80
|
+
elements should _not_ be rendered in the `header` HTML section since that's an
|
|
81
|
+
accessibility violation.
|
|
70
82
|
|
|
71
83
|
<b>This is the recommended way to render an app page template.</b>
|
|
72
84
|
|
|
@@ -74,6 +86,7 @@ element, set `renderFooterElement` to false so only one `<footer>` element is re
|
|
|
74
86
|
import { TemplateAppContainer } from "@nypl/design-system-react-components";
|
|
75
87
|
|
|
76
88
|
<TemplateAppContainer
|
|
89
|
+
aboveHeader={<Placeholder variant="short">Above Header</Placeholder>}
|
|
77
90
|
header={<Placeholder variant="short">NYPL Header</Placeholder>}
|
|
78
91
|
breakout={
|
|
79
92
|
<>
|
|
@@ -98,6 +111,7 @@ import { TemplateAppContainer } from "@nypl/design-system-react-components";
|
|
|
98
111
|
<Story
|
|
99
112
|
name="TemplateAppContainer Component"
|
|
100
113
|
args={{
|
|
114
|
+
aboveHeader: <Placeholder variant="short">Above Header</Placeholder>,
|
|
101
115
|
breakout: (
|
|
102
116
|
<>
|
|
103
117
|
<Placeholder variant="short">Breadcrumbs</Placeholder>
|
|
@@ -116,8 +130,10 @@ import { TemplateAppContainer } from "@nypl/design-system-react-components";
|
|
|
116
130
|
header: <Placeholder variant="short">NYPL Header</Placeholder>,
|
|
117
131
|
sidebar: "left",
|
|
118
132
|
renderFooterElement: true,
|
|
133
|
+
renderHeaderElement: true,
|
|
119
134
|
}}
|
|
120
135
|
argTypes={{
|
|
136
|
+
aboveHeader: { control: false },
|
|
121
137
|
breakout: { control: false },
|
|
122
138
|
contentPrimary: { control: false },
|
|
123
139
|
contentSidebar: { control: false },
|
|
@@ -149,6 +165,7 @@ Basic "template" components structure:
|
|
|
149
165
|
```
|
|
150
166
|
import {
|
|
151
167
|
Template,
|
|
168
|
+
TemplateAboveHeader,
|
|
152
169
|
TemplateHeader,
|
|
153
170
|
TemplateBreakout,
|
|
154
171
|
TemplateContent,
|
|
@@ -160,6 +177,9 @@ import {
|
|
|
160
177
|
|
|
161
178
|
|
|
162
179
|
<Template>
|
|
180
|
+
<TemplateAboveHeader>
|
|
181
|
+
// ...
|
|
182
|
+
</TemplateAboveHeader>
|
|
163
183
|
<TemplateHeader>
|
|
164
184
|
// ...
|
|
165
185
|
<TemplateBreakout>
|
|
@@ -190,6 +210,7 @@ import {
|
|
|
190
210
|
sidebar: "left",
|
|
191
211
|
}}
|
|
192
212
|
argTypes={{
|
|
213
|
+
aboveHeader: { table: { disable: true } },
|
|
193
214
|
breakout: { table: { disable: true } },
|
|
194
215
|
contentPrimary: { table: { disable: true } },
|
|
195
216
|
contentSidebar: { table: { disable: true } },
|
|
@@ -201,6 +222,9 @@ import {
|
|
|
201
222
|
>
|
|
202
223
|
{(args) => (
|
|
203
224
|
<Template>
|
|
225
|
+
<TemplateAboveHeader>
|
|
226
|
+
<Placeholder variant="short">Above Header</Placeholder>
|
|
227
|
+
</TemplateAboveHeader>
|
|
204
228
|
<TemplateHeader>
|
|
205
229
|
<Placeholder variant="short">NYPL Header</Placeholder>
|
|
206
230
|
<TemplateBreakout>
|
|
@@ -242,6 +266,7 @@ import {
|
|
|
242
266
|
The components consist of:
|
|
243
267
|
|
|
244
268
|
- `Template`
|
|
269
|
+
- `TemplateAboveHeader`
|
|
245
270
|
- `TemplateHeader`
|
|
246
271
|
- `TemplateBreakout`
|
|
247
272
|
- `TemplateContent`
|
|
@@ -260,10 +285,25 @@ The components consist of:
|
|
|
260
285
|
|
|
261
286
|
<Description of={Template} />
|
|
262
287
|
|
|
288
|
+
#### TemplateAboveHeader
|
|
289
|
+
|
|
290
|
+
```
|
|
291
|
+
<Template>
|
|
292
|
+
<TemplateAboveHeader>
|
|
293
|
+
// ...
|
|
294
|
+
</TemplateAboveHeader>
|
|
295
|
+
<Template>
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
<Description of={TemplateAboveHeader} />
|
|
299
|
+
|
|
263
300
|
#### TemplateHeader
|
|
264
301
|
|
|
265
302
|
```
|
|
266
303
|
<Template>
|
|
304
|
+
<TemplateAboveHeader>
|
|
305
|
+
// ...
|
|
306
|
+
</TemplateAboveHeader>
|
|
267
307
|
<TemplateHeader>
|
|
268
308
|
// ...
|
|
269
309
|
</TemplateHeader>
|
|
@@ -276,6 +316,9 @@ The components consist of:
|
|
|
276
316
|
|
|
277
317
|
```
|
|
278
318
|
<Template>
|
|
319
|
+
<TemplateAboveHeader>
|
|
320
|
+
// ...
|
|
321
|
+
</TemplateAboveHeader>
|
|
279
322
|
<TemplateHeader>
|
|
280
323
|
<TemplateBreakout>
|
|
281
324
|
// ...
|
|
@@ -303,6 +346,9 @@ The components consist of:
|
|
|
303
346
|
|
|
304
347
|
```
|
|
305
348
|
<Template>
|
|
349
|
+
<TemplateAboveHeader>
|
|
350
|
+
// ...
|
|
351
|
+
</TemplateAboveHeader>
|
|
306
352
|
<TemplateHeader>...</TemplateHeader>
|
|
307
353
|
<TemplateContent>
|
|
308
354
|
<TemplateContentTop>
|
|
@@ -318,6 +364,9 @@ The components consist of:
|
|
|
318
364
|
|
|
319
365
|
```
|
|
320
366
|
<Template>
|
|
367
|
+
<TemplateAboveHeader>
|
|
368
|
+
// ...
|
|
369
|
+
</TemplateAboveHeader>
|
|
321
370
|
<TemplateHeader>...</TemplateHeader>
|
|
322
371
|
<TemplateContent>
|
|
323
372
|
<TemplateContentPrimary>
|
|
@@ -333,6 +382,9 @@ The components consist of:
|
|
|
333
382
|
|
|
334
383
|
```
|
|
335
384
|
<Template>
|
|
385
|
+
<TemplateAboveHeader>
|
|
386
|
+
// ...
|
|
387
|
+
</TemplateAboveHeader>
|
|
336
388
|
<TemplateHeader>...</TemplateHeader>
|
|
337
389
|
<TemplateContent sidebar="right">
|
|
338
390
|
<TemplateContentPrimary>
|
|
@@ -345,6 +397,9 @@ The components consist of:
|
|
|
345
397
|
<Template>
|
|
346
398
|
|
|
347
399
|
<Template>
|
|
400
|
+
<TemplateAboveHeader>
|
|
401
|
+
// ...
|
|
402
|
+
</TemplateAboveHeader>
|
|
348
403
|
<TemplateHeader>...</TemplateHeader>
|
|
349
404
|
<TemplateContent sidebar="left">
|
|
350
405
|
<TemplateContentSidebar>
|
|
@@ -363,6 +418,9 @@ The components consist of:
|
|
|
363
418
|
|
|
364
419
|
```
|
|
365
420
|
<Template>
|
|
421
|
+
<TemplateAboveHeader>
|
|
422
|
+
// ...
|
|
423
|
+
</TemplateAboveHeader>
|
|
366
424
|
<TemplateHeader>
|
|
367
425
|
// ...
|
|
368
426
|
</TemplateHeader>
|
|
@@ -425,6 +483,23 @@ This is best viewed in the Storybook "Canvas" and not "Docs" section.
|
|
|
425
483
|
<Canvas>
|
|
426
484
|
<Story name="Full Example with Template Children Components">
|
|
427
485
|
<Template>
|
|
486
|
+
<TemplateAboveHeader>
|
|
487
|
+
<Notification
|
|
488
|
+
notificationType={NotificationTypes.Standard}
|
|
489
|
+
notificationHeading="Standard Notification"
|
|
490
|
+
notificationContent={
|
|
491
|
+
<>
|
|
492
|
+
This is an "announcement" Notification with a heading. Cras mattis
|
|
493
|
+
consectetur purus sit amet fermentum. Maecenas faucibus mollis
|
|
494
|
+
interdum. Morbi leo risus, porta ac consectetur ac, vestibulum at
|
|
495
|
+
eros. Cum sociis natoque penatibus et magnis dis parturient
|
|
496
|
+
montes, nascetur ridiculus mus. Vivamus sagittis lacus vel augue
|
|
497
|
+
laoreet rutrum faucibus dolor auctor.
|
|
498
|
+
</>
|
|
499
|
+
}
|
|
500
|
+
showIcon={false}
|
|
501
|
+
/>
|
|
502
|
+
</TemplateAboveHeader>
|
|
428
503
|
<TemplateHeader>
|
|
429
504
|
<TemplateBreakout>
|
|
430
505
|
<Breadcrumbs
|