@nypl/design-system-react-components 0.23.4 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +98 -1
- package/README.md +46 -11
- package/dist/components/Accordion/Accordion.d.ts +14 -14
- package/dist/components/Autosuggest/Autosuggest.stories.d.ts +1 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +11 -14
- package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +6 -0
- package/dist/components/Button/Button.d.ts +6 -13
- package/dist/components/Button/ButtonTypes.d.ts +5 -3
- package/dist/components/Card/Card.d.ts +59 -10
- package/dist/components/Card/CardTypes.d.ts +19 -0
- package/dist/components/CardEdition/CardEdition.d.ts +21 -0
- package/dist/components/{StyleGuide/Colors.stories.d.ts → CardEdition/CardEdition.stories.d.ts} +5 -2
- package/dist/components/Checkbox/Checkbox.d.ts +21 -16
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +43 -0
- package/dist/components/CheckboxGroup/CheckboxGroupLayoutTypes.d.ts +4 -0
- package/dist/components/DatePicker/DatePicker.d.ts +79 -0
- package/dist/components/DatePicker/DatePickerTypes.d.ts +5 -0
- package/dist/components/Form/Form.d.ts +16 -8
- package/dist/components/Form/FormTypes.d.ts +2 -0
- package/dist/components/Grid/GridTypes.d.ts +9 -0
- package/dist/components/Grid/SimpleGrid.d.ts +14 -0
- package/dist/components/Heading/Heading.d.ts +9 -11
- package/dist/components/Heading/{HeadingDisplaySizes.d.ts → HeadingTypes.d.ts} +8 -0
- package/dist/components/HelperErrorText/HelperErrorText.stories.d.ts +2 -1
- package/dist/components/Hero/Hero.d.ts +19 -14
- package/dist/components/Hero/HeroTypes.d.ts +10 -5
- package/dist/components/Icons/Icon.d.ts +13 -16
- package/dist/components/Icons/IconSvgs.d.ts +4 -0
- package/dist/components/Icons/IconTypes.d.ts +78 -60
- package/dist/components/Image/Image.stories.d.ts +2 -1
- package/dist/components/Label/Label.d.ts +10 -26
- package/dist/components/Link/Link.d.ts +8 -12
- package/dist/components/List/List.stories.d.ts +1 -0
- package/dist/components/Radio/Radio.d.ts +30 -24
- package/dist/components/RadioGroup/RadioGroup.d.ts +40 -0
- package/dist/components/RadioGroup/RadioGroupLayoutTypes.d.ts +4 -0
- package/dist/components/SearchBar/SearchBar.d.ts +45 -27
- package/dist/components/Select/Select.d.ts +34 -35
- package/dist/components/Select/SelectTypes.d.ts +4 -0
- package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +1 -1
- package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +2 -2
- package/dist/components/StatusBadge/StatusBadge.d.ts +8 -6
- package/dist/components/StatusBadge/StatusBadgeTypes.d.ts +5 -0
- package/dist/components/Tabs/Tabs.d.ts +25 -0
- package/dist/components/Template/Template.d.ts +91 -0
- package/dist/components/Text/Text.d.ts +16 -0
- package/dist/components/Text/TextTypes.d.ts +6 -0
- package/dist/components/TextInput/TextInput.d.ts +37 -30
- package/dist/components/TextInput/TextInputTypes.d.ts +5 -0
- package/dist/design-system-react-components.cjs.development.js +4102 -917
- 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 +4023 -920
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/index.d.ts +23 -5
- package/dist/resources.scss +133 -24
- package/dist/styles.css +1 -1
- package/dist/theme/components/accordion.d.ts +25 -0
- package/dist/theme/components/breadcrumb.d.ts +90 -0
- package/dist/theme/components/button.d.ts +109 -0
- package/dist/theme/components/checkbox.d.ts +91 -0
- package/dist/theme/components/customCheckboxGroup.d.ts +18 -0
- package/dist/theme/components/customRadioGroup.d.ts +18 -0
- package/dist/theme/components/global.d.ts +55 -0
- package/dist/theme/components/globalMixins.d.ts +15 -0
- package/dist/theme/components/heading.d.ts +110 -0
- package/dist/theme/components/hero.d.ts +492 -0
- package/dist/theme/components/icon.d.ts +13 -0
- package/dist/theme/components/label.d.ts +16 -0
- package/dist/theme/components/link.d.ts +45 -0
- package/dist/theme/components/radio.d.ts +95 -0
- package/dist/theme/components/searchBar.d.ts +20 -0
- package/dist/theme/components/select.d.ts +58 -0
- package/dist/theme/components/statusBadge.d.ts +25 -0
- package/dist/theme/components/tabs.d.ts +85 -0
- package/dist/theme/components/template.d.ts +105 -0
- package/dist/theme/components/text.d.ts +20 -0
- package/dist/theme/components/textInput.d.ts +105 -0
- package/dist/theme/foundations/breakpoints.d.ts +23 -0
- package/dist/theme/foundations/colors.d.ts +3 -0
- package/dist/theme/foundations/global.d.ts +23 -0
- package/dist/theme/foundations/shadows.d.ts +4 -0
- package/dist/theme/foundations/spacing.d.ts +77 -0
- package/dist/theme/foundations/typography.d.ts +8 -0
- package/dist/theme/index.d.ts +20 -0
- package/dist/theme/provider.d.ts +5 -0
- package/dist/theme/types.d.ts +1 -0
- package/dist/utils/utils.d.ts +6 -0
- package/package.json +9 -2
- package/src/components/Accordion/Accordion.stories.mdx +233 -33
- package/src/components/Accordion/Accordion.test.tsx +135 -19
- package/src/components/Accordion/Accordion.tsx +81 -56
- package/src/components/Autosuggest/Autosuggest.stories.mdx +4 -3
- package/src/components/Autosuggest/Autosuggest.stories.tsx +1 -1
- package/src/components/Autosuggest/_Autosuggest.scss +2 -2
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +57 -56
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +31 -25
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +71 -73
- package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +6 -0
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +100 -0
- package/src/components/Button/Button.stories.mdx +125 -138
- package/src/components/Button/Button.test.tsx +65 -11
- package/src/components/Button/Button.tsx +72 -68
- package/src/components/Button/ButtonTypes.tsx +4 -2
- package/src/components/Button/_Button.scss +7 -92
- package/src/components/Button/__snapshots__/Button.test.tsx.snap +58 -3
- package/src/components/Card/Card.stories.mdx +694 -0
- package/src/components/Card/Card.test.tsx +97 -102
- package/src/components/Card/Card.tsx +182 -31
- package/src/components/Card/CardTypes.tsx +21 -0
- package/src/components/Card/_Card.scss +234 -49
- package/src/components/{Card/Card.stories.tsx → CardEdition/CardEdition.stories.tsx} +32 -22
- package/src/components/CardEdition/CardEdition.test.tsx +395 -0
- package/src/components/CardEdition/CardEdition.tsx +60 -0
- package/src/components/CardEdition/_CardEdition.scss +138 -0
- package/src/components/Chakra/Box.stories.mdx +57 -0
- package/src/components/Chakra/Center.stories.mdx +99 -0
- package/src/components/Chakra/Grid.stories.mdx +79 -0
- package/src/components/Chakra/Stack.stories.mdx +93 -0
- package/src/components/Checkbox/Checkbox.stories.mdx +57 -35
- package/src/components/Checkbox/Checkbox.test.tsx +117 -147
- package/src/components/Checkbox/Checkbox.tsx +76 -50
- package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +325 -0
- package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +249 -0
- package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +345 -0
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +148 -0
- package/src/components/CheckboxGroup/CheckboxGroupLayoutTypes.tsx +4 -0
- package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +1360 -0
- package/src/components/DatePicker/DatePicker.stories.mdx +284 -0
- package/src/components/DatePicker/DatePicker.test.tsx +657 -0
- package/src/components/DatePicker/DatePicker.tsx +396 -0
- package/src/components/DatePicker/DatePickerTypes.tsx +5 -0
- package/src/components/DatePicker/_DatePicker.scss +76 -0
- package/src/components/Form/Form.stories.mdx +130 -27
- package/src/components/Form/Form.test.tsx +78 -36
- package/src/components/Form/Form.tsx +53 -19
- package/src/components/Form/FormTypes.tsx +3 -0
- package/src/components/Form/__snapshots__/Form.test.tsx.snap +38 -0
- package/src/components/Grid/GridTypes.tsx +9 -0
- package/src/components/Grid/SimpleGrid.stories.mdx +275 -0
- package/src/components/Grid/SimpleGrid.test.tsx +66 -0
- package/src/components/Grid/SimpleGrid.tsx +37 -0
- package/src/components/Grid/__snapshots__/SimpleGrid.test.tsx.snap +8 -0
- package/src/components/Heading/Heading.stories.mdx +63 -33
- package/src/components/Heading/Heading.test.tsx +24 -16
- package/src/components/Heading/Heading.tsx +54 -38
- package/src/components/Heading/{HeadingDisplaySizes.tsx → HeadingTypes.tsx} +9 -0
- package/src/components/HelperErrorText/HelperErrorText.stories.tsx +2 -1
- package/src/components/HelperErrorText/_HelperErrorText.scss +1 -1
- package/src/components/Hero/Hero.stories.mdx +195 -85
- package/src/components/Hero/Hero.test.tsx +544 -113
- package/src/components/Hero/Hero.tsx +80 -93
- package/src/components/Hero/HeroTypes.tsx +17 -5
- package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +307 -0
- package/src/components/HorizontalRule/HorizontalRule.stories.mdx +6 -1
- package/src/components/HorizontalRule/_HorizontalRule.scss +1 -1
- package/src/components/Icons/Icon.stories.mdx +89 -74
- package/src/components/Icons/Icon.test.tsx +30 -22
- package/src/components/Icons/Icon.tsx +63 -61
- package/src/components/Icons/IconSvgs.tsx +8 -0
- package/src/components/Icons/IconTypes.tsx +80 -60
- package/src/components/Image/Image.stories.tsx +2 -1
- package/src/components/Input/_Input.scss +2 -2
- package/src/components/Label/Label.stories.mdx +77 -0
- package/src/components/Label/Label.test.tsx +43 -12
- package/src/components/Label/Label.tsx +28 -45
- package/src/components/Label/__snapshots__/Label.test.tsx.snap +41 -0
- package/src/components/Link/Link.stories.mdx +47 -41
- package/src/components/Link/Link.test.tsx +33 -44
- package/src/components/Link/Link.tsx +114 -100
- package/src/components/List/List.stories.mdx +7 -3
- package/src/components/List/List.stories.tsx +14 -9
- package/src/components/List/List.test.tsx +12 -8
- package/src/components/List/List.tsx +9 -7
- package/src/components/List/_List.scss +3 -3
- package/src/components/Modal/Modal.stories.mdx +7 -3
- package/src/components/Modal/_Modal.scss +1 -1
- package/src/components/Notification/Notification.stories.mdx +99 -65
- package/src/components/Notification/Notification.test.tsx +3 -16
- package/src/components/Notification/Notification.tsx +12 -12
- package/src/components/Notification/_Notification.scss +5 -4
- package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +1 -1
- package/src/components/Pagination/Pagination.stories.mdx +7 -1
- package/src/components/Pagination/Pagination.test.tsx +16 -10
- package/src/components/Radio/Radio.stories.mdx +57 -46
- package/src/components/Radio/Radio.test.tsx +92 -138
- package/src/components/Radio/Radio.tsx +70 -69
- package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +250 -0
- package/src/components/RadioGroup/RadioGroup.stories.mdx +247 -0
- package/src/components/RadioGroup/RadioGroup.test.tsx +327 -0
- package/src/components/RadioGroup/RadioGroup.tsx +154 -0
- package/src/components/RadioGroup/RadioGroupLayoutTypes.tsx +4 -0
- package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +1101 -0
- package/src/components/SearchBar/SearchBar.Test.tsx +151 -16
- package/src/components/SearchBar/SearchBar.stories.mdx +196 -224
- package/src/components/SearchBar/SearchBar.tsx +151 -46
- package/src/components/Select/Select.stories.mdx +193 -168
- package/src/components/Select/Select.test.tsx +129 -324
- package/src/components/Select/Select.tsx +120 -160
- package/src/components/Select/SelectTypes.tsx +4 -0
- package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +18 -29
- package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +7 -7
- package/src/components/SkeletonLoader/SkeletonLoader.tsx +4 -2
- package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +2 -2
- package/src/components/SkeletonLoader/_SkeletonLoader.scss +3 -3
- package/src/components/StatusBadge/StatusBadge.stories.mdx +91 -0
- package/src/components/StatusBadge/StatusBadge.test.tsx +35 -7
- package/src/components/StatusBadge/StatusBadge.tsx +24 -25
- package/src/components/StatusBadge/StatusBadgeTypes.tsx +5 -0
- package/src/components/StatusBadge/__snapshots__/StatusBadge.test.tsx.snap +28 -0
- package/src/components/StyleGuide/Bidirectionality.stories.mdx +112 -90
- package/src/components/StyleGuide/Buttons.stories.mdx +98 -100
- package/src/components/StyleGuide/Colors.stories.mdx +336 -0
- package/src/components/StyleGuide/Forms.stories.mdx +85 -0
- package/src/components/StyleGuide/Iconography.stories.mdx +86 -93
- package/src/components/StyleGuide/Spacing.stories.mdx +0 -1
- package/src/components/StyleGuide/Typography.stories.mdx +164 -166
- package/src/components/StyleGuide/UIDocCard.tsx +4 -4
- package/src/components/Tabs/Tabs.stories.mdx +221 -0
- package/src/components/Tabs/Tabs.test.tsx +264 -0
- package/src/components/Tabs/Tabs.tsx +220 -0
- package/src/components/Template/Template.stories.mdx +574 -0
- package/src/components/Template/Template.test.tsx +124 -0
- package/src/components/Template/Template.tsx +226 -0
- package/src/components/Text/Text.stories.mdx +70 -0
- package/src/components/Text/Text.test.tsx +63 -0
- package/src/components/Text/Text.tsx +55 -0
- package/src/components/Text/TextTypes.tsx +6 -0
- package/src/components/Text/__snapshots__/Text.test.tsx.snap +33 -0
- package/src/components/TextInput/TextInput.stories.mdx +90 -90
- package/src/components/TextInput/TextInput.test.tsx +103 -83
- package/src/components/TextInput/TextInput.tsx +108 -91
- package/src/components/TextInput/TextInputTypes.tsx +6 -0
- package/src/components/VideoPlayer/VideoPlayer.stories.mdx +2 -1
- package/src/components/VideoPlayer/VideoPlayer.tsx +4 -2
- package/src/components/VideoPlayer/_VideoPlayer.scss +1 -1
- package/src/docs/Chakra.stories.mdx +341 -0
- package/src/docs/Intro.stories.mdx +31 -24
- package/src/index.ts +70 -5
- package/src/styles/01-colors/_colors-brand.scss +6 -4
- package/src/styles/01-colors/_colors-utility.scss +14 -15
- package/src/styles/03-space/_space-inline.scss +47 -7
- package/src/styles/03-space/_space-inset.scss +33 -5
- package/src/styles/03-space/_space-stack.scss +48 -8
- package/src/styles/base/_02-breakpoints.scss +5 -4
- package/src/styles/base/_04-base.scss +2 -1
- package/src/styles/base/_place-holder.scss +1 -1
- package/src/styles/base/_typography.scss +1 -29
- package/src/styles.scss +22 -25
- package/src/theme/components/accordion.ts +30 -0
- package/src/theme/components/breadcrumb.ts +77 -0
- package/src/theme/components/button.ts +125 -0
- package/src/theme/components/checkbox.ts +107 -0
- package/src/theme/components/customCheckboxGroup.ts +12 -0
- package/src/theme/components/customRadioGroup.ts +12 -0
- package/src/theme/components/global.ts +71 -0
- package/src/theme/components/globalMixins.ts +16 -0
- package/src/theme/components/heading.ts +72 -0
- package/src/theme/components/hero.ts +239 -0
- package/src/theme/components/icon.ts +79 -0
- package/src/theme/components/label.ts +17 -0
- package/src/theme/components/link.ts +47 -0
- package/src/theme/components/radio.ts +106 -0
- package/src/theme/components/searchBar.ts +21 -0
- package/src/theme/components/select.ts +50 -0
- package/src/theme/components/statusBadge.ts +27 -0
- package/src/theme/components/tabs.ts +79 -0
- package/src/theme/components/template.ts +114 -0
- package/src/theme/components/text.ts +31 -0
- package/src/theme/components/textInput.ts +61 -0
- package/src/theme/foundations/breakpoints.ts +24 -0
- package/src/theme/foundations/colors.ts +208 -0
- package/src/theme/foundations/global.ts +26 -0
- package/src/theme/foundations/shadows.ts +5 -0
- package/src/theme/foundations/spacing.ts +85 -0
- package/src/theme/foundations/typography.ts +35 -0
- package/src/theme/index.ts +88 -0
- package/src/theme/provider.tsx +9 -0
- package/src/theme/types.ts +1 -0
- package/src/utils/componentCategories.ts +56 -21
- package/src/utils/utils.ts +13 -0
- package/dist/components/Accordion/Accordion.stories.d.ts +0 -5
- package/dist/components/Card/Card.stories.d.ts +0 -27
- package/dist/components/Label/Label.stories.d.ts +0 -12
- package/dist/components/StatusBadge/StatusBadge.stories.d.ts +0 -8
- package/dist/components/Template/Template.stories.d.ts +0 -29
- package/src/components/Accordion/Accordion.stories.tsx +0 -65
- package/src/components/Accordion/_Accordion.scss +0 -81
- package/src/components/Breadcrumbs/_Breadcrumbs.scss +0 -97
- package/src/components/Checkbox/_Checkbox.scss +0 -97
- package/src/components/Form/_Form.scss +0 -28
- package/src/components/Heading/_Heading.scss +0 -163
- package/src/components/Hero/_Hero.scss +0 -256
- package/src/components/Icons/_Icons.scss +0 -116
- package/src/components/Label/Label.stories.tsx +0 -30
- package/src/components/Label/_Label.scss +0 -22
- package/src/components/Link/_Link.scss +0 -73
- package/src/components/Radio/_Radio.scss +0 -84
- package/src/components/SearchBar/_SearchBar.scss +0 -16
- package/src/components/Select/_Select.scss +0 -82
- package/src/components/StatusBadge/StatusBadge.stories.tsx +0 -33
- package/src/components/StatusBadge/_StatusBadge.scss +0 -23
- package/src/components/StyleGuide/Colors.stories.tsx +0 -288
- package/src/components/Template/Template.stories.tsx +0 -85
- package/src/components/Template/_Template.scss +0 -63
- package/src/components/TextInput/_TextInput.scss +0 -59
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
display: block;
|
|
30
30
|
font-weight: 300;
|
|
31
31
|
margin-top: -6px; // accounts for the focus ring on the input
|
|
32
|
-
outline: 1px solid var(--ui-gray-light);
|
|
32
|
+
outline: 1px solid var(--ui-gray-light-cool);
|
|
33
33
|
position: absolute;
|
|
34
34
|
width: 100%;
|
|
35
35
|
z-index: 2;
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
.react-autosuggest__suggestion--highlighted {
|
|
50
|
-
background-color: var(--ui-gray-light);
|
|
50
|
+
background-color: var(--ui-gray-light-cool);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
.auto-suggest-bottom {
|
|
@@ -3,101 +3,98 @@ import {
|
|
|
3
3
|
Story,
|
|
4
4
|
Canvas,
|
|
5
5
|
ArgsTable,
|
|
6
|
-
Preview,
|
|
7
6
|
Description,
|
|
8
7
|
} from "@storybook/addon-docs/blocks";
|
|
9
8
|
import { withDesign } from "storybook-addon-designs";
|
|
10
9
|
|
|
11
10
|
import Breadcrumbs from "./Breadcrumbs";
|
|
11
|
+
import { ColorVariants } from "./BreadcrumbsTypes";
|
|
12
|
+
import DSProvider from "../../theme/provider";
|
|
12
13
|
import Heading from "../Heading/Heading";
|
|
14
|
+
import { HeadingLevels } from "../Heading/HeadingTypes";
|
|
13
15
|
import Link from "../Link/Link";
|
|
14
|
-
import
|
|
16
|
+
import { getCategory } from "../../utils/componentCategories";
|
|
15
17
|
|
|
16
18
|
<Meta
|
|
17
|
-
title="Breadcrumbs"
|
|
19
|
+
title={getCategory("Breadcrumbs")}
|
|
18
20
|
component={Breadcrumbs}
|
|
19
21
|
decorators={[withDesign]}
|
|
20
22
|
parameters={{
|
|
21
23
|
design: {
|
|
22
24
|
type: "figma",
|
|
23
25
|
url:
|
|
24
|
-
"https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/
|
|
26
|
+
"https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Main?node-id=10766%3A1031",
|
|
25
27
|
},
|
|
26
28
|
jest: ["Breadcrumbs.test.tsx"],
|
|
27
29
|
}}
|
|
28
30
|
argTypes={{
|
|
29
|
-
|
|
31
|
+
id: { table: { disable: true } },
|
|
30
32
|
className: { table: { disable: true } },
|
|
31
|
-
modifiers: { table: { disable: true } },
|
|
32
33
|
}}
|
|
33
34
|
/>
|
|
34
35
|
|
|
35
36
|
# Breadcrumbs
|
|
36
37
|
|
|
38
|
+
| Component Version | DS Version |
|
|
39
|
+
| ----------------- | ---------- |
|
|
40
|
+
| Added | `0.0.3` |
|
|
41
|
+
| Latest | `0.25.1` |
|
|
42
|
+
|
|
37
43
|
<Description of={Breadcrumbs} />
|
|
38
44
|
|
|
39
45
|
The `Breadcrumbs` component is a navigation element that provides a breadcrumb path that reflects the site structure and allows a user to navigate to any page available in the breadcrumb hierarchy.
|
|
40
46
|
|
|
41
|
-
<
|
|
47
|
+
<Canvas withToolbar>
|
|
42
48
|
<Story
|
|
43
|
-
name="
|
|
49
|
+
name="Breadcrumbs Props"
|
|
44
50
|
args={{
|
|
45
|
-
|
|
51
|
+
breadcrumbsData: [
|
|
46
52
|
{ url: "#", text: "Parent" },
|
|
47
53
|
{ url: "#", text: "Child" },
|
|
48
54
|
{ url: "#", text: "Grandchild" },
|
|
49
55
|
],
|
|
56
|
+
id: "init-breadcrumbs",
|
|
50
57
|
}}
|
|
51
58
|
>
|
|
52
59
|
{(args) => <Breadcrumbs {...args} />}
|
|
53
60
|
</Story>
|
|
54
|
-
</
|
|
61
|
+
</Canvas>
|
|
55
62
|
|
|
56
|
-
<ArgsTable story="
|
|
63
|
+
<ArgsTable story="Breadcrumbs Props" />
|
|
57
64
|
|
|
58
65
|
### Long Titles
|
|
59
66
|
|
|
60
67
|
<Canvas>
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
{
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
<DSProvider>
|
|
69
|
+
<Breadcrumbs
|
|
70
|
+
breadcrumbsData={[
|
|
71
|
+
{ url: "#", text: "Parent with a Long Name" },
|
|
72
|
+
{ url: "#", text: "Child with an Even Longer Name" },
|
|
73
|
+
{
|
|
74
|
+
url: "#",
|
|
75
|
+
text: "Grandchild with an Exceptionally Long Name",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
url: "#",
|
|
79
|
+
text:
|
|
80
|
+
"Great-Grandchild with the Longest Name That Will Wrap onto the Second Line of the Breadcrumb Component Under the Right Circumstances",
|
|
81
|
+
},
|
|
82
|
+
]}
|
|
83
|
+
/>
|
|
84
|
+
</DSProvider>
|
|
76
85
|
</Canvas>
|
|
77
86
|
|
|
78
87
|
## Color Variations
|
|
79
88
|
|
|
80
|
-
The `Breadcrumbs` component background color
|
|
89
|
+
The `Breadcrumbs` component background color can be set using the `colorVariant` prop and the `ColorVariants` enum. If the `colorVariant` prop is omitted, the default background color is `black`.
|
|
81
90
|
|
|
82
|
-
<
|
|
83
|
-
<Story
|
|
84
|
-
name="Color Variations"
|
|
85
|
-
args={{
|
|
86
|
-
breadcrumbs: [
|
|
87
|
-
{ url: "#", text: "Parent" },
|
|
88
|
-
{ url: "#", text: "Child" },
|
|
89
|
-
{
|
|
90
|
-
url: "#",
|
|
91
|
-
text: "Grandchild",
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
|
-
}}
|
|
95
|
-
>
|
|
91
|
+
<Canvas>
|
|
92
|
+
<Story name="Color Variations" args={{}}>
|
|
96
93
|
{(args) => (
|
|
97
94
|
<div className="nypl--books-and-more">
|
|
98
|
-
<Heading level={
|
|
95
|
+
<Heading level={HeadingLevels.Three}>Books and More</Heading>
|
|
99
96
|
<Breadcrumbs
|
|
100
|
-
|
|
97
|
+
breadcrumbsData={[
|
|
101
98
|
{ url: "#", text: "Parent" },
|
|
102
99
|
{ url: "#", text: "Child" },
|
|
103
100
|
{
|
|
@@ -105,17 +102,18 @@ The `Breadcrumbs` component background color will match the secondary section co
|
|
|
105
102
|
text: "Grandchild",
|
|
106
103
|
},
|
|
107
104
|
]}
|
|
105
|
+
colorVariant={ColorVariants.BooksAndMore}
|
|
108
106
|
/>
|
|
109
107
|
</div>
|
|
110
108
|
)}
|
|
111
109
|
</Story>
|
|
112
|
-
</
|
|
110
|
+
</Canvas>
|
|
113
111
|
|
|
114
112
|
<Canvas>
|
|
115
|
-
<
|
|
116
|
-
<Heading level={
|
|
113
|
+
<DSProvider>
|
|
114
|
+
<Heading level={HeadingLevels.Three}>Locations</Heading>
|
|
117
115
|
<Breadcrumbs
|
|
118
|
-
|
|
116
|
+
breadcrumbsData={[
|
|
119
117
|
{ url: "#", text: "Parent" },
|
|
120
118
|
{ url: "#", text: "Child" },
|
|
121
119
|
{
|
|
@@ -123,15 +121,16 @@ The `Breadcrumbs` component background color will match the secondary section co
|
|
|
123
121
|
text: "Grandchild",
|
|
124
122
|
},
|
|
125
123
|
]}
|
|
124
|
+
colorVariant={ColorVariants.Locations}
|
|
126
125
|
/>
|
|
127
|
-
</
|
|
126
|
+
</DSProvider>
|
|
128
127
|
</Canvas>
|
|
129
128
|
|
|
130
129
|
<Canvas>
|
|
131
|
-
<
|
|
132
|
-
<Heading level={
|
|
130
|
+
<DSProvider>
|
|
131
|
+
<Heading level={HeadingLevels.Three}>Research</Heading>
|
|
133
132
|
<Breadcrumbs
|
|
134
|
-
|
|
133
|
+
breadcrumbsData={[
|
|
135
134
|
{ url: "#", text: "Parent" },
|
|
136
135
|
{ url: "#", text: "Child" },
|
|
137
136
|
{
|
|
@@ -139,15 +138,16 @@ The `Breadcrumbs` component background color will match the secondary section co
|
|
|
139
138
|
text: "Grandchild",
|
|
140
139
|
},
|
|
141
140
|
]}
|
|
141
|
+
colorVariant={ColorVariants.Research}
|
|
142
142
|
/>
|
|
143
|
-
</
|
|
143
|
+
</DSProvider>
|
|
144
144
|
</Canvas>
|
|
145
145
|
|
|
146
146
|
<Canvas>
|
|
147
|
-
<
|
|
148
|
-
<Heading level={
|
|
147
|
+
<DSProvider>
|
|
148
|
+
<Heading level={HeadingLevels.Three}>What's On</Heading>
|
|
149
149
|
<Breadcrumbs
|
|
150
|
-
|
|
150
|
+
breadcrumbsData={[
|
|
151
151
|
{ url: "#", text: "Parent" },
|
|
152
152
|
{ url: "#", text: "Child" },
|
|
153
153
|
{
|
|
@@ -155,6 +155,7 @@ The `Breadcrumbs` component background color will match the secondary section co
|
|
|
155
155
|
text: "Grandchild",
|
|
156
156
|
},
|
|
157
157
|
]}
|
|
158
|
+
colorVariant={ColorVariants.WhatsOn}
|
|
158
159
|
/>
|
|
159
|
-
</
|
|
160
|
+
</DSProvider>
|
|
160
161
|
</Canvas>
|
|
@@ -1,62 +1,68 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import renderer from "react-test-renderer";
|
|
3
4
|
import { axe } from "jest-axe";
|
|
4
5
|
|
|
5
6
|
import Breadcrumbs from "./Breadcrumbs";
|
|
6
7
|
|
|
7
8
|
describe("Breadcrumbs Accessibility", () => {
|
|
8
|
-
const
|
|
9
|
+
const breadcrumbsData = [
|
|
9
10
|
{ url: "#string1", text: "string1" },
|
|
10
11
|
{ url: "#string2", text: "string2" },
|
|
11
12
|
];
|
|
12
13
|
it("passes axe accessibility test", async () => {
|
|
13
14
|
const { container } = render(
|
|
14
|
-
<Breadcrumbs
|
|
15
|
+
<Breadcrumbs breadcrumbsData={breadcrumbsData} />
|
|
15
16
|
);
|
|
16
17
|
expect(await axe(container)).toHaveNoViolations();
|
|
17
18
|
});
|
|
18
19
|
});
|
|
19
20
|
|
|
20
|
-
describe("Breadcrumbs", () => {
|
|
21
|
-
|
|
21
|
+
describe("Breadcrumbs Snapshot", () => {
|
|
22
|
+
it("Renders the UI snapshot correctly", () => {
|
|
23
|
+
const breadcrumbsData = [
|
|
24
|
+
{ url: "#string1", text: "string1" },
|
|
25
|
+
{ url: "#string2", text: "string2" },
|
|
26
|
+
{ url: "#string3", text: "string3" },
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
const breadcrumbsSnapshot = renderer
|
|
30
|
+
.create(
|
|
31
|
+
<Breadcrumbs id="breadcrumbs-test" breadcrumbsData={breadcrumbsData} />
|
|
32
|
+
)
|
|
33
|
+
.toJSON();
|
|
34
|
+
|
|
35
|
+
expect(breadcrumbsSnapshot).toMatchSnapshot();
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe("Breadcrumbs Testing", () => {
|
|
40
|
+
const breadcrumbsData = [
|
|
22
41
|
{ url: "#string1", text: "string1" },
|
|
23
42
|
{ url: "#string2", text: "string2" },
|
|
24
|
-
|
|
25
|
-
const breadcrumbComponent = [
|
|
26
|
-
<a key="link1" href="#component1">
|
|
27
|
-
<span>component1</span>
|
|
28
|
-
</a>,
|
|
29
|
-
<a key="link2" href="#component2">
|
|
30
|
-
component2
|
|
31
|
-
</a>,
|
|
43
|
+
{ url: "#string3", text: "string3" },
|
|
32
44
|
];
|
|
33
45
|
|
|
34
46
|
it("Renders a tag with custom text", () => {
|
|
35
|
-
render(<Breadcrumbs
|
|
47
|
+
render(<Breadcrumbs breadcrumbsData={breadcrumbsData} />);
|
|
36
48
|
|
|
49
|
+
// The last breadcrumb (the active page) is not a link.
|
|
37
50
|
expect(screen.getAllByRole("link")).toHaveLength(2);
|
|
38
51
|
expect(screen.getAllByRole("link")[0]).toHaveTextContent("string1");
|
|
39
52
|
expect(screen.getAllByRole("link")[1]).toHaveTextContent("string2");
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
it("Renders breadcrumb when passed components", () => {
|
|
43
|
-
render(<Breadcrumbs breadcrumbs={breadcrumbComponent} />);
|
|
44
|
-
|
|
45
|
-
expect(screen.getAllByRole("link")).toHaveLength(2);
|
|
46
|
-
expect(screen.getAllByRole("link")[0]).toHaveTextContent("component1");
|
|
47
|
-
expect(screen.getAllByRole("link")[1]).toHaveTextContent("component2");
|
|
53
|
+
expect(screen.getByText(/string3/)).toBeInTheDocument();
|
|
48
54
|
});
|
|
49
55
|
|
|
50
56
|
it("Renders icon", () => {
|
|
51
57
|
const { container } = render(
|
|
52
|
-
<Breadcrumbs
|
|
58
|
+
<Breadcrumbs breadcrumbsData={breadcrumbsData} />
|
|
53
59
|
);
|
|
54
|
-
expect(container.querySelector(".
|
|
60
|
+
expect(container.querySelector(".breadcrumbs-icon")).toBeInTheDocument();
|
|
55
61
|
});
|
|
56
62
|
|
|
57
63
|
it("Throws error when nothing is passed into Breadcrumb", () => {
|
|
58
|
-
expect(() => render(<Breadcrumbs
|
|
59
|
-
"
|
|
64
|
+
expect(() => render(<Breadcrumbs breadcrumbsData={[]} />)).toThrowError(
|
|
65
|
+
"You must use the `breadcrumbsData` prop to pass a data object to the Breadcrumbs component. That prop is current empty."
|
|
60
66
|
);
|
|
61
67
|
});
|
|
62
68
|
});
|
|
@@ -1,92 +1,90 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import {
|
|
3
|
+
Breadcrumb as ChakraBreadcrumb,
|
|
4
|
+
BreadcrumbItem,
|
|
5
|
+
BreadcrumbLink,
|
|
6
|
+
useStyleConfig,
|
|
7
|
+
} from "@chakra-ui/react";
|
|
5
8
|
|
|
6
|
-
|
|
9
|
+
import generateUUID from "../../helpers/generateUUID";
|
|
10
|
+
import { ColorVariants } from "./BreadcrumbsTypes";
|
|
11
|
+
import Icon from "../Icons/Icon";
|
|
12
|
+
import {
|
|
13
|
+
IconNames,
|
|
14
|
+
IconRotationTypes,
|
|
15
|
+
IconSizes,
|
|
16
|
+
IconTypes,
|
|
17
|
+
} from "../Icons/IconTypes";
|
|
18
|
+
import { getVariant } from "../../utils/utils";
|
|
7
19
|
|
|
8
|
-
|
|
9
|
-
|
|
20
|
+
export interface BreadcrumbsDataProps {
|
|
21
|
+
url: string;
|
|
22
|
+
text: string | React.ReactNode;
|
|
10
23
|
}
|
|
11
24
|
|
|
12
25
|
export interface BreadcrumbProps {
|
|
13
|
-
/** BlockName for use with BEM. See how to work with blockNames and BEM here: http://getbem.com/introduction/ */
|
|
14
|
-
blockName?: string;
|
|
15
26
|
/** Breadcrumb links as an array */
|
|
16
|
-
|
|
27
|
+
breadcrumbsData: BreadcrumbsDataProps[];
|
|
17
28
|
/** className you can add in addition to 'input' */
|
|
18
29
|
className?: string;
|
|
19
|
-
/**
|
|
20
|
-
|
|
30
|
+
/** ID that other components can cross reference for accessibility purposes */
|
|
31
|
+
id?: string;
|
|
32
|
+
/** Used to control how the `Hero` component will be rendered. */
|
|
33
|
+
colorVariant?: ColorVariants;
|
|
21
34
|
}
|
|
22
35
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
constructor(props: BreadcrumbProps) {
|
|
27
|
-
super(props);
|
|
36
|
+
const getElementsFromData = (data, breadcrumbsID) => {
|
|
37
|
+
if (!data?.length) {
|
|
38
|
+
return {};
|
|
28
39
|
}
|
|
29
40
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
const breadcrumbItems = data.map((breadcrumbData, index) => (
|
|
42
|
+
<BreadcrumbItem
|
|
43
|
+
key={index}
|
|
44
|
+
isCurrentPage={index === data.length - 1 ? true : false}
|
|
45
|
+
>
|
|
46
|
+
<BreadcrumbLink href={breadcrumbData.url}>
|
|
47
|
+
{index === data.length - 2 && (
|
|
48
|
+
<Icon
|
|
49
|
+
name={IconNames.Arrow}
|
|
50
|
+
size={IconSizes.Small}
|
|
51
|
+
iconRotation={IconRotationTypes.Rotate90}
|
|
52
|
+
id={`${breadcrumbsID}__backarrow`}
|
|
53
|
+
className="breadcrumbs-icon"
|
|
54
|
+
type={IconTypes.Breadcrumbs}
|
|
55
|
+
/>
|
|
56
|
+
)}
|
|
57
|
+
<span className="breadcrumb-label">{breadcrumbData.text}</span>
|
|
58
|
+
</BreadcrumbLink>
|
|
59
|
+
</BreadcrumbItem>
|
|
60
|
+
));
|
|
34
61
|
|
|
35
|
-
|
|
62
|
+
return breadcrumbItems;
|
|
63
|
+
};
|
|
36
64
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
65
|
+
function Breadcrumbs(props: React.PropsWithChildren<BreadcrumbProps>) {
|
|
66
|
+
const {
|
|
67
|
+
breadcrumbsData,
|
|
68
|
+
className,
|
|
69
|
+
colorVariant,
|
|
70
|
+
id = generateUUID(),
|
|
71
|
+
} = props;
|
|
72
|
+
const variant = getVariant(colorVariant, ColorVariants);
|
|
45
73
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
{item.text}
|
|
50
|
-
</a>
|
|
51
|
-
) : (
|
|
52
|
-
item.text
|
|
53
|
-
);
|
|
54
|
-
} else {
|
|
55
|
-
const props = {
|
|
56
|
-
className: bem("link", [], baseClass),
|
|
57
|
-
};
|
|
58
|
-
linkComponent = React.createElement(
|
|
59
|
-
item.type,
|
|
60
|
-
{ ...props, ...item.props },
|
|
61
|
-
item.props.children
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
breadcrumbItems.push(
|
|
65
|
-
<li
|
|
66
|
-
key={`${baseClass}-${index}`}
|
|
67
|
-
className={bem("item", [], baseClass)}
|
|
68
|
-
>
|
|
69
|
-
{last && (
|
|
70
|
-
<Icon
|
|
71
|
-
name={IconNames.arrow}
|
|
72
|
-
blockName={baseClass}
|
|
73
|
-
modifiers={["small"]}
|
|
74
|
-
decorative={true}
|
|
75
|
-
/>
|
|
76
|
-
)}
|
|
77
|
-
{linkComponent}
|
|
78
|
-
</li>
|
|
79
|
-
);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<nav
|
|
84
|
-
className={bem(baseClass, modifiers, blockName, [className])}
|
|
85
|
-
role="navigation"
|
|
86
|
-
aria-label="Breadcrumbs"
|
|
87
|
-
>
|
|
88
|
-
<ul className={bem("list", [], baseClass)}>{breadcrumbItems}</ul>
|
|
89
|
-
</nav>
|
|
74
|
+
if (!breadcrumbsData || breadcrumbsData.length === 0) {
|
|
75
|
+
throw new Error(
|
|
76
|
+
"You must use the `breadcrumbsData` prop to pass a data object to the Breadcrumbs component. That prop is current empty."
|
|
90
77
|
);
|
|
91
78
|
}
|
|
79
|
+
|
|
80
|
+
const styles = useStyleConfig("Breadcrumb", { variant });
|
|
81
|
+
const breadcrumbItems = getElementsFromData(breadcrumbsData, id);
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<ChakraBreadcrumb className={className} __css={styles} id={id}>
|
|
85
|
+
{breadcrumbItems}
|
|
86
|
+
</ChakraBreadcrumb>
|
|
87
|
+
);
|
|
92
88
|
}
|
|
89
|
+
|
|
90
|
+
export default Breadcrumbs;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Breadcrumbs Snapshot Renders the UI snapshot correctly 1`] = `
|
|
4
|
+
<nav
|
|
5
|
+
aria-label="breadcrumb"
|
|
6
|
+
className="chakra-breadcrumb css-0"
|
|
7
|
+
id="breadcrumbs-test"
|
|
8
|
+
>
|
|
9
|
+
<ol
|
|
10
|
+
className="chakra-breadcrumb__list css-0"
|
|
11
|
+
>
|
|
12
|
+
<li
|
|
13
|
+
className="chakra-breadcrumb__list-item css-18biwo"
|
|
14
|
+
>
|
|
15
|
+
<a
|
|
16
|
+
className="chakra-breadcrumb__link css-0"
|
|
17
|
+
href="#string1"
|
|
18
|
+
>
|
|
19
|
+
<span
|
|
20
|
+
className="breadcrumb-label"
|
|
21
|
+
>
|
|
22
|
+
string1
|
|
23
|
+
</span>
|
|
24
|
+
</a>
|
|
25
|
+
<span
|
|
26
|
+
className="css-t4q1nq"
|
|
27
|
+
role="presentation"
|
|
28
|
+
>
|
|
29
|
+
/
|
|
30
|
+
</span>
|
|
31
|
+
</li>
|
|
32
|
+
<li
|
|
33
|
+
className="chakra-breadcrumb__list-item css-18biwo"
|
|
34
|
+
>
|
|
35
|
+
<a
|
|
36
|
+
className="chakra-breadcrumb__link css-0"
|
|
37
|
+
href="#string2"
|
|
38
|
+
>
|
|
39
|
+
<svg
|
|
40
|
+
aria-hidden={true}
|
|
41
|
+
className="chakra-icon breadcrumbs-icon css-onkibi"
|
|
42
|
+
focusable={false}
|
|
43
|
+
id="breadcrumbs-test__backarrow"
|
|
44
|
+
role="img"
|
|
45
|
+
viewBox="0 0 24 24"
|
|
46
|
+
>
|
|
47
|
+
<g
|
|
48
|
+
stroke="currentColor"
|
|
49
|
+
strokeWidth="1.5"
|
|
50
|
+
>
|
|
51
|
+
<path
|
|
52
|
+
d="M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"
|
|
53
|
+
fill="none"
|
|
54
|
+
strokeLinecap="round"
|
|
55
|
+
/>
|
|
56
|
+
<path
|
|
57
|
+
d="M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"
|
|
58
|
+
fill="currentColor"
|
|
59
|
+
strokeLinecap="round"
|
|
60
|
+
/>
|
|
61
|
+
<circle
|
|
62
|
+
cx="12"
|
|
63
|
+
cy="12"
|
|
64
|
+
fill="none"
|
|
65
|
+
r="11.25"
|
|
66
|
+
strokeMiterlimit="10"
|
|
67
|
+
/>
|
|
68
|
+
</g>
|
|
69
|
+
</svg>
|
|
70
|
+
<span
|
|
71
|
+
className="breadcrumb-label"
|
|
72
|
+
>
|
|
73
|
+
string2
|
|
74
|
+
</span>
|
|
75
|
+
</a>
|
|
76
|
+
<span
|
|
77
|
+
className="css-t4q1nq"
|
|
78
|
+
role="presentation"
|
|
79
|
+
>
|
|
80
|
+
/
|
|
81
|
+
</span>
|
|
82
|
+
</li>
|
|
83
|
+
<li
|
|
84
|
+
className="chakra-breadcrumb__list-item css-18biwo"
|
|
85
|
+
>
|
|
86
|
+
<span
|
|
87
|
+
aria-current="page"
|
|
88
|
+
className="chakra-breadcrumb__link css-0"
|
|
89
|
+
href="#string3"
|
|
90
|
+
>
|
|
91
|
+
<span
|
|
92
|
+
className="breadcrumb-label"
|
|
93
|
+
>
|
|
94
|
+
string3
|
|
95
|
+
</span>
|
|
96
|
+
</span>
|
|
97
|
+
</li>
|
|
98
|
+
</ol>
|
|
99
|
+
</nav>
|
|
100
|
+
`;
|