@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
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
import { Box, chakra, useMultiStyleConfig } from "@chakra-ui/react";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import Image from "../Image/Image";
|
|
4
|
+
import Image, { ComponentImageProps } from "../Image/Image";
|
|
6
5
|
|
|
6
|
+
export type HeroTypes =
|
|
7
|
+
| "primary"
|
|
8
|
+
| "secondary"
|
|
9
|
+
| "secondaryBooksAndMore"
|
|
10
|
+
| "secondaryLocations"
|
|
11
|
+
| "secondaryResearch"
|
|
12
|
+
| "secondaryWhatsOn"
|
|
13
|
+
| "tertiary"
|
|
14
|
+
| "campaign"
|
|
15
|
+
| "fiftyFifty";
|
|
16
|
+
// Only used for internal purposes.
|
|
17
|
+
export const heroSecondaryTypes = [
|
|
18
|
+
"secondary",
|
|
19
|
+
"secondaryBooksAndMore",
|
|
20
|
+
"secondaryLocations",
|
|
21
|
+
"secondaryResearch",
|
|
22
|
+
"secondaryWhatsOn",
|
|
23
|
+
];
|
|
24
|
+
export interface HeroImageProps
|
|
25
|
+
extends Pick<ComponentImageProps, "alt" | "src"> {}
|
|
7
26
|
export interface HeroProps {
|
|
8
27
|
/** Optional hex color value used to override the default background
|
|
9
28
|
* color for a given `Hero` variation.
|
|
@@ -21,14 +40,14 @@ export interface HeroProps {
|
|
|
21
40
|
heading?: JSX.Element;
|
|
22
41
|
/** Used to control how the `Hero` component will be rendered. */
|
|
23
42
|
heroType?: HeroTypes;
|
|
24
|
-
/**
|
|
25
|
-
*
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
* `Hero` types; Note: `
|
|
29
|
-
* `backgroundImageSrc` for the
|
|
30
|
-
* Note: not all `Hero` variations utilize this prop. */
|
|
31
|
-
|
|
43
|
+
/** Object used to create and render the `Image` component. Note that only
|
|
44
|
+
* `src` and `alt` are the available attributes to pass. If `imageProps.alt`
|
|
45
|
+
* is left blank, a warning will be logged to the console and will cause
|
|
46
|
+
* accessibility issues. For `imageProps.src`, it will only work for the
|
|
47
|
+
* "secondary", "fiftyFifty" and "campaign" `Hero` types; Note: `imageProps.src`
|
|
48
|
+
* can only be used in conjunction with `backgroundImageSrc` for the "campaign"
|
|
49
|
+
* `Hero` type. Note: not all `Hero` variations utilize this prop. */
|
|
50
|
+
imageProps?: HeroImageProps;
|
|
32
51
|
/** Optional details area that contains location data.
|
|
33
52
|
* Note: not all `Hero` variations utilize this prop. */
|
|
34
53
|
locationDetails?: JSX.Element;
|
|
@@ -37,18 +56,6 @@ export interface HeroProps {
|
|
|
37
56
|
subHeaderText?: string | JSX.Element;
|
|
38
57
|
}
|
|
39
58
|
|
|
40
|
-
// Used to map between HeroTypes enum values and Chakra variant options.
|
|
41
|
-
const variantMap = {};
|
|
42
|
-
for (const type in HeroTypes) {
|
|
43
|
-
variantMap[HeroTypes[type]] = HeroTypes[type];
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Map the HeroTypes to the Hero Chakra theme variant object. If a wrong
|
|
47
|
-
* value is passed (typically in non-Typescript scenarios), then the default
|
|
48
|
-
* is the "primary" variant.
|
|
49
|
-
*/
|
|
50
|
-
const getVariant = (type) => variantMap[type] || HeroTypes.Primary;
|
|
51
|
-
|
|
52
59
|
export const Hero = chakra(
|
|
53
60
|
(props: React.PropsWithChildren<HeroProps>) => {
|
|
54
61
|
const {
|
|
@@ -57,89 +64,86 @@ export const Hero = chakra(
|
|
|
57
64
|
foregroundColor,
|
|
58
65
|
heading,
|
|
59
66
|
heroType,
|
|
60
|
-
|
|
61
|
-
|
|
67
|
+
imageProps = {
|
|
68
|
+
alt: "",
|
|
69
|
+
src: "",
|
|
70
|
+
},
|
|
62
71
|
locationDetails,
|
|
63
72
|
subHeaderText,
|
|
64
73
|
...rest
|
|
65
74
|
} = props;
|
|
66
|
-
const
|
|
67
|
-
const styles = useMultiStyleConfig("Hero", { variant });
|
|
75
|
+
const styles = useMultiStyleConfig("Hero", { variant: heroType });
|
|
68
76
|
const headingStyles = styles.heading;
|
|
69
77
|
// We want to add `Hero`-specific styling to the `Heading` component.
|
|
70
78
|
const finalHeading =
|
|
71
|
-
heading &&
|
|
72
|
-
React.cloneElement(heading, { additionalStyles: headingStyles });
|
|
79
|
+
heading && React.cloneElement(heading, { __css: headingStyles });
|
|
73
80
|
let backgroundImageStyle = {};
|
|
74
81
|
let contentBoxStyling = {};
|
|
75
82
|
|
|
76
|
-
if (
|
|
83
|
+
if (imageProps.src && !imageProps.alt) {
|
|
77
84
|
console.warn(
|
|
78
|
-
`NYPL Reservoir: The "
|
|
85
|
+
`NYPL Reservoir Hero: The "imageProps.src" prop was passed but the "imageProps.alt" props was not. This will make the rendered image inaccessible.`
|
|
79
86
|
);
|
|
80
87
|
}
|
|
81
88
|
|
|
82
|
-
if (heroType ===
|
|
89
|
+
if (heroType === "primary") {
|
|
83
90
|
if (!backgroundImageSrc) {
|
|
84
91
|
console.warn(
|
|
85
92
|
"NYPL Reservoir Hero: It is recommended to use the `backgroundImageSrc` " +
|
|
86
|
-
"prop for the `
|
|
93
|
+
"prop for the `'primary'` `heroType` variant."
|
|
87
94
|
);
|
|
88
95
|
}
|
|
89
|
-
if (
|
|
96
|
+
if (imageProps.alt && imageProps.src) {
|
|
90
97
|
console.warn(
|
|
91
|
-
"NYPL Reservoir Hero: The `
|
|
92
|
-
"passed, but the `
|
|
98
|
+
"NYPL Reservoir Hero: The `imageProps.src` and `imageProps.alt` props have been " +
|
|
99
|
+
"passed, but the `'primary'` `heroType` variant will not use it."
|
|
93
100
|
);
|
|
94
101
|
}
|
|
95
102
|
} else if (locationDetails) {
|
|
96
103
|
console.warn(
|
|
97
104
|
"NYPL Reservoir Hero: The `locationDetails` prop should only be used " +
|
|
98
|
-
"with the `
|
|
105
|
+
"with the `'primary'` `heroType` variant."
|
|
99
106
|
);
|
|
100
107
|
}
|
|
101
|
-
if (
|
|
108
|
+
if (heroSecondaryTypes.includes(heroType) && backgroundImageSrc) {
|
|
102
109
|
console.warn(
|
|
103
110
|
"NYPL Reservoir Hero: The `backgroundImageSrc` prop has been passed, " +
|
|
104
|
-
"but the `
|
|
111
|
+
"but the `'secondary'` `heroType` variant will not use it."
|
|
105
112
|
);
|
|
106
113
|
}
|
|
107
|
-
if (heroType ===
|
|
114
|
+
if (heroType === "tertiary" && (backgroundImageSrc || imageProps.src)) {
|
|
108
115
|
console.warn(
|
|
109
|
-
"NYPL Reservoir Hero: The `
|
|
116
|
+
"NYPL Reservoir Hero: The `'tertiary'` `heroType` variant hero " +
|
|
110
117
|
"will not use any of the image props."
|
|
111
118
|
);
|
|
112
119
|
}
|
|
113
|
-
if (heroType ===
|
|
120
|
+
if (heroType === "campaign" && (!backgroundImageSrc || !imageProps.src)) {
|
|
114
121
|
console.warn(
|
|
115
122
|
"NYPL Reservoir Hero: It is recommended to use both the " +
|
|
116
|
-
"`backgroundImageSrc` and `
|
|
117
|
-
"`
|
|
123
|
+
"`backgroundImageSrc` and `imageProps.src` props for the " +
|
|
124
|
+
"`'campaign'` `heroType` variant."
|
|
118
125
|
);
|
|
119
126
|
}
|
|
120
|
-
if (heroType ===
|
|
127
|
+
if (heroType === "fiftyFifty" && backgroundImageSrc) {
|
|
121
128
|
console.warn(
|
|
122
129
|
"NYPL Reservoir Hero: The `backgroundImageSrc` prop has been passed, " +
|
|
123
|
-
"but the `
|
|
130
|
+
"but the `'fiftyFifty'` `heroType` variant hero will not use it."
|
|
124
131
|
);
|
|
125
132
|
}
|
|
126
133
|
|
|
127
|
-
if (heroType ===
|
|
134
|
+
if (heroType === "primary") {
|
|
128
135
|
backgroundImageStyle = backgroundImageSrc
|
|
129
136
|
? { backgroundImage: `url(${backgroundImageSrc})` }
|
|
130
137
|
: {};
|
|
131
|
-
} else if (heroType ===
|
|
138
|
+
} else if (heroType === "campaign") {
|
|
132
139
|
backgroundImageStyle = backgroundImageSrc
|
|
133
140
|
? { backgroundImage: `url(${backgroundImageSrc})` }
|
|
134
141
|
: { backgroundColor };
|
|
135
|
-
} else if (
|
|
136
|
-
heroType === HeroTypes.Tertiary ||
|
|
137
|
-
heroType === HeroTypes.FiftyFifty
|
|
138
|
-
) {
|
|
142
|
+
} else if (heroType === "tertiary" || heroType === "fiftyFifty") {
|
|
139
143
|
backgroundImageStyle = { backgroundColor };
|
|
140
144
|
}
|
|
141
145
|
|
|
142
|
-
if (!
|
|
146
|
+
if (!heroSecondaryTypes.includes(heroType)) {
|
|
143
147
|
contentBoxStyling = {
|
|
144
148
|
color: foregroundColor,
|
|
145
149
|
backgroundColor,
|
|
@@ -147,15 +151,15 @@ export const Hero = chakra(
|
|
|
147
151
|
} else if (foregroundColor || backgroundColor) {
|
|
148
152
|
console.warn(
|
|
149
153
|
"NYPL Reservoir Hero: The `foregroundColor` and/or `backgroundColor` " +
|
|
150
|
-
"props have been passed, but the `
|
|
154
|
+
"props have been passed, but the `'secondary'` `heroType` " +
|
|
151
155
|
"variant will not use them."
|
|
152
156
|
);
|
|
153
157
|
}
|
|
154
158
|
|
|
155
159
|
const childrenToRender =
|
|
156
|
-
heroType ===
|
|
160
|
+
heroType === "campaign" ? (
|
|
157
161
|
<>
|
|
158
|
-
<Image alt={
|
|
162
|
+
<Image alt={imageProps.alt} src={imageProps.src} />
|
|
159
163
|
<Box __css={styles.interior}>
|
|
160
164
|
{finalHeading}
|
|
161
165
|
{subHeaderText}
|
|
@@ -163,12 +167,11 @@ export const Hero = chakra(
|
|
|
163
167
|
</>
|
|
164
168
|
) : (
|
|
165
169
|
<>
|
|
166
|
-
{heroType !==
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
)}
|
|
170
|
+
{heroType !== "primary" && heroType !== "tertiary" && (
|
|
171
|
+
<Image alt={imageProps.alt} src={imageProps.src} />
|
|
172
|
+
)}
|
|
170
173
|
{finalHeading}
|
|
171
|
-
{heroType ===
|
|
174
|
+
{heroType === "tertiary" && subHeaderText ? (
|
|
172
175
|
<p>{subHeaderText}</p>
|
|
173
176
|
) : (
|
|
174
177
|
<Box __css={styles.bodyText}>{subHeaderText}</Box>
|
|
@@ -191,7 +194,6 @@ export const Hero = chakra(
|
|
|
191
194
|
>
|
|
192
195
|
{childrenToRender}
|
|
193
196
|
</Box>
|
|
194
|
-
{locationDetails}
|
|
195
197
|
</Box>
|
|
196
198
|
);
|
|
197
199
|
},
|
|
@@ -8,33 +8,9 @@ import {
|
|
|
8
8
|
import { withDesign } from "storybook-addon-designs";
|
|
9
9
|
|
|
10
10
|
import Heading from "../Heading/Heading";
|
|
11
|
-
import { HeadingLevels } from "../Heading/HeadingTypes";
|
|
12
11
|
import Icon from "./Icon";
|
|
13
|
-
import {
|
|
14
|
-
IconAlign,
|
|
15
|
-
IconColors,
|
|
16
|
-
IconNames,
|
|
17
|
-
IconRotationTypes,
|
|
18
|
-
IconSizes,
|
|
19
|
-
IconTypes,
|
|
20
|
-
} from "./IconTypes";
|
|
21
12
|
import iconSvgs from "./IconSvgs";
|
|
22
|
-
import List from "../List/List";
|
|
23
|
-
import { ListTypes } from "../List/ListTypes";
|
|
24
13
|
import { getCategory } from "../../utils/componentCategories";
|
|
25
|
-
import { getStorybookEnumValues } from "../../utils/utils";
|
|
26
|
-
|
|
27
|
-
export const alignEnumValues = getStorybookEnumValues(IconAlign, "IconAlign");
|
|
28
|
-
export const namesEnumValues = getStorybookEnumValues(IconNames, "IconNames");
|
|
29
|
-
export const colorsEnumValues = getStorybookEnumValues(
|
|
30
|
-
IconColors,
|
|
31
|
-
"IconColors"
|
|
32
|
-
);
|
|
33
|
-
export const sizesEnumValues = getStorybookEnumValues(IconSizes, "IconSizes");
|
|
34
|
-
export const rotationEnumValues = getStorybookEnumValues(
|
|
35
|
-
IconRotationTypes,
|
|
36
|
-
"IconRotationTypes"
|
|
37
|
-
);
|
|
38
14
|
|
|
39
15
|
<Meta
|
|
40
16
|
title={getCategory("Icon")}
|
|
@@ -49,31 +25,42 @@ export const rotationEnumValues = getStorybookEnumValues(
|
|
|
49
25
|
}}
|
|
50
26
|
argTypes={{
|
|
51
27
|
align: {
|
|
52
|
-
|
|
53
|
-
table: { defaultValue: { summary: "IconAlign.None" } },
|
|
54
|
-
options: alignEnumValues.options,
|
|
28
|
+
table: { defaultValue: { summary: "none" } },
|
|
55
29
|
},
|
|
56
30
|
children: { table: { disable: true } },
|
|
57
31
|
className: { control: false },
|
|
58
32
|
color: {
|
|
59
33
|
control: { type: "select" },
|
|
60
|
-
table: { defaultValue: { summary: "
|
|
61
|
-
options:
|
|
34
|
+
table: { defaultValue: { summary: "ui.black" } },
|
|
35
|
+
options: [
|
|
36
|
+
"ui.black",
|
|
37
|
+
"ui.white",
|
|
38
|
+
"brand.primary",
|
|
39
|
+
"brand.secondary",
|
|
40
|
+
"section.blogs.primary",
|
|
41
|
+
"section.blogs.secondary",
|
|
42
|
+
"section.books-and-more.primary",
|
|
43
|
+
"section.books-and-more.secondary",
|
|
44
|
+
"section.education.primary",
|
|
45
|
+
"section.education.secondary",
|
|
46
|
+
"section.locations.primary",
|
|
47
|
+
"section.locations.secondary",
|
|
48
|
+
"section.research.primary",
|
|
49
|
+
"section.research.secondary",
|
|
50
|
+
"section.research-library.lpa",
|
|
51
|
+
"section.research-library.schomburg",
|
|
52
|
+
"section.research-library.schwartzman",
|
|
53
|
+
"section.whats-on.primary",
|
|
54
|
+
"section.whats-on.secondary",
|
|
55
|
+
],
|
|
62
56
|
},
|
|
63
57
|
iconRotation: {
|
|
64
|
-
|
|
65
|
-
table: { defaultValue: { summary: "IconRotationTypes.Rotate0" } },
|
|
66
|
-
options: rotationEnumValues.options,
|
|
58
|
+
table: { defaultValue: { summary: "rotate0" } },
|
|
67
59
|
},
|
|
68
60
|
id: { control: false },
|
|
69
|
-
name: {
|
|
70
|
-
control: { type: "select" },
|
|
71
|
-
options: namesEnumValues.options,
|
|
72
|
-
},
|
|
61
|
+
name: {},
|
|
73
62
|
size: {
|
|
74
|
-
|
|
75
|
-
table: { defaultValue: { summary: "IconSizes.Medium" } },
|
|
76
|
-
options: sizesEnumValues.options,
|
|
63
|
+
table: { defaultValue: { summary: "medium" } },
|
|
77
64
|
},
|
|
78
65
|
title: {
|
|
79
66
|
control: false,
|
|
@@ -81,7 +68,7 @@ export const rotationEnumValues = getStorybookEnumValues(
|
|
|
81
68
|
},
|
|
82
69
|
type: {
|
|
83
70
|
control: false,
|
|
84
|
-
table: { defaultValue: { summary: "
|
|
71
|
+
table: { defaultValue: { summary: "default" } },
|
|
85
72
|
},
|
|
86
73
|
}}
|
|
87
74
|
/>
|
|
@@ -91,7 +78,7 @@ export const rotationEnumValues = getStorybookEnumValues(
|
|
|
91
78
|
| Component Version | DS Version |
|
|
92
79
|
| ----------------- | ---------- |
|
|
93
80
|
| Added | `0.0.4` |
|
|
94
|
-
| Latest | `0.
|
|
81
|
+
| Latest | `0.28.0` |
|
|
95
82
|
|
|
96
83
|
## Table of Contents
|
|
97
84
|
|
|
@@ -114,57 +101,47 @@ export const rotationEnumValues = getStorybookEnumValues(
|
|
|
114
101
|
<Story
|
|
115
102
|
name="Icon with Controls"
|
|
116
103
|
args={{
|
|
117
|
-
|
|
118
|
-
align: "IconAlign.None",
|
|
104
|
+
align: "none",
|
|
119
105
|
className: undefined,
|
|
120
|
-
color: "
|
|
106
|
+
color: "ui.black",
|
|
121
107
|
decorative: true,
|
|
122
|
-
iconRotation: "
|
|
108
|
+
iconRotation: "rotate0",
|
|
123
109
|
id: "icon-id",
|
|
124
|
-
name: "
|
|
125
|
-
size: "
|
|
110
|
+
name: "check",
|
|
111
|
+
size: "xxlarge",
|
|
126
112
|
title: undefined,
|
|
127
|
-
type:
|
|
113
|
+
type: "default",
|
|
128
114
|
}}
|
|
129
115
|
>
|
|
130
|
-
{(args) =>
|
|
131
|
-
<Icon
|
|
132
|
-
align={alignEnumValues.getValue(args.align)}
|
|
133
|
-
color={colorsEnumValues.getValue(args.color)}
|
|
134
|
-
iconRotation={rotationEnumValues.getValue(args.iconRotation)}
|
|
135
|
-
name={namesEnumValues.getValue(args.name)}
|
|
136
|
-
size={sizesEnumValues.getValue(args.size)}
|
|
137
|
-
title={args.title}
|
|
138
|
-
/>
|
|
139
|
-
)}
|
|
116
|
+
{(args) => <Icon {...args} />}
|
|
140
117
|
</Story>
|
|
141
118
|
</Canvas>
|
|
142
119
|
|
|
143
120
|
<ArgsTable story="Icon with Controls" />
|
|
144
121
|
|
|
145
|
-
export const iconRow = (
|
|
122
|
+
export const iconRow = (iconName, opts = {}) => {
|
|
146
123
|
// We'll use this setup function to render all the icons in a list item.
|
|
147
124
|
// Some icons display better with a dark background.
|
|
148
125
|
const styles = { display: "block" };
|
|
149
126
|
const {
|
|
150
|
-
size =
|
|
151
|
-
iconRotation =
|
|
152
|
-
color =
|
|
153
|
-
displayValue =
|
|
127
|
+
size = "large",
|
|
128
|
+
iconRotation = "rotate0",
|
|
129
|
+
color = "ui.black",
|
|
130
|
+
displayValue = iconName,
|
|
154
131
|
} = opts;
|
|
155
|
-
let key =
|
|
156
|
-
if (
|
|
132
|
+
let key = iconName;
|
|
133
|
+
if (iconName.indexOf("Negative") !== -1 || color.indexOf("White") !== -1) {
|
|
157
134
|
styles.backgroundColor = "#000";
|
|
158
135
|
styles.padding = "1rem";
|
|
159
136
|
}
|
|
160
137
|
// The following is just to fix duplicate React key issues.
|
|
161
|
-
if (iconRotation !==
|
|
138
|
+
if (iconRotation !== "rotate0") {
|
|
162
139
|
key += `-${iconRotation}`;
|
|
163
140
|
}
|
|
164
|
-
if (color !==
|
|
141
|
+
if (color !== "ui.black") {
|
|
165
142
|
key += `-${color}`;
|
|
166
143
|
}
|
|
167
|
-
if (size !==
|
|
144
|
+
if (size !== "large") {
|
|
168
145
|
key += `-${size}`;
|
|
169
146
|
}
|
|
170
147
|
return (
|
|
@@ -172,10 +149,10 @@ export const iconRow = (icon, iconType = IconNames, opts = {}) => {
|
|
|
172
149
|
key={key}
|
|
173
150
|
style={{ marginBottom: "var(--nypl-space-l)", textAlign: "center" }}
|
|
174
151
|
>
|
|
175
|
-
<Heading level=
|
|
152
|
+
<Heading level="four">{displayValue}</Heading>
|
|
176
153
|
<span style={styles}>
|
|
177
154
|
<Icon
|
|
178
|
-
name={
|
|
155
|
+
name={iconName}
|
|
179
156
|
size={size}
|
|
180
157
|
iconRotation={iconRotation}
|
|
181
158
|
color={color}
|
|
@@ -188,37 +165,105 @@ export const icons = [];
|
|
|
188
165
|
export const rotations = [];
|
|
189
166
|
export const colors = [];
|
|
190
167
|
export const sizes = [];
|
|
191
|
-
|
|
168
|
+
export const iconColorsValues = [
|
|
169
|
+
"ui.black",
|
|
170
|
+
"ui.white",
|
|
171
|
+
"brand.primary",
|
|
172
|
+
"brand.secondary",
|
|
173
|
+
"section.blogs.primary",
|
|
174
|
+
"section.blogs.secondary",
|
|
175
|
+
"section.books-and-more.primary",
|
|
176
|
+
"section.books-and-more.secondary",
|
|
177
|
+
"section.education.primary",
|
|
178
|
+
"section.education.secondary",
|
|
179
|
+
"section.locations.primary",
|
|
180
|
+
"section.locations.secondary",
|
|
181
|
+
"section.research.primary",
|
|
182
|
+
"section.research.secondary",
|
|
183
|
+
"section.research-library.lpa",
|
|
184
|
+
"section.research-library.schomburg",
|
|
185
|
+
"section.research-library.schwartzman",
|
|
186
|
+
"section.whats-on.primary",
|
|
187
|
+
"section.whats-on.secondary",
|
|
188
|
+
];
|
|
189
|
+
export const iconNamesValues = [
|
|
190
|
+
"accessibilityFull",
|
|
191
|
+
"accessibilityPartial",
|
|
192
|
+
"actionCheckCircle",
|
|
193
|
+
"actionHelpDefault",
|
|
194
|
+
"actionHelpOutline",
|
|
195
|
+
"alertNotificationImportant",
|
|
196
|
+
"actionLaunch",
|
|
197
|
+
"arrow",
|
|
198
|
+
"check",
|
|
199
|
+
"clock",
|
|
200
|
+
"close",
|
|
201
|
+
"download",
|
|
202
|
+
"errorFilled",
|
|
203
|
+
"errorOutline",
|
|
204
|
+
"fileTypeAudio",
|
|
205
|
+
"fileTypeDoc",
|
|
206
|
+
"fileTypeGenericDoc",
|
|
207
|
+
"fileTypeImage",
|
|
208
|
+
"fileTypePdf",
|
|
209
|
+
"fileTypeSpreadsheet",
|
|
210
|
+
"fileTypeVideo",
|
|
211
|
+
"headset",
|
|
212
|
+
"minus",
|
|
213
|
+
"plus",
|
|
214
|
+
"search",
|
|
215
|
+
"speakerNotes",
|
|
216
|
+
"utilityAccountFilled",
|
|
217
|
+
"utilityAccountUnfilled",
|
|
218
|
+
"utilityHamburger",
|
|
219
|
+
"utilitySearch",
|
|
220
|
+
];
|
|
221
|
+
export const iconRotationTypesValues = [
|
|
222
|
+
"rotate0",
|
|
223
|
+
"rotate90",
|
|
224
|
+
"rotate180",
|
|
225
|
+
"rotate270",
|
|
226
|
+
];
|
|
227
|
+
export const iconSizesValues = [
|
|
228
|
+
"default",
|
|
229
|
+
"small",
|
|
230
|
+
"medium",
|
|
231
|
+
"large",
|
|
232
|
+
"xlarge",
|
|
233
|
+
"xxlarge",
|
|
234
|
+
"xxxlarge",
|
|
235
|
+
];
|
|
236
|
+
for (const icon in iconNamesValues) {
|
|
192
237
|
icons.push(
|
|
193
|
-
iconRow(icon,
|
|
194
|
-
displayValue:
|
|
195
|
-
size:
|
|
238
|
+
iconRow(iconNamesValues[icon], {
|
|
239
|
+
displayValue: iconNamesValues[icon],
|
|
240
|
+
size: "xxlarge",
|
|
196
241
|
})
|
|
197
242
|
);
|
|
198
243
|
}
|
|
199
|
-
for (const iconRotation in
|
|
244
|
+
for (const iconRotation in iconRotationTypesValues) {
|
|
200
245
|
rotations.push(
|
|
201
|
-
iconRow("
|
|
202
|
-
displayValue:
|
|
203
|
-
iconRotation:
|
|
204
|
-
size:
|
|
246
|
+
iconRow("arrow", {
|
|
247
|
+
displayValue: iconRotationTypesValues[iconRotation],
|
|
248
|
+
iconRotation: iconRotationTypesValues[iconRotation],
|
|
249
|
+
size: "xxlarge",
|
|
205
250
|
})
|
|
206
251
|
);
|
|
207
252
|
}
|
|
208
|
-
for (const iconColor in
|
|
253
|
+
for (const iconColor in iconColorsValues) {
|
|
209
254
|
colors.push(
|
|
210
|
-
iconRow("
|
|
211
|
-
color:
|
|
212
|
-
displayValue:
|
|
213
|
-
size:
|
|
255
|
+
iconRow("errorFilled", {
|
|
256
|
+
color: iconColorsValues[iconColor],
|
|
257
|
+
displayValue: iconColorsValues[iconColor],
|
|
258
|
+
size: "xxlarge",
|
|
214
259
|
})
|
|
215
260
|
);
|
|
216
261
|
}
|
|
217
|
-
for (const iconSize in
|
|
262
|
+
for (const iconSize in iconSizesValues) {
|
|
218
263
|
sizes.push(
|
|
219
|
-
iconRow("
|
|
220
|
-
displayValue:
|
|
221
|
-
size:
|
|
264
|
+
iconRow("actionCheckCircle", {
|
|
265
|
+
displayValue: iconSizesValues[iconSize],
|
|
266
|
+
size: iconSizesValues[iconSize],
|
|
222
267
|
})
|
|
223
268
|
);
|
|
224
269
|
}
|
|
@@ -229,10 +274,10 @@ export const allIconsType = (list) => (
|
|
|
229
274
|
|
|
230
275
|
## Accessibility
|
|
231
276
|
|
|
232
|
-
For accessibility purposes, every Reservoir Design System (DS) `Icon` will
|
|
233
|
-
render the `svg` element with its icon name in the `title` element. The default
|
|
234
|
-
text in the `title` element is the icon's code name. Pass in better descriptive
|
|
235
|
-
text in the `title` prop when using the `Icon` component in your application.
|
|
277
|
+
For accessibility purposes, every Reservoir Design System (DS) `Icon` will
|
|
278
|
+
render the `svg` element with its icon name in the `title` element. The default
|
|
279
|
+
text in the `title` element is the icon's code name. Pass in better descriptive
|
|
280
|
+
text in the `title` prop when using the `Icon` component in your application.
|
|
236
281
|
This will give screenreaders a better descriptive title for the `svg` graphic.
|
|
237
282
|
|
|
238
283
|
`Icon`s are decorative by default. This means that they are presentational and
|
|
@@ -248,19 +293,15 @@ Resources:
|
|
|
248
293
|
## Rotation Types
|
|
249
294
|
|
|
250
295
|
Passing an `iconRotation` prop with a value from `IconRotationTypes` allows
|
|
251
|
-
the icon to be rotated when it is rendered. The
|
|
252
|
-
|
|
296
|
+
the icon to be rotated when it is rendered. The values are:
|
|
297
|
+
`"rotate0"`, `"rotate90"`, `"rotate180"`, and `"rotate270"`.
|
|
253
298
|
|
|
254
299
|
Note: All of the examples below have been rendered with the `size` prop set to
|
|
255
|
-
`
|
|
300
|
+
`xxlarge`.
|
|
256
301
|
|
|
257
302
|
```jsx
|
|
258
303
|
// Example
|
|
259
|
-
<Icon
|
|
260
|
-
iconRotation={IconRotationTypes.Rotate180}
|
|
261
|
-
name={IconNames.Arrow}
|
|
262
|
-
size={IconSizes.ExtraExtraLarge}
|
|
263
|
-
/>
|
|
304
|
+
<Icon iconRotation="rotate180" name="arrow" size="xxlarge" />
|
|
264
305
|
```
|
|
265
306
|
|
|
266
307
|
<Canvas>
|
|
@@ -269,19 +310,23 @@ Note: All of the examples below have been rendered with the `size` prop set to
|
|
|
269
310
|
|
|
270
311
|
## IconColors Types
|
|
271
312
|
|
|
272
|
-
Update an SVG icon by passing a `color` prop with a value from `IconColors
|
|
273
|
-
The
|
|
313
|
+
Update an SVG icon by passing a `color` prop with a value from the `IconColors`
|
|
314
|
+
type. The values are: `"ui.black"`, `"ui.white"`, `"brand.primary"`,
|
|
315
|
+
`"brand.secondary"`, `"section.blogs.primary"`, `"section.blogs.secondary"`,
|
|
316
|
+
`"section.books-and-more.primary"`, `"section.books-and-more.secondary"`,
|
|
317
|
+
`"section.education.primary"`, `"section.education.secondary"`,
|
|
318
|
+
`"section.locations.primary"`, `"section.locations.secondary"`,
|
|
319
|
+
`"section.research.primary"`, `"section.research.secondary"`,
|
|
320
|
+
`"section.research-library.lpa"`, `"section.research-library.schomburg"`,
|
|
321
|
+
`"section.research-library.schwartzman"`, `"section.whats-on.primary"`,
|
|
322
|
+
`"section.whats-on.secondary"`.
|
|
274
323
|
|
|
275
324
|
Note: All of the examples below have been rendered with the `size` prop set to
|
|
276
|
-
`
|
|
325
|
+
`xxlarge`.
|
|
277
326
|
|
|
278
327
|
```jsx
|
|
279
328
|
// Example
|
|
280
|
-
<Icon
|
|
281
|
-
color={IconColors.BrandPrimary}
|
|
282
|
-
name={IconNames.ErrorFilled}
|
|
283
|
-
size={IconSizes.ExtraExtraLarge}
|
|
284
|
-
/>
|
|
329
|
+
<Icon color="brand.primary" name="errorFilled" size="xxlarge" />
|
|
285
330
|
```
|
|
286
331
|
|
|
287
332
|
<Canvas>
|
|
@@ -290,15 +335,16 @@ Note: All of the examples below have been rendered with the `size` prop set to
|
|
|
290
335
|
|
|
291
336
|
## IconSizes Types
|
|
292
337
|
|
|
293
|
-
Update an SVG icon by passing a `size` prop with a value from `IconSizes`.
|
|
294
|
-
|
|
338
|
+
Update an SVG icon by passing a `size` prop with a value from `IconSizes`. The
|
|
339
|
+
values are: `"default"`, `"small"`, `"medium"`, `"large"`, `"xlarge"`,
|
|
340
|
+
`"xxlarge"`, `"xxxlarge"`.
|
|
295
341
|
|
|
296
|
-
Note: `
|
|
297
|
-
|
|
342
|
+
Note: `"default"` sets the width to `100%` and the rendered icon will expand to
|
|
343
|
+
fill the full width of the parent element.
|
|
298
344
|
|
|
299
345
|
```jsx
|
|
300
346
|
// Example
|
|
301
|
-
<Icon name=
|
|
347
|
+
<Icon name="actionCheckCircle" size="xxlarge" />
|
|
302
348
|
```
|
|
303
349
|
|
|
304
350
|
<Canvas>
|
|
@@ -308,10 +354,18 @@ expand to fill the full width of the parent element.
|
|
|
308
354
|
## All Display Icons
|
|
309
355
|
|
|
310
356
|
The following icons are for generic purposes. All the available icon names can
|
|
311
|
-
be found in the `IconNames`
|
|
357
|
+
be found in the `IconNames` type. They are: `"accessibilityFull"`,
|
|
358
|
+
`"accessibilityPartial"`, `"actionCheckCircle"`, `"actionHelpDefault"`,
|
|
359
|
+
`"actionHelpOutline"`, `"alertNotificationImportant"`, `"actionLaunch"`,
|
|
360
|
+
`"arrow"`, `"check"`, `"clock"`, `"close"`, `"download"`, `"errorFilled"`,
|
|
361
|
+
`"errorOutline"`, `"fileTypeAudio"`, `"fileTypeDoc"`,
|
|
362
|
+
`"fileTypeGenericDoc"`, `"fileTypeImage"`, `"fileTypePdf"`,
|
|
363
|
+
`"fileTypeSpreadsheet"`, `"fileTypeVideo"`, `"headset"`, `"minus"`,
|
|
364
|
+
`"plus"`, `"search"`, `"speakerNotes"`, `"utilityAccountFilled"`,
|
|
365
|
+
`"utilityAccountUnfilled"`, `"utilityHamburger"`, `"utilitySearch"`.
|
|
312
366
|
|
|
313
367
|
Note: All of the examples below have been rendered with the `size` prop set to
|
|
314
|
-
`
|
|
368
|
+
`xxlarge`.
|
|
315
369
|
|
|
316
370
|
<Canvas withToolbar>
|
|
317
371
|
<Story name="All Icons">{allIconsType(icons)}</Story>
|
|
@@ -336,9 +390,9 @@ child to the `Icon` component.
|
|
|
336
390
|
<Story
|
|
337
391
|
name="Custom Icons"
|
|
338
392
|
args={{
|
|
339
|
-
color:
|
|
340
|
-
size:
|
|
341
|
-
iconRotation:
|
|
393
|
+
color: "ui.black",
|
|
394
|
+
size: "xxxlarge",
|
|
395
|
+
iconRotation: "rotate0",
|
|
342
396
|
decorative: true,
|
|
343
397
|
}}
|
|
344
398
|
>
|