@nypl/design-system-react-components 0.26.1 → 1.0.0
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 +54 -0
- package/README.md +7 -7
- package/dist/components/Accordion/Accordion.d.ts +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +1 -5
- package/dist/components/Button/Button.d.ts +2 -10
- package/dist/components/ButtonGroup/ButtonGroup.d.ts +22 -0
- package/dist/components/Card/Card.d.ts +2 -2
- package/dist/components/Checkbox/Checkbox.d.ts +10 -8
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +1 -1
- package/dist/components/DatePicker/DatePicker.d.ts +1 -1
- package/dist/components/Form/Form.d.ts +2 -2
- package/dist/components/Grid/SimpleGrid.d.ts +6 -3
- package/dist/components/Heading/Heading.d.ts +2 -5
- package/dist/components/HelperErrorText/HelperErrorText.d.ts +1 -5
- package/dist/components/Hero/Hero.d.ts +13 -9
- package/dist/components/Icons/Icon.d.ts +6 -5
- package/dist/components/Icons/IconSvgs.d.ts +21 -21
- package/dist/components/Image/Image.d.ts +8 -5
- package/dist/components/Link/Link.d.ts +1 -9
- package/dist/components/List/List.d.ts +7 -11
- package/dist/components/Logo/Logo.d.ts +2 -5
- package/dist/components/Logo/LogoSvgs.d.ts +39 -39
- package/dist/components/Modal/Modal.d.ts +28 -8
- package/dist/components/Notification/Notification.d.ts +1 -1
- package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +2 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +1 -1
- package/dist/components/SearchBar/SearchBar.d.ts +3 -2
- package/dist/components/Select/Select.d.ts +2 -5
- package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -4
- package/dist/components/SkipNavigation/SkipNavigation.d.ts +17 -0
- package/dist/components/StatusBadge/StatusBadge.d.ts +2 -3
- package/dist/components/StructuredContent/StructuredContent.d.ts +2 -2
- package/dist/components/Table/Table.d.ts +1 -1
- package/dist/components/Template/Template.d.ts +2 -0
- package/dist/components/Text/Text.d.ts +1 -1
- package/dist/components/TextInput/TextInput.d.ts +21 -9
- package/dist/components/Toggle/Toggle.d.ts +1 -5
- package/dist/components/VideoPlayer/VideoPlayer.d.ts +2 -1
- package/dist/design-system-react-components.cjs.development.js +983 -1222
- 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 +982 -1285
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/helpers/types.d.ts +1 -0
- package/dist/index.d.ts +27 -48
- package/dist/styles.css +1 -1
- package/dist/theme/components/buttonGroup.d.ts +11 -0
- package/dist/theme/components/card.d.ts +104 -8
- package/dist/theme/components/componentWrapper.d.ts +4 -3
- package/dist/theme/components/customTable.d.ts +11 -14
- package/dist/theme/components/fieldset.d.ts +4 -3
- package/dist/theme/components/helperErrorText.d.ts +4 -3
- package/dist/theme/components/hero.d.ts +1 -1
- package/dist/theme/components/horizontalRule.d.ts +4 -3
- package/dist/theme/components/icon.d.ts +47743 -1
- package/dist/theme/components/image.d.ts +563 -10
- package/dist/theme/components/label.d.ts +4 -3
- package/dist/theme/components/list.d.ts +6 -7
- package/dist/theme/components/logo.d.ts +474 -1
- package/dist/theme/components/notification.d.ts +20 -16
- package/dist/theme/components/progressIndicator.d.ts +6 -4
- package/dist/theme/components/select.d.ts +4 -10
- package/dist/theme/components/skeletonLoader.d.ts +14 -10
- package/dist/theme/components/skipNavigation.d.ts +22 -0
- package/dist/theme/components/slider.d.ts +7 -6
- package/dist/theme/components/structuredContent.d.ts +10 -9
- package/dist/theme/components/text.d.ts +7 -1
- package/dist/theme/components/toggle.d.ts +6 -4
- package/dist/theme/provider.d.ts +2 -4
- package/dist/utils/componentCategories.d.ts +1 -1
- package/dist/utils/interfaces.d.ts +5 -0
- package/dist/utils/utils.d.ts +2 -18
- package/package.json +15 -16
- package/src/__tests__/setup.ts +3 -3
- package/src/__tests__/utils/utils.test.ts +1 -23
- package/src/components/AccessibilityGuide/SkipNavigation.stories.mdx +22 -14
- package/src/components/Accordion/Accordion.stories.mdx +43 -44
- package/src/components/Accordion/Accordion.test.tsx +5 -13
- package/src/components/Accordion/Accordion.tsx +14 -18
- package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +6 -6
- package/src/components/Autosuggest/Autosuggest.stories.mdx +1 -1
- package/src/components/Autosuggest/Autosuggest.stories.tsx +23 -25
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +21 -37
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +4 -17
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +18 -21
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +1 -100
- package/src/components/Button/Button.stories.mdx +89 -126
- package/src/components/Button/Button.test.tsx +16 -30
- package/src/components/Button/Button.tsx +14 -20
- package/src/components/ButtonGroup/ButtonGroup.stories.mdx +147 -0
- package/src/components/ButtonGroup/ButtonGroup.test.tsx +141 -0
- package/src/components/ButtonGroup/ButtonGroup.tsx +99 -0
- package/src/components/ButtonGroup/__snapshots__/ButtonGroup.test.tsx.snap +117 -0
- package/src/components/Card/Card.stories.mdx +144 -178
- package/src/components/Card/Card.test.tsx +36 -97
- package/src/components/Card/Card.tsx +78 -74
- package/src/components/Chakra/Box.stories.mdx +3 -7
- package/src/components/Chakra/Center.stories.mdx +6 -24
- package/src/components/Chakra/Flex.stories.mdx +5 -7
- package/src/components/Chakra/Grid.stories.mdx +1 -1
- package/src/components/Chakra/Stack.stories.mdx +10 -11
- package/src/components/Checkbox/Checkbox.stories.mdx +1 -1
- package/src/components/Checkbox/Checkbox.test.tsx +2 -2
- package/src/components/Checkbox/Checkbox.tsx +20 -13
- package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +6 -17
- package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +1 -7
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +33 -29
- package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +0 -11
- package/src/components/ComponentWrapper/ComponentWrapper.tsx +3 -10
- package/src/components/DatePicker/DatePicker.stories.mdx +23 -37
- package/src/components/DatePicker/DatePicker.test.tsx +21 -19
- package/src/components/DatePicker/DatePicker.tsx +57 -49
- package/src/components/Form/Form.stories.mdx +46 -31
- package/src/components/Form/Form.test.tsx +1 -18
- package/src/components/Form/Form.tsx +7 -7
- package/src/components/Grid/SimpleGrid.stories.mdx +73 -49
- package/src/components/Grid/SimpleGrid.test.tsx +7 -9
- package/src/components/Grid/SimpleGrid.tsx +14 -11
- package/src/components/Heading/Heading.stories.mdx +27 -72
- package/src/components/Heading/Heading.test.tsx +18 -44
- package/src/components/Heading/Heading.tsx +7 -10
- package/src/components/HelperErrorText/HelperErrorText.stories.mdx +1 -3
- package/src/components/HelperErrorText/HelperErrorText.tsx +1 -5
- package/src/components/Hero/Hero.stories.mdx +219 -216
- package/src/components/Hero/Hero.test.tsx +107 -223
- package/src/components/Hero/Hero.tsx +63 -61
- package/src/components/Icons/Icon.stories.mdx +172 -118
- package/src/components/Icons/Icon.test.tsx +8 -16
- package/src/components/Icons/Icon.tsx +75 -29
- package/src/components/Icons/IconSvgs.tsx +42 -42
- package/src/components/Image/Image.stories.mdx +45 -132
- package/src/components/Image/Image.test.tsx +16 -31
- package/src/components/Image/Image.tsx +28 -12
- package/src/components/Link/Link.stories.mdx +30 -94
- package/src/components/Link/Link.test.tsx +25 -75
- package/src/components/Link/Link.tsx +43 -56
- package/src/components/Link/__snapshots__/Link.test.tsx.snap +1 -2
- package/src/components/List/List.stories.mdx +20 -31
- package/src/components/List/List.test.tsx +24 -43
- package/src/components/List/List.tsx +25 -36
- package/src/components/Logo/Logo.stories.mdx +94 -50
- package/src/components/Logo/Logo.test.tsx +10 -19
- package/src/components/Logo/Logo.tsx +50 -17
- package/src/components/Logo/LogoSvgs.tsx +78 -78
- package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +4 -4
- package/src/components/Modal/Modal.stories.mdx +245 -139
- package/src/components/Modal/Modal.test.tsx +147 -10
- package/src/components/Modal/Modal.tsx +140 -20
- package/src/components/Modal/__snapshots__/Modal.test.tsx.snap +25 -0
- package/src/components/Notification/Notification.stories.mdx +10 -28
- package/src/components/Notification/Notification.test.tsx +9 -12
- package/src/components/Notification/Notification.tsx +34 -37
- package/src/components/Pagination/Pagination.stories.mdx +3 -4
- package/src/components/Pagination/Pagination.tsx +15 -10
- package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +27 -53
- package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +9 -10
- package/src/components/ProgressIndicator/ProgressIndicator.tsx +17 -21
- package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +0 -10
- package/src/components/Radio/Radio.stories.mdx +1 -1
- package/src/components/Radio/Radio.tsx +9 -6
- package/src/components/RadioGroup/RadioGroup.stories.mdx +15 -16
- package/src/components/RadioGroup/RadioGroup.test.tsx +2 -8
- package/src/components/RadioGroup/RadioGroup.tsx +28 -24
- package/src/components/SearchBar/SearchBar.stories.mdx +4 -4
- package/src/components/SearchBar/SearchBar.test.tsx +1 -1
- package/src/components/SearchBar/SearchBar.tsx +14 -22
- package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +1 -13
- package/src/components/Select/Select.stories.mdx +10 -25
- package/src/components/Select/Select.test.tsx +6 -7
- package/src/components/Select/Select.tsx +28 -35
- package/src/components/Select/__snapshots__/Select.test.tsx.snap +24 -24
- package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +17 -56
- package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +7 -21
- package/src/components/SkeletonLoader/SkeletonLoader.tsx +9 -8
- package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +33 -33
- package/src/components/SkipNavigation/SkipNavigation.stories.mdx +90 -0
- package/src/components/SkipNavigation/SkipNavigation.test.tsx +63 -0
- package/src/components/SkipNavigation/SkipNavigation.tsx +51 -0
- package/src/components/SkipNavigation/__snapshots__/SkipNavigation.test.tsx.snap +130 -0
- package/src/components/Slider/Slider.stories.mdx +19 -53
- package/src/components/Slider/Slider.test.tsx +2 -2
- package/src/components/Slider/Slider.tsx +10 -12
- package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +2 -9
- package/src/components/StatusBadge/StatusBadge.stories.mdx +6 -21
- package/src/components/StatusBadge/StatusBadge.test.tsx +2 -3
- package/src/components/StatusBadge/StatusBadge.tsx +3 -10
- package/src/components/StructuredContent/StructuredContent.stories.mdx +30 -58
- package/src/components/StructuredContent/StructuredContent.test.tsx +42 -44
- package/src/components/StructuredContent/StructuredContent.tsx +9 -18
- package/src/components/StyleGuide/Bidirectionality.stories.mdx +9 -23
- package/src/components/StyleGuide/Buttons.stories.mdx +63 -63
- package/src/components/StyleGuide/ColorCard.tsx +2 -4
- package/src/components/StyleGuide/Colors.stories.mdx +9 -10
- package/src/components/StyleGuide/DesignTokens.stories.mdx +5 -7
- package/src/components/StyleGuide/Forms.stories.mdx +2 -2
- package/src/components/StyleGuide/Iconography.stories.mdx +60 -78
- package/src/components/StyleGuide/Spacing.stories.mdx +1 -2
- package/src/components/StyleGuide/Typography.stories.mdx +16 -19
- package/src/components/Table/Table.stories.mdx +85 -1
- package/src/components/Table/Table.test.tsx +57 -1
- package/src/components/Table/Table.tsx +7 -4
- package/src/components/Table/__snapshots__/Table.test.tsx.snap +121 -0
- package/src/components/Tabs/Tabs.stories.mdx +1 -1
- package/src/components/Tabs/Tabs.test.tsx +2 -2
- package/src/components/Tabs/Tabs.tsx +26 -27
- package/src/components/Template/Template.stories.mdx +49 -54
- package/src/components/Template/Template.tsx +9 -3
- package/src/components/Text/Text.stories.mdx +5 -11
- package/src/components/Text/Text.test.tsx +3 -6
- package/src/components/Text/Text.tsx +3 -5
- package/src/components/TextInput/TextInput.stories.mdx +10 -22
- package/src/components/TextInput/TextInput.test.tsx +32 -62
- package/src/components/TextInput/TextInput.tsx +61 -30
- package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +1 -0
- package/src/components/Toggle/Toggle.stories.mdx +5 -16
- package/src/components/Toggle/Toggle.test.tsx +2 -3
- package/src/components/Toggle/Toggle.tsx +9 -10
- package/src/components/VideoPlayer/VideoPlayer.stories.mdx +13 -29
- package/src/components/VideoPlayer/VideoPlayer.test.tsx +18 -23
- package/src/components/VideoPlayer/VideoPlayer.tsx +13 -10
- package/src/docs/Chakra.stories.mdx +14 -11
- package/src/docs/Welcome.stories.mdx +23 -43
- package/src/helpers/types.ts +1 -0
- package/src/hooks/tests/useNYPLTheme.test.tsx +1 -1
- package/src/hooks/useNYPLTheme.stories.mdx +3 -6
- package/src/index.ts +52 -46
- package/src/styles.scss +0 -1
- package/src/theme/components/buttonGroup.ts +10 -0
- package/src/theme/components/card.ts +50 -15
- package/src/theme/components/componentWrapper.ts +5 -1
- package/src/theme/components/customTable.ts +8 -2
- package/src/theme/components/fieldset.ts +5 -1
- package/src/theme/components/helperErrorText.ts +5 -1
- package/src/theme/components/hero.ts +2 -2
- package/src/theme/components/horizontalRule.ts +5 -1
- package/src/theme/components/icon.ts +7 -1
- package/src/theme/components/image.ts +14 -3
- package/src/theme/components/label.ts +5 -1
- package/src/theme/components/list.ts +8 -2
- package/src/theme/components/logo.ts +5 -1
- package/src/theme/components/notification.ts +38 -14
- package/src/theme/components/progressIndicator.ts +10 -5
- package/src/theme/components/select.ts +5 -6
- package/src/theme/components/skeletonLoader.ts +8 -2
- package/src/theme/components/skipNavigation.ts +26 -0
- package/src/theme/components/slider.ts +13 -1
- package/src/theme/components/structuredContent.ts +11 -1
- package/src/theme/components/text.ts +12 -5
- package/src/theme/components/toggle.ts +9 -3
- package/src/theme/foundations/colors.ts +6 -9
- package/src/theme/index.ts +4 -0
- package/src/theme/provider.tsx +1 -1
- package/src/utils/componentCategories.ts +13 -5
- package/src/utils/interfaces.ts +5 -0
- package/src/utils/utils.ts +2 -32
- package/dist/components/Accordion/AccordionTypes.d.ts +0 -5
- package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +0 -8
- package/dist/components/Button/ButtonTypes.d.ts +0 -8
- package/dist/components/DatePicker/DatePickerTypes.d.ts +0 -5
- package/dist/components/Form/FormTypes.d.ts +0 -2
- package/dist/components/Grid/GridTypes.d.ts +0 -9
- package/dist/components/Heading/HeadingTypes.d.ts +0 -14
- package/dist/components/Hero/HeroTypes.d.ts +0 -12
- package/dist/components/Icons/IconTypes.d.ts +0 -77
- package/dist/components/Image/ImageTypes.d.ts +0 -22
- package/dist/components/Link/LinkTypes.d.ts +0 -8
- package/dist/components/List/ListTypes.d.ts +0 -5
- package/dist/components/Logo/LogoTypes.d.ts +0 -54
- package/dist/components/Notification/NotificationTypes.d.ts +0 -5
- package/dist/components/ProgressIndicator/ProgressIndicatorTypes.d.ts +0 -8
- package/dist/components/Select/SelectTypes.d.ts +0 -8
- package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +0 -5
- package/dist/components/StatusBadge/StatusBadgeTypes.d.ts +0 -5
- package/dist/components/StructuredContent/StructuredContentTypes.d.ts +0 -5
- package/dist/components/Text/TextTypes.d.ts +0 -6
- package/dist/components/TextInput/TextInputTypes.d.ts +0 -25
- package/dist/components/Toggle/ToggleTypes.d.ts +0 -4
- package/dist/components/VideoPlayer/VideoPlayerTypes.d.ts +0 -9
- package/dist/helpers/enums.d.ts +0 -4
- package/dist/utils/siteSections.d.ts +0 -2
- package/src/components/Accordion/AccordionTypes.tsx +0 -5
- package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +0 -8
- package/src/components/Button/ButtonTypes.tsx +0 -8
- package/src/components/DatePicker/DatePickerTypes.tsx +0 -5
- package/src/components/Form/FormTypes.tsx +0 -3
- package/src/components/Grid/GridTypes.tsx +0 -9
- package/src/components/Heading/HeadingTypes.tsx +0 -15
- package/src/components/Hero/HeroTypes.tsx +0 -20
- package/src/components/Icons/IconTypes.tsx +0 -83
- package/src/components/Image/ImageTypes.ts +0 -24
- package/src/components/Link/LinkTypes.tsx +0 -8
- package/src/components/List/ListTypes.tsx +0 -5
- package/src/components/Logo/LogoTypes.tsx +0 -56
- package/src/components/Modal/_Modal.scss +0 -18
- package/src/components/Notification/NotificationTypes.tsx +0 -5
- package/src/components/ProgressIndicator/ProgressIndicatorTypes.ts +0 -8
- package/src/components/Select/SelectTypes.tsx +0 -10
- package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +0 -5
- package/src/components/StatusBadge/StatusBadgeTypes.tsx +0 -5
- package/src/components/StructuredContent/StructuredContentTypes.tsx +0 -5
- package/src/components/Text/TextTypes.tsx +0 -6
- package/src/components/TextInput/TextInputTypes.tsx +0 -48
- package/src/components/Toggle/ToggleTypes.tsx +0 -4
- package/src/components/VideoPlayer/VideoPlayerTypes.tsx +0 -10
- package/src/helpers/enums.ts +0 -4
- package/src/utils/siteSections.ts +0 -10
|
@@ -8,18 +8,7 @@ import {
|
|
|
8
8
|
import { withDesign } from "storybook-addon-designs";
|
|
9
9
|
|
|
10
10
|
import Heading from "./Heading";
|
|
11
|
-
import { HeadingSizes, HeadingLevels } from "./HeadingTypes";
|
|
12
11
|
import { getCategory } from "../../utils/componentCategories";
|
|
13
|
-
import { getStorybookEnumValues } from "../../utils/utils";
|
|
14
|
-
|
|
15
|
-
export const sizesEnumValues = getStorybookEnumValues(
|
|
16
|
-
HeadingSizes,
|
|
17
|
-
"HeadingSizes"
|
|
18
|
-
);
|
|
19
|
-
export const levelsEnumValues = getStorybookEnumValues(
|
|
20
|
-
HeadingLevels,
|
|
21
|
-
"HeadingLevels"
|
|
22
|
-
);
|
|
23
12
|
|
|
24
13
|
<Meta
|
|
25
14
|
title={getCategory("Heading")}
|
|
@@ -33,17 +22,10 @@ export const levelsEnumValues = getStorybookEnumValues(
|
|
|
33
22
|
jest: ["Heading.test.tsx"],
|
|
34
23
|
}}
|
|
35
24
|
argTypes={{
|
|
36
|
-
additionalStyles: { control: false },
|
|
37
25
|
className: { control: false },
|
|
38
26
|
id: { control: false },
|
|
39
27
|
level: {
|
|
40
|
-
|
|
41
|
-
options: levelsEnumValues.options,
|
|
42
|
-
table: { defaultValue: { summary: "HeadingLevels.Two" } },
|
|
43
|
-
},
|
|
44
|
-
size: {
|
|
45
|
-
control: { type: "select" },
|
|
46
|
-
options: sizesEnumValues.options,
|
|
28
|
+
table: { defaultValue: { summary: "two" } },
|
|
47
29
|
},
|
|
48
30
|
}}
|
|
49
31
|
/>
|
|
@@ -53,7 +35,7 @@ export const levelsEnumValues = getStorybookEnumValues(
|
|
|
53
35
|
| Component Version | DS Version |
|
|
54
36
|
| ----------------- | ---------- |
|
|
55
37
|
| Added | `0.0.4` |
|
|
56
|
-
| Latest | `0.
|
|
38
|
+
| Latest | `0.28.0` |
|
|
57
39
|
|
|
58
40
|
## Table of Contents
|
|
59
41
|
|
|
@@ -79,23 +61,16 @@ semantic elements can be overwritten using the `size` prop.
|
|
|
79
61
|
<Story
|
|
80
62
|
name="Heading with Controls"
|
|
81
63
|
args={{
|
|
82
|
-
additionalStyles: undefined,
|
|
83
64
|
className: undefined,
|
|
84
65
|
id: "heading-id",
|
|
85
|
-
level: "
|
|
66
|
+
level: "two",
|
|
86
67
|
size: undefined,
|
|
87
68
|
text: "Default Heading",
|
|
88
69
|
url: undefined,
|
|
89
70
|
urlClass: undefined,
|
|
90
71
|
}}
|
|
91
72
|
>
|
|
92
|
-
{(args) =>
|
|
93
|
-
<Heading
|
|
94
|
-
{...args}
|
|
95
|
-
level={levelsEnumValues.getValue(args.level)}
|
|
96
|
-
size={args.size && sizesEnumValues.getValue(args.size)}
|
|
97
|
-
/>
|
|
98
|
-
)}
|
|
73
|
+
{(args) => <Heading {...args} />}
|
|
99
74
|
</Story>
|
|
100
75
|
</Canvas>
|
|
101
76
|
|
|
@@ -125,36 +100,16 @@ Resources:
|
|
|
125
100
|
<Canvas>
|
|
126
101
|
<Story name="Default Heading Styles">
|
|
127
102
|
<div>
|
|
128
|
-
<Heading
|
|
129
|
-
|
|
130
|
-
level={HeadingLevels.One}
|
|
131
|
-
text="<h1> Heading 1 - HeadingLevels.One"
|
|
132
|
-
/>
|
|
133
|
-
<Heading
|
|
134
|
-
id="heading-two"
|
|
135
|
-
level={HeadingLevels.Two}
|
|
136
|
-
text="<h2> Heading 2 - HeadingLevels.Two"
|
|
137
|
-
/>
|
|
103
|
+
<Heading id="heading-one" level="one" text="<h1> Heading 1 - 'one'" />
|
|
104
|
+
<Heading id="heading-two" level="two" text="<h2> Heading 2 - 'two'" />
|
|
138
105
|
<Heading
|
|
139
106
|
id="heading-three"
|
|
140
|
-
level=
|
|
141
|
-
text="<h3> Heading 3 -
|
|
142
|
-
/>
|
|
143
|
-
<Heading
|
|
144
|
-
id="heading-four"
|
|
145
|
-
level={HeadingLevels.Four}
|
|
146
|
-
text="<h4> Heading 4 - HeadingLevels.Four"
|
|
147
|
-
/>
|
|
148
|
-
<Heading
|
|
149
|
-
id="heading-five"
|
|
150
|
-
level={HeadingLevels.Five}
|
|
151
|
-
text="<h5> Heading 5 - HeadingLevels.Five"
|
|
152
|
-
/>
|
|
153
|
-
<Heading
|
|
154
|
-
id="heading-six"
|
|
155
|
-
level={HeadingLevels.Six}
|
|
156
|
-
text="<h6> Heading 6 - HeadingLevels.Six"
|
|
107
|
+
level="three"
|
|
108
|
+
text="<h3> Heading 3 - 'three'"
|
|
157
109
|
/>
|
|
110
|
+
<Heading id="heading-four" level="four" text="<h4> Heading 4 - 'four'" />
|
|
111
|
+
<Heading id="heading-five" level="five" text="<h5> Heading 5 - 'five'" />
|
|
112
|
+
<Heading id="heading-six" level="six" text="<h6> Heading 6 - 'six'" />
|
|
158
113
|
</div>
|
|
159
114
|
</Story>
|
|
160
115
|
</Canvas>
|
|
@@ -162,34 +117,34 @@ Resources:
|
|
|
162
117
|
## Size Styles
|
|
163
118
|
|
|
164
119
|
Note: The `level` prop for the `Heading`s in the next example are all set to
|
|
165
|
-
`level=
|
|
120
|
+
`level="one"`.
|
|
166
121
|
|
|
167
122
|
<Canvas>
|
|
168
123
|
<Story name="Size Styles">
|
|
169
124
|
<div>
|
|
170
125
|
<Heading
|
|
171
126
|
id="heading-primary"
|
|
172
|
-
level=
|
|
173
|
-
size=
|
|
174
|
-
text="<h1>
|
|
127
|
+
level="one"
|
|
128
|
+
size="primary"
|
|
129
|
+
text="<h1> 'primary'"
|
|
175
130
|
/>
|
|
176
131
|
<Heading
|
|
177
132
|
id="heading-secondary"
|
|
178
|
-
level=
|
|
179
|
-
size=
|
|
180
|
-
text="<h1>
|
|
133
|
+
level="one"
|
|
134
|
+
size="secondary"
|
|
135
|
+
text="<h1> 'secondary'"
|
|
181
136
|
/>
|
|
182
137
|
<Heading
|
|
183
138
|
id="heading-tertiary"
|
|
184
|
-
level=
|
|
185
|
-
size=
|
|
186
|
-
text="<h1>
|
|
139
|
+
level="one"
|
|
140
|
+
size="tertiary"
|
|
141
|
+
text="<h1> 'tertiary'"
|
|
187
142
|
/>
|
|
188
143
|
<Heading
|
|
189
144
|
id="heading-callout"
|
|
190
|
-
level=
|
|
191
|
-
size=
|
|
192
|
-
text="<h1>
|
|
145
|
+
level="one"
|
|
146
|
+
size="callout"
|
|
147
|
+
text="<h1> 'callout'"
|
|
193
148
|
/>
|
|
194
149
|
</div>
|
|
195
150
|
</Story>
|
|
@@ -199,7 +154,7 @@ Note: The `level` prop for the `Heading`s in the next example are all set to
|
|
|
199
154
|
|
|
200
155
|
<Canvas>
|
|
201
156
|
<Story name="Heading with Bold Text">
|
|
202
|
-
<Heading id="headingWithBold" level=
|
|
157
|
+
<Heading id="headingWithBold" level="one">
|
|
203
158
|
<>
|
|
204
159
|
Heading with a <b>Bold</b> Word
|
|
205
160
|
</>
|
|
@@ -215,12 +170,12 @@ When the `url` prop is passed to `Heading`, a child `<a>` element is created and
|
|
|
215
170
|
<Story name="Headings with Links">
|
|
216
171
|
<Heading
|
|
217
172
|
id="heading-with-link-url"
|
|
218
|
-
level=
|
|
173
|
+
level="two"
|
|
219
174
|
text="Heading with URL Props"
|
|
220
175
|
url="http://apple.com"
|
|
221
176
|
urlClass="special-link"
|
|
222
177
|
/>
|
|
223
|
-
<Heading id="heading-with-link-child"
|
|
178
|
+
<Heading id="heading-with-link-child">
|
|
224
179
|
<>
|
|
225
180
|
Heading with a Word <a href="#hello">Link</a>
|
|
226
181
|
</>
|
|
@@ -4,12 +4,11 @@ import { axe } from "jest-axe";
|
|
|
4
4
|
import renderer from "react-test-renderer";
|
|
5
5
|
|
|
6
6
|
import Heading from "./Heading";
|
|
7
|
-
import { HeadingSizes, HeadingLevels } from "./HeadingTypes";
|
|
8
7
|
|
|
9
8
|
describe("Heading Accessibility", () => {
|
|
10
9
|
it("passes axe accessibility test", async () => {
|
|
11
10
|
const { container } = render(
|
|
12
|
-
<Heading id="h1" level=
|
|
11
|
+
<Heading id="h1" level="one" text="Heading 1" />
|
|
13
12
|
);
|
|
14
13
|
expect(await axe(container)).toHaveNoViolations();
|
|
15
14
|
});
|
|
@@ -17,17 +16,13 @@ describe("Heading Accessibility", () => {
|
|
|
17
16
|
|
|
18
17
|
describe("Heading", () => {
|
|
19
18
|
it("renders and HTML heading element with the correct level", () => {
|
|
20
|
-
render(<Heading id="h1" level=
|
|
19
|
+
render(<Heading id="h1" level="one" text="Heading 1" />);
|
|
21
20
|
expect(screen.getByRole("heading", { level: 1 })).toBeInTheDocument();
|
|
22
21
|
expect(screen.getByText("Heading 1")).toBeInTheDocument();
|
|
23
22
|
});
|
|
24
23
|
|
|
25
24
|
it("can pass heading content as child", () => {
|
|
26
|
-
render(
|
|
27
|
-
<Heading id="h1" level={HeadingLevels.Two}>
|
|
28
|
-
Heading 2
|
|
29
|
-
</Heading>
|
|
30
|
-
);
|
|
25
|
+
render(<Heading id="h1">Heading 2</Heading>);
|
|
31
26
|
expect(screen.getByRole("heading", { level: 2 })).toBeInTheDocument();
|
|
32
27
|
expect(screen.getByText("Heading 2")).toBeInTheDocument();
|
|
33
28
|
});
|
|
@@ -37,15 +32,9 @@ describe("Heading", () => {
|
|
|
37
32
|
expect(screen.getByRole("heading", { level: 2 })).toBeInTheDocument();
|
|
38
33
|
});
|
|
39
34
|
|
|
40
|
-
// TODO: check that header children are links
|
|
41
|
-
// it("Throws error when invalid heading is passed as child", () => {
|
|
42
|
-
// expect(() => render(<Heading id="h1" level={HeadingLevels.Three}><span>oh no</span></Heading>))
|
|
43
|
-
// .to.throw("Headings can only be plain text or bold");
|
|
44
|
-
// });
|
|
45
|
-
|
|
46
35
|
it("can pass a span element as a child", () => {
|
|
47
36
|
render(
|
|
48
|
-
<Heading id="h1" level=
|
|
37
|
+
<Heading id="h1" level="one">
|
|
49
38
|
<span>
|
|
50
39
|
Text <b>hi</b>
|
|
51
40
|
</span>
|
|
@@ -56,7 +45,7 @@ describe("Heading", () => {
|
|
|
56
45
|
|
|
57
46
|
it("prioritizes the child when both child and the text prop are passed", () => {
|
|
58
47
|
render(
|
|
59
|
-
<Heading id="h1" level=
|
|
48
|
+
<Heading id="h1" level="one" text="prop text">
|
|
60
49
|
child text
|
|
61
50
|
</Heading>
|
|
62
51
|
);
|
|
@@ -64,14 +53,7 @@ describe("Heading", () => {
|
|
|
64
53
|
});
|
|
65
54
|
|
|
66
55
|
it("renders an anchor element when the `url` prop is passed", () => {
|
|
67
|
-
render(
|
|
68
|
-
<Heading
|
|
69
|
-
id="h1"
|
|
70
|
-
level={HeadingLevels.One}
|
|
71
|
-
text="Heading 1"
|
|
72
|
-
url="fake-url"
|
|
73
|
-
/>
|
|
74
|
-
);
|
|
56
|
+
render(<Heading id="h1" level="one" text="Heading 1" url="fake-url" />);
|
|
75
57
|
|
|
76
58
|
expect(screen.getByRole("link")).toBeInTheDocument();
|
|
77
59
|
});
|
|
@@ -80,7 +62,7 @@ describe("Heading", () => {
|
|
|
80
62
|
render(
|
|
81
63
|
<Heading
|
|
82
64
|
id="h1"
|
|
83
|
-
level=
|
|
65
|
+
level="one"
|
|
84
66
|
url="fake-url"
|
|
85
67
|
urlClass="fake-class"
|
|
86
68
|
text="Heading 1"
|
|
@@ -92,7 +74,7 @@ describe("Heading", () => {
|
|
|
92
74
|
});
|
|
93
75
|
|
|
94
76
|
it("throws error when neither child nor text is passed", () => {
|
|
95
|
-
expect(() => render(<Heading id="h1" level=
|
|
77
|
+
expect(() => render(<Heading id="h1" level="one" />)).toThrow(
|
|
96
78
|
"NYPL Reservoir Heading: No children or value was passed to the `text` prop."
|
|
97
79
|
);
|
|
98
80
|
});
|
|
@@ -100,7 +82,7 @@ describe("Heading", () => {
|
|
|
100
82
|
it("throws error when heading with many children is passed", () => {
|
|
101
83
|
expect(() =>
|
|
102
84
|
render(
|
|
103
|
-
<Heading id="h1" level=
|
|
85
|
+
<Heading id="h1" level="four">
|
|
104
86
|
<span>too</span>
|
|
105
87
|
<span>many</span>
|
|
106
88
|
</Heading>
|
|
@@ -112,8 +94,8 @@ describe("Heading", () => {
|
|
|
112
94
|
render(
|
|
113
95
|
<Heading
|
|
114
96
|
id="h1"
|
|
115
|
-
level=
|
|
116
|
-
size=
|
|
97
|
+
level="one"
|
|
98
|
+
size="secondary"
|
|
117
99
|
text="Heading with Secondary size"
|
|
118
100
|
/>
|
|
119
101
|
);
|
|
@@ -124,13 +106,11 @@ describe("Heading", () => {
|
|
|
124
106
|
|
|
125
107
|
it("renders the UI snapshot correctly", () => {
|
|
126
108
|
const basic = renderer
|
|
127
|
-
.create(
|
|
128
|
-
<Heading id="basic" level={HeadingLevels.One} text="Heading text" />
|
|
129
|
-
)
|
|
109
|
+
.create(<Heading id="basic" level="one" text="Heading text" />)
|
|
130
110
|
.toJSON();
|
|
131
111
|
const basicWithChildText = renderer
|
|
132
112
|
.create(
|
|
133
|
-
<Heading id="basicWithChildText" level=
|
|
113
|
+
<Heading id="basicWithChildText" level="one">
|
|
134
114
|
Heading text
|
|
135
115
|
</Heading>
|
|
136
116
|
)
|
|
@@ -139,26 +119,20 @@ describe("Heading", () => {
|
|
|
139
119
|
.create(
|
|
140
120
|
<Heading
|
|
141
121
|
id="customDisplaySize"
|
|
142
|
-
level=
|
|
143
|
-
size=
|
|
122
|
+
level="one"
|
|
123
|
+
size="secondary"
|
|
144
124
|
text="Heading with Secondary size"
|
|
145
125
|
/>
|
|
146
126
|
)
|
|
147
127
|
.toJSON();
|
|
148
128
|
const otherLevel = renderer
|
|
149
|
-
.create(
|
|
150
|
-
<Heading
|
|
151
|
-
id="otherLevel"
|
|
152
|
-
level={HeadingLevels.Six}
|
|
153
|
-
text="Heading level six"
|
|
154
|
-
/>
|
|
155
|
-
)
|
|
129
|
+
.create(<Heading id="otherLevel" level="six" text="Heading level six" />)
|
|
156
130
|
.toJSON();
|
|
157
131
|
const withLink = renderer
|
|
158
132
|
.create(
|
|
159
133
|
<Heading
|
|
160
134
|
id="withLink"
|
|
161
|
-
level=
|
|
135
|
+
level="one"
|
|
162
136
|
text="Heading text is a link"
|
|
163
137
|
url="fake-url"
|
|
164
138
|
/>
|
|
@@ -166,7 +140,7 @@ describe("Heading", () => {
|
|
|
166
140
|
.toJSON();
|
|
167
141
|
const withCustomLink = renderer
|
|
168
142
|
.create(
|
|
169
|
-
<Heading id="withCustomLink" level=
|
|
143
|
+
<Heading id="withCustomLink" level="one">
|
|
170
144
|
<>
|
|
171
145
|
Part of the heading text is
|
|
172
146
|
<a href="fake-url" className="custom-link">
|
|
@@ -5,12 +5,11 @@ import {
|
|
|
5
5
|
} from "@chakra-ui/react";
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
|
|
8
|
-
import { HeadingSizes, HeadingLevels } from "./HeadingTypes";
|
|
9
8
|
import Link from "../Link/Link";
|
|
10
|
-
|
|
9
|
+
|
|
10
|
+
export type HeadingSizes = "primary" | "secondary" | "tertiary" | "callout";
|
|
11
|
+
export type HeadingLevels = "one" | "two" | "three" | "four" | "five" | "six";
|
|
11
12
|
export interface HeadingProps {
|
|
12
|
-
/** Optionally pass in additional Chakra-based styles. */
|
|
13
|
-
additionalStyles?: { [key: string]: any };
|
|
14
13
|
/** Optional className that appears in addition to `heading` */
|
|
15
14
|
className?: string;
|
|
16
15
|
/** Optional ID that other components can cross reference for accessibility purposes */
|
|
@@ -32,7 +31,7 @@ export interface HeadingProps {
|
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
/** Map the word heading level to the number heading level. The default is 2. */
|
|
35
|
-
const getMappedLevel = (level =
|
|
34
|
+
const getMappedLevel = (level = "two") => {
|
|
36
35
|
const levelMap = {
|
|
37
36
|
one: 1,
|
|
38
37
|
two: 2,
|
|
@@ -47,10 +46,9 @@ const getMappedLevel = (level = HeadingLevels.Two) => {
|
|
|
47
46
|
export const Heading = chakra(
|
|
48
47
|
(props: React.PropsWithChildren<HeadingProps>) => {
|
|
49
48
|
const {
|
|
50
|
-
additionalStyles = {},
|
|
51
49
|
className,
|
|
52
50
|
id,
|
|
53
|
-
level =
|
|
51
|
+
level = "two",
|
|
54
52
|
size,
|
|
55
53
|
text,
|
|
56
54
|
url,
|
|
@@ -58,11 +56,10 @@ export const Heading = chakra(
|
|
|
58
56
|
...rest
|
|
59
57
|
} = props;
|
|
60
58
|
const finalLevel = getMappedLevel(level);
|
|
61
|
-
const variant = size ?
|
|
59
|
+
const variant = size ? size : `h${finalLevel}`;
|
|
62
60
|
const styles = useStyleConfig("Heading", { variant });
|
|
63
61
|
// Combine native base styles with any additional styles.
|
|
64
62
|
// This is used in the `Hero` and `Notification` components.
|
|
65
|
-
const finalStyles = { ...styles, ...additionalStyles };
|
|
66
63
|
const asHeading: any = `h${finalLevel}`;
|
|
67
64
|
|
|
68
65
|
if (!props.children && !text) {
|
|
@@ -92,7 +89,7 @@ export const Heading = chakra(
|
|
|
92
89
|
as={asHeading}
|
|
93
90
|
className={className}
|
|
94
91
|
id={id}
|
|
95
|
-
sx={
|
|
92
|
+
sx={styles}
|
|
96
93
|
{...rest}
|
|
97
94
|
>
|
|
98
95
|
{content}
|
|
@@ -25,7 +25,6 @@ import DSProvider from "../../theme/provider";
|
|
|
25
25
|
jest: ["HelperErrorText.test.tsx"],
|
|
26
26
|
}}
|
|
27
27
|
argTypes={{
|
|
28
|
-
additionalStyles: { control: false },
|
|
29
28
|
ariaAtomic: {
|
|
30
29
|
control: false,
|
|
31
30
|
table: { defaultValue: { summary: true } },
|
|
@@ -47,7 +46,7 @@ import DSProvider from "../../theme/provider";
|
|
|
47
46
|
| Component Version | DS Version |
|
|
48
47
|
| ----------------- | ---------- |
|
|
49
48
|
| Added | `0.0.10` |
|
|
50
|
-
| Latest | `0.
|
|
49
|
+
| Latest | `0.28.0` |
|
|
51
50
|
|
|
52
51
|
## Table of Contents
|
|
53
52
|
|
|
@@ -67,7 +66,6 @@ import DSProvider from "../../theme/provider";
|
|
|
67
66
|
<Story
|
|
68
67
|
name="HelperErrorText with Controls"
|
|
69
68
|
args={{
|
|
70
|
-
additionalStyles: undefined,
|
|
71
69
|
ariaAtomic: undefined,
|
|
72
70
|
ariaLive: "polite",
|
|
73
71
|
className: undefined,
|
|
@@ -5,8 +5,6 @@ export type AriaLiveValues = "assertive" | "off" | "polite";
|
|
|
5
5
|
export type HelperErrorTextType = string | JSX.Element;
|
|
6
6
|
|
|
7
7
|
interface HelperErrorTextProps {
|
|
8
|
-
/** Optionally pass in additional Chakra-based styles. */
|
|
9
|
-
additionalStyles?: { [key: string]: any };
|
|
10
8
|
/** Aria attribute. When true, assistive technologies will
|
|
11
9
|
* read the entire DOM element. When false, only changes (additionals or
|
|
12
10
|
* removals) will be read. True by default. */
|
|
@@ -33,7 +31,6 @@ interface HelperErrorTextProps {
|
|
|
33
31
|
*/
|
|
34
32
|
export const HelperErrorText = chakra(
|
|
35
33
|
({
|
|
36
|
-
additionalStyles = {},
|
|
37
34
|
ariaAtomic = true,
|
|
38
35
|
ariaLive = "polite",
|
|
39
36
|
className = "",
|
|
@@ -45,14 +42,13 @@ export const HelperErrorText = chakra(
|
|
|
45
42
|
// Only announce the text in the invalid state.
|
|
46
43
|
const announceAriaLive = isInvalid;
|
|
47
44
|
const styles = useStyleConfig("HelperErrorText", { isInvalid });
|
|
48
|
-
const finalStyles = { ...styles, ...additionalStyles };
|
|
49
45
|
const props = {
|
|
50
46
|
"aria-atomic": ariaAtomic,
|
|
51
47
|
"aria-live": announceAriaLive ? ariaLive : "off",
|
|
52
48
|
className,
|
|
53
49
|
"data-isinvalid": isInvalid,
|
|
54
50
|
id,
|
|
55
|
-
__css:
|
|
51
|
+
__css: styles,
|
|
56
52
|
...rest,
|
|
57
53
|
};
|
|
58
54
|
return typeof text === "string" ? (
|