@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
|
@@ -4,7 +4,6 @@ import { axe } from "jest-axe";
|
|
|
4
4
|
import renderer from "react-test-renderer";
|
|
5
5
|
|
|
6
6
|
import Image from "./Image";
|
|
7
|
-
import { ImageRatios, ImageSizes, ImageTypes } from "./ImageTypes";
|
|
8
7
|
|
|
9
8
|
describe("Image Accessibility", () => {
|
|
10
9
|
it("passes axe accessibility for regular img element", async () => {
|
|
@@ -76,66 +75,52 @@ describe("Image", () => {
|
|
|
76
75
|
.create(<Image src="test.png" alt="" caption="Caption" credit="Credit" />)
|
|
77
76
|
.toJSON();
|
|
78
77
|
const sizeExtraExtraSmall = renderer
|
|
79
|
-
.create(<Image src="test.png" alt="" size=
|
|
78
|
+
.create(<Image src="test.png" alt="" size="xxsmall" />)
|
|
80
79
|
.toJSON();
|
|
81
80
|
const sizeExtraSmall = renderer
|
|
82
|
-
.create(<Image src="test.png" alt="" size=
|
|
81
|
+
.create(<Image src="test.png" alt="" size="xsmall" />)
|
|
83
82
|
.toJSON();
|
|
84
83
|
const sizeSmall = renderer
|
|
85
|
-
.create(<Image src="test.png" alt="" size=
|
|
84
|
+
.create(<Image src="test.png" alt="" size="small" />)
|
|
86
85
|
.toJSON();
|
|
87
86
|
const sizeMedium = renderer
|
|
88
|
-
.create(<Image src="test.png" alt="" size=
|
|
87
|
+
.create(<Image src="test.png" alt="" size="medium" />)
|
|
89
88
|
.toJSON();
|
|
90
89
|
const sizeLarge = renderer
|
|
91
|
-
.create(<Image src="test.png" alt="" size=
|
|
90
|
+
.create(<Image src="test.png" alt="" size="large" />)
|
|
92
91
|
.toJSON();
|
|
93
92
|
const ratioFourByThree = renderer
|
|
94
|
-
.create(
|
|
95
|
-
<Image src="test.png" alt="" aspectRatio={ImageRatios.FourByThree} />
|
|
96
|
-
)
|
|
93
|
+
.create(<Image src="test.png" alt="" aspectRatio="fourByThree" />)
|
|
97
94
|
.toJSON();
|
|
98
95
|
const ratioOneByTwo = renderer
|
|
99
|
-
.create(
|
|
100
|
-
<Image src="test.png" alt="" aspectRatio={ImageRatios.OneByTwo} />
|
|
101
|
-
)
|
|
96
|
+
.create(<Image src="test.png" alt="" aspectRatio="oneByTwo" />)
|
|
102
97
|
.toJSON();
|
|
103
98
|
const ratioOriginal = renderer
|
|
104
|
-
.create(
|
|
105
|
-
<Image src="test.png" alt="" aspectRatio={ImageRatios.Original} />
|
|
106
|
-
)
|
|
99
|
+
.create(<Image src="test.png" alt="" aspectRatio="original" />)
|
|
107
100
|
.toJSON();
|
|
108
101
|
const ratioSixteenByNine = renderer
|
|
109
|
-
.create(
|
|
110
|
-
<Image src="test.png" alt="" aspectRatio={ImageRatios.SixteenByNine} />
|
|
111
|
-
)
|
|
102
|
+
.create(<Image src="test.png" alt="" aspectRatio="sixteenByNine" />)
|
|
112
103
|
.toJSON();
|
|
113
104
|
const ratioSquare = renderer
|
|
114
|
-
.create(<Image src="test.png" alt="" aspectRatio=
|
|
105
|
+
.create(<Image src="test.png" alt="" aspectRatio="square" />)
|
|
115
106
|
.toJSON();
|
|
116
107
|
const ratioThreeByFour = renderer
|
|
117
|
-
.create(
|
|
118
|
-
<Image src="test.png" alt="" aspectRatio={ImageRatios.ThreeByFour} />
|
|
119
|
-
)
|
|
108
|
+
.create(<Image src="test.png" alt="" aspectRatio="threeByFour" />)
|
|
120
109
|
.toJSON();
|
|
121
110
|
const ratioThreeByTwo = renderer
|
|
122
|
-
.create(
|
|
123
|
-
<Image src="test.png" alt="" aspectRatio={ImageRatios.ThreeByTwo} />
|
|
124
|
-
)
|
|
111
|
+
.create(<Image src="test.png" alt="" aspectRatio="threeByTwo" />)
|
|
125
112
|
.toJSON();
|
|
126
113
|
const ratioTwoByOne = renderer
|
|
127
|
-
.create(
|
|
128
|
-
<Image src="test.png" alt="" aspectRatio={ImageRatios.TwoByOne} />
|
|
129
|
-
)
|
|
114
|
+
.create(<Image src="test.png" alt="" aspectRatio="twoByOne" />)
|
|
130
115
|
.toJSON();
|
|
131
116
|
const typeCircle = renderer
|
|
132
117
|
.create(
|
|
133
118
|
<Image
|
|
134
119
|
src="test.png"
|
|
135
120
|
alt=""
|
|
136
|
-
aspectRatio=
|
|
137
|
-
size=
|
|
138
|
-
imageType=
|
|
121
|
+
aspectRatio="square"
|
|
122
|
+
size="small"
|
|
123
|
+
imageType="circle"
|
|
139
124
|
/>
|
|
140
125
|
)
|
|
141
126
|
.toJSON();
|
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import { Box, chakra, useMultiStyleConfig } from "@chakra-ui/react";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export type ImageRatios =
|
|
5
|
+
| "fourByThree"
|
|
6
|
+
| "oneByTwo"
|
|
7
|
+
| "original"
|
|
8
|
+
| "sixteenByNine"
|
|
9
|
+
| "square"
|
|
10
|
+
| "threeByFour"
|
|
11
|
+
| "threeByTwo"
|
|
12
|
+
| "twoByOne";
|
|
13
|
+
export type ImageSizes =
|
|
14
|
+
| "default"
|
|
15
|
+
| "xxsmall"
|
|
16
|
+
| "xsmall"
|
|
17
|
+
| "small"
|
|
18
|
+
| "medium"
|
|
19
|
+
| "large";
|
|
20
|
+
export type ImageTypes = "default" | "circle";
|
|
6
21
|
// Used for components that have an `imageProps` prop.
|
|
7
22
|
export interface ComponentImageProps {
|
|
8
23
|
/** String value used to populate the `alt` attribute of the internal `Image`
|
|
@@ -18,7 +33,7 @@ export interface ComponentImageProps {
|
|
|
18
33
|
/** Optional value to render as a credit for the internal `Image` component. */
|
|
19
34
|
credit?: string;
|
|
20
35
|
/** Optional value to control the size of the internal `Image` component.
|
|
21
|
-
* Defaults to `ImageSizes.
|
|
36
|
+
* Defaults to `ImageSizes.Default`. */
|
|
22
37
|
size?: ImageSizes;
|
|
23
38
|
/** Optional value that contains the path to an image. If omitted, the internal
|
|
24
39
|
* DS `Image` component will not render. */
|
|
@@ -30,7 +45,8 @@ interface ImageWrapperProps {
|
|
|
30
45
|
additionalWrapperStyles?: { [key: string]: any };
|
|
31
46
|
/** ClassName you can add in addition to 'image' */
|
|
32
47
|
className?: string;
|
|
33
|
-
/** Optional value to control the aspect ratio of the
|
|
48
|
+
/** Optional value to control the aspect ratio of the card image; default
|
|
49
|
+
* value is `"original"` */
|
|
34
50
|
aspectRatio?: ImageRatios;
|
|
35
51
|
/** Optional value to control the size of the image */
|
|
36
52
|
size?: ImageSizes;
|
|
@@ -42,7 +58,7 @@ export interface ImageProps extends ImageWrapperProps {
|
|
|
42
58
|
/** Optionally pass in additional Chakra-based styles only for the image. */
|
|
43
59
|
additionalImageStyles?: { [key: string]: any };
|
|
44
60
|
/** Alternate text description of the image */
|
|
45
|
-
alt
|
|
61
|
+
alt?: string;
|
|
46
62
|
/** Adding will wrap the image in a <figure> */
|
|
47
63
|
caption?: string;
|
|
48
64
|
/** Custom image component */
|
|
@@ -52,7 +68,7 @@ export interface ImageProps extends ImageWrapperProps {
|
|
|
52
68
|
/** Optional value for the image type */
|
|
53
69
|
imageType?: ImageTypes;
|
|
54
70
|
/** The src attribute is required, and contains the path to the image you want to embed. */
|
|
55
|
-
src
|
|
71
|
+
src?: string;
|
|
56
72
|
}
|
|
57
73
|
|
|
58
74
|
const ImageWrapper = chakra(
|
|
@@ -61,8 +77,8 @@ const ImageWrapper = chakra(
|
|
|
61
77
|
additionalWrapperStyles = {},
|
|
62
78
|
className = "",
|
|
63
79
|
children,
|
|
64
|
-
aspectRatio =
|
|
65
|
-
size =
|
|
80
|
+
aspectRatio = "original",
|
|
81
|
+
size = "default",
|
|
66
82
|
...rest
|
|
67
83
|
} = props;
|
|
68
84
|
const styles = useMultiStyleConfig("CustomImageWrapper", {
|
|
@@ -89,17 +105,17 @@ export const Image = chakra((props: ImageProps) => {
|
|
|
89
105
|
additionalImageStyles = {},
|
|
90
106
|
additionalWrapperStyles = {},
|
|
91
107
|
alt,
|
|
92
|
-
aspectRatio =
|
|
108
|
+
aspectRatio = "original",
|
|
93
109
|
caption,
|
|
94
110
|
className = "",
|
|
95
111
|
component,
|
|
96
112
|
credit,
|
|
97
|
-
imageType =
|
|
98
|
-
size =
|
|
113
|
+
imageType = "default",
|
|
114
|
+
size = "default",
|
|
99
115
|
src,
|
|
100
116
|
...rest
|
|
101
117
|
} = props;
|
|
102
|
-
const useImageWrapper = aspectRatio !==
|
|
118
|
+
const useImageWrapper = aspectRatio !== "original";
|
|
103
119
|
const styles = useMultiStyleConfig("CustomImage", {
|
|
104
120
|
variant: imageType,
|
|
105
121
|
size,
|
|
@@ -6,21 +6,12 @@ import {
|
|
|
6
6
|
Meta,
|
|
7
7
|
Story,
|
|
8
8
|
} from "@storybook/addon-docs";
|
|
9
|
-
import {
|
|
10
|
-
BrowserRouter as Router,
|
|
11
|
-
Link as ReactRouterLink,
|
|
12
|
-
} from "react-router-dom";
|
|
13
9
|
import { withDesign } from "storybook-addon-designs";
|
|
14
10
|
|
|
15
11
|
import Link from "./Link";
|
|
16
|
-
import { LinkTypes } from "./LinkTypes";
|
|
17
12
|
import Icon from "../Icons/Icon";
|
|
18
|
-
import { IconAlign, IconNames, IconSizes } from "../Icons/IconTypes";
|
|
19
13
|
import { getCategory } from "../../utils/componentCategories";
|
|
20
14
|
import DSProvider from "../../theme/provider";
|
|
21
|
-
import { getStorybookEnumValues } from "../../utils/utils";
|
|
22
|
-
|
|
23
|
-
export const enumValues = getStorybookEnumValues(LinkTypes, "LinkTypes");
|
|
24
15
|
|
|
25
16
|
<Meta
|
|
26
17
|
title={getCategory("Link")}
|
|
@@ -34,15 +25,11 @@ export const enumValues = getStorybookEnumValues(LinkTypes, "LinkTypes");
|
|
|
34
25
|
jest: ["Link.test.tsx"],
|
|
35
26
|
}}
|
|
36
27
|
argTypes={{
|
|
37
|
-
additionalStyles: { control: false },
|
|
38
|
-
attributes: { control: false },
|
|
39
28
|
children: { table: { disable: true } },
|
|
40
29
|
key: { table: { disable: true } },
|
|
41
30
|
ref: { table: { disable: true } },
|
|
42
31
|
type: {
|
|
43
|
-
|
|
44
|
-
table: { defaultValue: { summary: "LinkTypes.Default" } },
|
|
45
|
-
options: enumValues.options,
|
|
32
|
+
table: { defaultValue: { summary: "default" } },
|
|
46
33
|
},
|
|
47
34
|
}}
|
|
48
35
|
/>
|
|
@@ -52,7 +39,7 @@ export const enumValues = getStorybookEnumValues(LinkTypes, "LinkTypes");
|
|
|
52
39
|
| Component Version | DS Version |
|
|
53
40
|
| ----------------- | ---------- |
|
|
54
41
|
| Added | `0.0.4` |
|
|
55
|
-
| Latest | `0.
|
|
42
|
+
| Latest | `0.28.0` |
|
|
56
43
|
|
|
57
44
|
## Table of Contents
|
|
58
45
|
|
|
@@ -73,22 +60,13 @@ export const enumValues = getStorybookEnumValues(LinkTypes, "LinkTypes");
|
|
|
73
60
|
<Story
|
|
74
61
|
name="Link with Controls"
|
|
75
62
|
args={{
|
|
76
|
-
additionalStyles: undefined,
|
|
77
|
-
attributes: {
|
|
78
|
-
rel: "nofollow",
|
|
79
|
-
onClick: (e) => e.preventDefault(),
|
|
80
|
-
},
|
|
81
63
|
className: "custom-class",
|
|
82
64
|
href: "https://nypl.org",
|
|
83
65
|
id: "nypl-link",
|
|
84
|
-
type: "
|
|
66
|
+
type: "action",
|
|
85
67
|
}}
|
|
86
68
|
>
|
|
87
|
-
{(args) =>
|
|
88
|
-
<Link {...args} type={enumValues.getValue(args.type)}>
|
|
89
|
-
Link
|
|
90
|
-
</Link>
|
|
91
|
-
)}
|
|
69
|
+
{(args) => <Link {...args}>Link</Link>}
|
|
92
70
|
</Story>
|
|
93
71
|
</Canvas>
|
|
94
72
|
|
|
@@ -108,35 +86,27 @@ Resources:
|
|
|
108
86
|
## Links With Icons
|
|
109
87
|
|
|
110
88
|
To render an `Icon` as part of the link, make sure that the `Link` component
|
|
111
|
-
wraps the `Icon`. Use `type=
|
|
89
|
+
wraps the `Icon`. Use `type="action"` to apply appropriate styling to
|
|
112
90
|
links with icons. Icons can be rendered to the left or right of the link text.
|
|
113
91
|
|
|
114
92
|
<Canvas>
|
|
115
93
|
<Story name="With Icons">
|
|
116
94
|
<VStack spacing="xs" align="flex-start">
|
|
117
|
-
<Link type=
|
|
118
|
-
<Icon name="headset" align=
|
|
95
|
+
<Link type="action" href="#passed-in-link">
|
|
96
|
+
<Icon name="headset" align="left" size="small" />
|
|
119
97
|
Headset Link
|
|
120
98
|
</Link>
|
|
121
|
-
<Link type=
|
|
122
|
-
<Icon name="clock" align=
|
|
99
|
+
<Link type="action" href="#passed-in-link">
|
|
100
|
+
<Icon name="clock" align="left" size="small" />
|
|
123
101
|
Clock Link
|
|
124
102
|
</Link>
|
|
125
|
-
<Link type=
|
|
126
|
-
<Icon
|
|
127
|
-
name={IconNames.Check}
|
|
128
|
-
align={IconAlign.Left}
|
|
129
|
-
size={IconSizes.Small}
|
|
130
|
-
/>
|
|
103
|
+
<Link type="action" href="#passed-in-link">
|
|
104
|
+
<Icon name="check" align="left" size="small" />
|
|
131
105
|
Check Link
|
|
132
106
|
</Link>
|
|
133
|
-
<Link type=
|
|
107
|
+
<Link type="action" href="#passed-in-link-right">
|
|
134
108
|
Check Link Right
|
|
135
|
-
<Icon
|
|
136
|
-
name={IconNames.Check}
|
|
137
|
-
align={IconAlign.Right}
|
|
138
|
-
size={IconSizes.Small}
|
|
139
|
-
/>
|
|
109
|
+
<Icon name="check" align="right" size="small" />
|
|
140
110
|
</Link>
|
|
141
111
|
</VStack>
|
|
142
112
|
</Story>
|
|
@@ -149,21 +119,21 @@ can use the `href` prop to generate an `<a>` element.
|
|
|
149
119
|
|
|
150
120
|
```jsx
|
|
151
121
|
// Existing anchor element
|
|
152
|
-
<Link type=
|
|
122
|
+
<Link type="action">
|
|
153
123
|
<a href="#existing-anchor-tag">link</a>
|
|
154
124
|
</Link>
|
|
155
125
|
|
|
156
126
|
// Also works with an icon component. Make sure to wrap the icon and anchor
|
|
157
127
|
// in a single element for this pattern.
|
|
158
|
-
<Link type=
|
|
128
|
+
<Link type="action">
|
|
159
129
|
<>
|
|
160
|
-
<Icon name=
|
|
130
|
+
<Icon name="check" align="left" size="small" />
|
|
161
131
|
<a href="#existing-anchor-tag">check link</a>
|
|
162
132
|
</>
|
|
163
133
|
</Link>
|
|
164
134
|
|
|
165
135
|
// Otherwise, the `href` prop will generate an `<a>` tag.
|
|
166
|
-
<Link type=
|
|
136
|
+
<Link type="action" href="#passed-in-link">
|
|
167
137
|
link
|
|
168
138
|
</Link>
|
|
169
139
|
```
|
|
@@ -172,22 +142,18 @@ can use the `href` prop to generate an `<a>` element.
|
|
|
172
142
|
<Story name="Anchor Element Rendering">
|
|
173
143
|
<>
|
|
174
144
|
This is a{" "}
|
|
175
|
-
<Link type=
|
|
145
|
+
<Link type="action">
|
|
176
146
|
<a href="#existing-anchor-tag">link</a>
|
|
177
147
|
</Link>{" "}
|
|
178
148
|
with the <a> element as a child of the `Link` component. This is a{" "}
|
|
179
|
-
<Link type=
|
|
149
|
+
<Link type="action" href="#passed-in-link">
|
|
180
150
|
link
|
|
181
151
|
</Link>{" "}
|
|
182
152
|
where the `Link` component uses the `href` prop and has a string-only
|
|
183
153
|
child. Finally, this is a{" "}
|
|
184
|
-
<Link type=
|
|
154
|
+
<Link type="action">
|
|
185
155
|
<>
|
|
186
|
-
<Icon
|
|
187
|
-
name={IconNames.Check}
|
|
188
|
-
align={IconAlign.Left}
|
|
189
|
-
size={IconSizes.Small}
|
|
190
|
-
/>
|
|
156
|
+
<Icon name="check" align="left" size="small" />
|
|
191
157
|
<a href="#existing-anchor-tag">link</a>
|
|
192
158
|
</>
|
|
193
159
|
</Link>{" "}
|
|
@@ -198,23 +164,6 @@ can use the `href` prop to generate an `<a>` element.
|
|
|
198
164
|
|
|
199
165
|
## Link with Routers
|
|
200
166
|
|
|
201
|
-
<Canvas>
|
|
202
|
-
<Story name="Link with Routers">
|
|
203
|
-
<div>With React Router</div>
|
|
204
|
-
<Router>
|
|
205
|
-
<Link type={LinkTypes.Action}>
|
|
206
|
-
<ReactRouterLink to="#">Next Page</ReactRouterLink>
|
|
207
|
-
</Link>
|
|
208
|
-
</Router>
|
|
209
|
-
<br />
|
|
210
|
-
<br />
|
|
211
|
-
<div>With NextJS</div>
|
|
212
|
-
<NextJsLink href="#" passHref>
|
|
213
|
-
<Link type={LinkTypes.Action}>Next Page</Link>
|
|
214
|
-
</NextJsLink>
|
|
215
|
-
</Story>
|
|
216
|
-
</Canvas>
|
|
217
|
-
|
|
218
167
|
### React Router
|
|
219
168
|
|
|
220
169
|
The Design System's `Link` component should wrap around `react-router`'s own
|
|
@@ -228,9 +177,9 @@ import {
|
|
|
228
177
|
BrowserRouter as Router,
|
|
229
178
|
Link as ReactRouterLink,
|
|
230
179
|
} from "react-router-dom";
|
|
231
|
-
import { Link
|
|
180
|
+
import { Link } from "@nypl/design-system-react-components";
|
|
232
181
|
|
|
233
|
-
<Link type=
|
|
182
|
+
<Link type="action">
|
|
234
183
|
<ReactRouterLink to="#">Next Page</ReactRouterLink>
|
|
235
184
|
</Link>;
|
|
236
185
|
|
|
@@ -238,12 +187,9 @@ import { Link, LinkTypes } from "@nypl/design-system-react-components";
|
|
|
238
187
|
// is not renamed but the DS's `Link` component is renamed
|
|
239
188
|
// to `DSLink`.
|
|
240
189
|
import { BrowserRouter, Link } from "react-router-dom";
|
|
241
|
-
import {
|
|
242
|
-
Link as DSLink,
|
|
243
|
-
LinkTypes,
|
|
244
|
-
} from "@nypl/design-system-react-components";
|
|
190
|
+
import { Link as DSLink } from "@nypl/design-system-react-components";
|
|
245
191
|
|
|
246
|
-
<DSLink type=
|
|
192
|
+
<DSLink type="action">
|
|
247
193
|
<Link to="#">Next Page</Link>
|
|
248
194
|
</DSLink>;
|
|
249
195
|
|
|
@@ -253,21 +199,11 @@ import {
|
|
|
253
199
|
import { BrowserRouter, Link } from "react-router-dom";
|
|
254
200
|
import DS from "@nypl/design-system-react-components";
|
|
255
201
|
|
|
256
|
-
<DS.Link type=
|
|
202
|
+
<DS.Link type="action">
|
|
257
203
|
<Link to="#">Next Page</Link>
|
|
258
204
|
</DS.Link>;
|
|
259
205
|
```
|
|
260
206
|
|
|
261
|
-
<Canvas>
|
|
262
|
-
<DSProvider>
|
|
263
|
-
<Router>
|
|
264
|
-
<Link type={LinkTypes.Action}>
|
|
265
|
-
<ReactRouterLink to="#">Next Page</ReactRouterLink>
|
|
266
|
-
</Link>
|
|
267
|
-
</Router>
|
|
268
|
-
</DSProvider>
|
|
269
|
-
</Canvas>
|
|
270
|
-
|
|
271
207
|
### NextJS
|
|
272
208
|
|
|
273
209
|
NextJS's `Link` component should wrap the Design System's `Link` component.
|
|
@@ -277,7 +213,7 @@ These props, along with an implicit `ref` from NextJS and the Design System's
|
|
|
277
213
|
pages in a NextJS app.
|
|
278
214
|
|
|
279
215
|
```jsx
|
|
280
|
-
import { Link
|
|
216
|
+
import { Link } from "@nypl/design-system-react-components";
|
|
281
217
|
|
|
282
218
|
/**
|
|
283
219
|
* This is just an example wrapper that works similarly to NextJS' `Link`
|
|
@@ -293,21 +229,21 @@ export const NextJsLink = (props: HTMLAnchorElement) =>
|
|
|
293
229
|
|
|
294
230
|
// Note that NextJS' `href` and `passHref` props are required.
|
|
295
231
|
<NextJsLink href="#" passHref>
|
|
296
|
-
<Link type=
|
|
232
|
+
<Link type="action">Next Page</Link>
|
|
297
233
|
</NextJsLink>;
|
|
298
234
|
```
|
|
299
235
|
|
|
300
236
|
export const NextJsLink = (props) =>
|
|
301
237
|
React.cloneElement(
|
|
302
238
|
props.children,
|
|
303
|
-
{
|
|
239
|
+
{ href: props.href },
|
|
304
240
|
props.children.props.children
|
|
305
241
|
);
|
|
306
242
|
|
|
307
243
|
<Canvas>
|
|
308
244
|
<DSProvider>
|
|
309
245
|
<NextJsLink href="#" passHref>
|
|
310
|
-
<Link type=
|
|
246
|
+
<Link type="action">Next Page</Link>
|
|
311
247
|
</NextJsLink>
|
|
312
248
|
</DSProvider>
|
|
313
249
|
</Canvas>
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
import { render, screen } from "@testing-library/react";
|
|
2
2
|
import { axe } from "jest-axe";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import {
|
|
5
|
-
BrowserRouter as Router,
|
|
6
|
-
Link as ReactRouterLink,
|
|
7
|
-
} from "react-router-dom";
|
|
8
4
|
import renderer from "react-test-renderer";
|
|
9
5
|
|
|
10
6
|
import Link from "./Link";
|
|
11
|
-
import { LinkTypes } from "./LinkTypes";
|
|
12
7
|
import Icon from "../Icons/Icon";
|
|
13
|
-
import {
|
|
14
|
-
IconAlign,
|
|
15
|
-
IconNames,
|
|
16
|
-
IconRotationTypes,
|
|
17
|
-
IconSizes,
|
|
18
|
-
} from "../Icons/IconTypes";
|
|
19
8
|
|
|
20
9
|
describe("Link Accessibility", () => {
|
|
21
10
|
it("passes axe accessibility test for children component", async () => {
|
|
@@ -36,12 +25,12 @@ describe("Link Accessibility", () => {
|
|
|
36
25
|
describe("Link", () => {
|
|
37
26
|
it("Can pass in an icon and text as children and url as prop", () => {
|
|
38
27
|
const utils = render(
|
|
39
|
-
<Link href="#passed-in-link" type=
|
|
28
|
+
<Link href="#passed-in-link" type="action">
|
|
40
29
|
<Icon
|
|
41
30
|
className="more-link"
|
|
42
|
-
name=
|
|
43
|
-
align=
|
|
44
|
-
iconRotation=
|
|
31
|
+
name="download"
|
|
32
|
+
align="left"
|
|
33
|
+
iconRotation="rotate0"
|
|
45
34
|
/>
|
|
46
35
|
Download
|
|
47
36
|
</Link>
|
|
@@ -61,13 +50,13 @@ describe("Link", () => {
|
|
|
61
50
|
|
|
62
51
|
it("Can pass a link with <a> tag and an icon", () => {
|
|
63
52
|
const utils = render(
|
|
64
|
-
<Link type=
|
|
53
|
+
<Link type="action">
|
|
65
54
|
<a href="#test2">
|
|
66
55
|
<Icon
|
|
67
56
|
className="more-link"
|
|
68
|
-
name=
|
|
69
|
-
align=
|
|
70
|
-
iconRotation=
|
|
57
|
+
name="download"
|
|
58
|
+
align="left"
|
|
59
|
+
iconRotation="rotate0"
|
|
71
60
|
/>
|
|
72
61
|
Test
|
|
73
62
|
</a>
|
|
@@ -79,25 +68,25 @@ describe("Link", () => {
|
|
|
79
68
|
|
|
80
69
|
it("Generated back link has icon", () => {
|
|
81
70
|
const utils = render(
|
|
82
|
-
<Link href="#passed-in-link" type=
|
|
71
|
+
<Link href="#passed-in-link" type="backwards">
|
|
83
72
|
content
|
|
84
73
|
</Link>
|
|
85
74
|
);
|
|
86
75
|
expect(utils.container.querySelector(".more-link")).toBeInTheDocument();
|
|
87
76
|
expect(
|
|
88
|
-
utils.container.querySelector(".more-link")
|
|
77
|
+
utils.container.querySelector(".more-link")?.getAttribute("class")
|
|
89
78
|
).toContain("chakra-icon more-link");
|
|
90
79
|
});
|
|
91
80
|
|
|
92
81
|
it("Generated forwards link has icon", () => {
|
|
93
82
|
const utils = render(
|
|
94
|
-
<Link href="#passed-in-link" type=
|
|
83
|
+
<Link href="#passed-in-link" type="forwards">
|
|
95
84
|
content
|
|
96
85
|
</Link>
|
|
97
86
|
);
|
|
98
87
|
expect(utils.container.querySelector(".more-link")).toBeInTheDocument();
|
|
99
88
|
expect(
|
|
100
|
-
utils.container.querySelector(".more-link")
|
|
89
|
+
utils.container.querySelector(".more-link")?.getAttribute("class")
|
|
101
90
|
).toContain("chakra-icon more-link");
|
|
102
91
|
});
|
|
103
92
|
|
|
@@ -106,24 +95,6 @@ describe("Link", () => {
|
|
|
106
95
|
expect(screen.getByRole("link")).toBeInTheDocument();
|
|
107
96
|
});
|
|
108
97
|
|
|
109
|
-
it("Can pass in a ReactRouter Link", () => {
|
|
110
|
-
render(
|
|
111
|
-
<Router>
|
|
112
|
-
<Link type={LinkTypes.Action}>
|
|
113
|
-
<ReactRouterLink to="#">
|
|
114
|
-
<Icon
|
|
115
|
-
name={IconNames.Download}
|
|
116
|
-
align={IconAlign.Left}
|
|
117
|
-
iconRotation={IconRotationTypes.Rotate0}
|
|
118
|
-
/>
|
|
119
|
-
Download
|
|
120
|
-
</ReactRouterLink>
|
|
121
|
-
</Link>
|
|
122
|
-
</Router>
|
|
123
|
-
);
|
|
124
|
-
expect(screen.getByRole("link")).toBeInTheDocument();
|
|
125
|
-
});
|
|
126
|
-
|
|
127
98
|
it("throws an error if text is passed but no url is passed", () => {
|
|
128
99
|
expect(() => render(<Link>Test</Link>)).toThrowError(
|
|
129
100
|
"`Link` needs the `href` prop."
|
|
@@ -134,11 +105,7 @@ describe("Link", () => {
|
|
|
134
105
|
expect(() =>
|
|
135
106
|
render(
|
|
136
107
|
<Link>
|
|
137
|
-
<Icon
|
|
138
|
-
name={IconNames.Download}
|
|
139
|
-
align={IconAlign.Left}
|
|
140
|
-
iconRotation={IconRotationTypes.Rotate0}
|
|
141
|
-
/>
|
|
108
|
+
<Icon name="download" align="left" iconRotation="rotate0" />
|
|
142
109
|
<a href="#test">Test</a>
|
|
143
110
|
</Link>
|
|
144
111
|
)
|
|
@@ -148,60 +115,48 @@ describe("Link", () => {
|
|
|
148
115
|
it("renders the UI snapshot correctly", () => {
|
|
149
116
|
const standard = renderer
|
|
150
117
|
.create(
|
|
151
|
-
<Link href="#passed-in-link" id="standard-link" type=
|
|
118
|
+
<Link href="#passed-in-link" id="standard-link" type="action">
|
|
152
119
|
Standard
|
|
153
120
|
</Link>
|
|
154
121
|
)
|
|
155
122
|
.toJSON();
|
|
156
123
|
const typeForwards = renderer
|
|
157
124
|
.create(
|
|
158
|
-
<Link
|
|
159
|
-
href="#passed-in-link"
|
|
160
|
-
id="forwards-link"
|
|
161
|
-
type={LinkTypes.Forwards}
|
|
162
|
-
>
|
|
125
|
+
<Link href="#passed-in-link" id="forwards-link" type="forwards">
|
|
163
126
|
Forwards
|
|
164
127
|
</Link>
|
|
165
128
|
)
|
|
166
129
|
.toJSON();
|
|
167
130
|
const typeBackwards = renderer
|
|
168
131
|
.create(
|
|
169
|
-
<Link
|
|
170
|
-
href="#passed-in-link"
|
|
171
|
-
id="backwards-link"
|
|
172
|
-
type={LinkTypes.Backwards}
|
|
173
|
-
>
|
|
132
|
+
<Link href="#passed-in-link" id="backwards-link" type="backwards">
|
|
174
133
|
Backwards
|
|
175
134
|
</Link>
|
|
176
135
|
)
|
|
177
136
|
.toJSON();
|
|
178
137
|
const typeExternal = renderer
|
|
179
138
|
.create(
|
|
180
|
-
<Link
|
|
181
|
-
href="#passed-in-link"
|
|
182
|
-
id="external-link"
|
|
183
|
-
type={LinkTypes.External}
|
|
184
|
-
>
|
|
139
|
+
<Link href="#passed-in-link" id="external-link" type="external">
|
|
185
140
|
External
|
|
186
141
|
</Link>
|
|
187
142
|
)
|
|
188
143
|
.toJSON();
|
|
189
144
|
const typeButton = renderer
|
|
190
145
|
.create(
|
|
191
|
-
<Link href="#passed-in-link" id="button-link" type=
|
|
146
|
+
<Link href="#passed-in-link" id="button-link" type="button">
|
|
192
147
|
Button
|
|
193
148
|
</Link>
|
|
194
149
|
)
|
|
195
150
|
.toJSON();
|
|
196
151
|
const withIconChild = renderer
|
|
197
152
|
.create(
|
|
198
|
-
<Link href="#passed-in-link" id="icon-link" type=
|
|
153
|
+
<Link href="#passed-in-link" id="icon-link" type="action">
|
|
199
154
|
<Icon
|
|
200
|
-
align=
|
|
155
|
+
align="left"
|
|
201
156
|
className="more-link"
|
|
202
|
-
iconRotation=
|
|
157
|
+
iconRotation="rotate0"
|
|
203
158
|
id="link-icon"
|
|
204
|
-
name=
|
|
159
|
+
name="download"
|
|
205
160
|
/>
|
|
206
161
|
Download
|
|
207
162
|
</Link>
|
|
@@ -209,21 +164,16 @@ describe("Link", () => {
|
|
|
209
164
|
.toJSON();
|
|
210
165
|
const withAchorChild = renderer
|
|
211
166
|
.create(
|
|
212
|
-
<Link id="anchor-link" type=
|
|
167
|
+
<Link id="anchor-link" type="action">
|
|
213
168
|
<a href="#existing-anchor-tag">check link</a>
|
|
214
169
|
</Link>
|
|
215
170
|
)
|
|
216
171
|
.toJSON();
|
|
217
172
|
const withAchorChildAndIcon = renderer
|
|
218
173
|
.create(
|
|
219
|
-
<Link id="anchor-icon-link" type=
|
|
174
|
+
<Link id="anchor-icon-link" type="action">
|
|
220
175
|
<>
|
|
221
|
-
<Icon
|
|
222
|
-
align={IconAlign.Left}
|
|
223
|
-
id="link-icon"
|
|
224
|
-
name={IconNames.Check}
|
|
225
|
-
size={IconSizes.Small}
|
|
226
|
-
/>
|
|
176
|
+
<Icon align="left" id="link-icon" name="check" size="small" />
|
|
227
177
|
<a href="#existing-anchor-tag">check link</a>
|
|
228
178
|
</>
|
|
229
179
|
</Link>
|