@nypl/design-system-react-components 0.26.0 → 0.28.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 +56 -0
- 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 +977 -1213
- 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 +976 -1276
- 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 +143 -177
- package/src/components/Card/Card.test.tsx +36 -97
- package/src/components/Card/Card.tsx +78 -74
- package/src/components/Card/__snapshots__/Card.test.tsx.snap +1 -1
- package/src/components/Chakra/Box.stories.mdx +2 -6
- package/src/components/Chakra/Center.stories.mdx +5 -23
- package/src/components/Chakra/Flex.stories.mdx +4 -6
- package/src/components/Chakra/Stack.stories.mdx +9 -10
- 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/Checkbox/__snapshots__/Checkbox.test.tsx.snap +9 -9
- 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 +24 -35
- 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 +1 -1
- 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 +62 -62
- package/src/components/StyleGuide/ColorCard.tsx +2 -4
- package/src/components/StyleGuide/Colors.stories.mdx +7 -8
- package/src/components/StyleGuide/DesignTokens.stories.mdx +5 -7
- package/src/components/StyleGuide/Forms.stories.mdx +0 -1
- package/src/components/StyleGuide/Iconography.stories.mdx +59 -77
- package/src/components/StyleGuide/Spacing.stories.mdx +0 -1
- package/src/components/StyleGuide/Typography.stories.mdx +15 -18
- 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/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,5 +1,11 @@
|
|
|
1
|
+
interface TextBaseStyle {
|
|
2
|
+
isBold: boolean;
|
|
3
|
+
isItalic: boolean;
|
|
4
|
+
noSpace: boolean;
|
|
5
|
+
variant: string;
|
|
6
|
+
}
|
|
1
7
|
declare const Text: {
|
|
2
|
-
baseStyle: (
|
|
8
|
+
baseStyle: ({ isBold, isItalic, noSpace, variant }: TextBaseStyle) => {
|
|
3
9
|
fontStyle: string;
|
|
4
10
|
fontWeight: string;
|
|
5
11
|
marginBottom: string;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { ToggleSizes } from "../../components/Toggle/Toggle";
|
|
2
|
+
interface ToggleBaseStyle {
|
|
3
|
+
isDisabled: boolean;
|
|
4
|
+
size: ToggleSizes;
|
|
5
|
+
}
|
|
1
6
|
declare const _default: {
|
|
2
7
|
Toggle: {
|
|
3
8
|
parts: string[];
|
|
4
|
-
baseStyle: ({ isDisabled, size }: {
|
|
5
|
-
isDisabled: any;
|
|
6
|
-
size: any;
|
|
7
|
-
}) => {
|
|
9
|
+
baseStyle: ({ isDisabled, size }: ToggleBaseStyle) => {
|
|
8
10
|
label: {
|
|
9
11
|
alignItems: string;
|
|
10
12
|
display: string;
|
package/dist/theme/provider.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getCategory: (component:
|
|
1
|
+
export declare const getCategory: (component: string) => string;
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -4,29 +4,13 @@
|
|
|
4
4
|
* `step` between values.
|
|
5
5
|
*/
|
|
6
6
|
export declare const range: (start: number, stop: number, step?: number) => number[];
|
|
7
|
-
/**
|
|
8
|
-
* Map an enum value to a component's Chakra theme variant object. If a wrong
|
|
9
|
-
* value is passed (typically in non-Typescript scenarios), then the "fallback"
|
|
10
|
-
* value, if provided, will be used.
|
|
11
|
-
*/
|
|
12
|
-
export declare const getVariant: (variant: any, collection: any, fallback?: any) => any;
|
|
13
|
-
/**
|
|
14
|
-
* Given an enum object and its name, this will return (1) an array `options`
|
|
15
|
-
* of all values with the enum name as the prefix, and (2) a function that
|
|
16
|
-
* returns the correct enum value given a string from the `options` array.
|
|
17
|
-
* @NOTE this is only used for Storybook documentation.
|
|
18
|
-
*/
|
|
19
|
-
export declare const getStorybookEnumValues: (enumObject: any, name: any) => {
|
|
20
|
-
options: string[];
|
|
21
|
-
getValue: (key: any) => any;
|
|
22
|
-
};
|
|
23
7
|
/**
|
|
24
8
|
* Given a pagination's pageCount, this will return (1) a page number,
|
|
25
9
|
* derived from the current URL, and (2) a function that, when passed to
|
|
26
10
|
* Pagination component, makes the URL change and refreshes the page.
|
|
27
11
|
* @NOTE this is only used for Storybook documentation.
|
|
28
12
|
*/
|
|
29
|
-
export declare const getStorybookHrefProps: (pageCount:
|
|
13
|
+
export declare const getStorybookHrefProps: (pageCount: number) => {
|
|
30
14
|
computedCurrentPage: number;
|
|
31
|
-
getPageHref: (selectedPage:
|
|
15
|
+
getPageHref: (selectedPage: number) => string;
|
|
32
16
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nypl/design-system-react-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "NYPL Reservoir Design System React Components",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"analyze": "size-limit --why",
|
|
34
34
|
"generate-sass-resources": "gulp",
|
|
35
35
|
"storybook": "start-storybook -p 6006 -s ./.storybook/public",
|
|
36
|
-
"build-storybook:
|
|
36
|
+
"build-storybook:v0": "npm run prebuild:storybook && build-storybook -c .storybook -o ./reservoir/v0",
|
|
37
37
|
"prebuild:storybook": "npm run test:generate-output"
|
|
38
38
|
},
|
|
39
39
|
"lint-staged": {
|
|
@@ -57,27 +57,28 @@
|
|
|
57
57
|
}
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@chakra-ui/react": ">=1.
|
|
61
|
-
"@chakra-ui/system": ">=1.
|
|
62
|
-
"@emotion/react": "11.4.1",
|
|
63
|
-
"@emotion/styled": "11.3.0",
|
|
64
|
-
"framer-motion": "4.1.17",
|
|
60
|
+
"@chakra-ui/react": ">=1.8.5",
|
|
61
|
+
"@chakra-ui/system": ">=1.11.0",
|
|
62
|
+
"@emotion/react": ">=11.4.1",
|
|
63
|
+
"@emotion/styled": ">=11.3.0",
|
|
64
|
+
"framer-motion": "^4.1.17",
|
|
65
65
|
"he": "1.2.0",
|
|
66
66
|
"react-datepicker": "4.1.1",
|
|
67
67
|
"system-font-css": "2.0.2",
|
|
68
68
|
"typescript": "4.3.5"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
|
-
"@chakra-ui/react": ">=1.
|
|
72
|
-
"@chakra-ui/system": ">=1.
|
|
71
|
+
"@chakra-ui/react": ">=1.8.0",
|
|
72
|
+
"@chakra-ui/system": ">=1.10.0",
|
|
73
73
|
"@emotion/react": ">=11.4.1",
|
|
74
74
|
"@emotion/styled": ">=11.3.0",
|
|
75
|
-
"framer-motion": "
|
|
75
|
+
"framer-motion": "^4.1.17",
|
|
76
76
|
"react": ">=16.13.0",
|
|
77
77
|
"react-dom": ">=16.13.0"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@babel/core": "7.14.6",
|
|
81
|
+
"@chakra-ui/storybook-addon": "1.0.3",
|
|
81
82
|
"@mdx-js/react": "1.6.22",
|
|
82
83
|
"@size-limit/preset-small-lib": "5.0.1",
|
|
83
84
|
"@storybook/addon-a11y": "6.4.19",
|
|
@@ -86,7 +87,6 @@
|
|
|
86
87
|
"@storybook/addon-essentials": "6.4.19",
|
|
87
88
|
"@storybook/addon-jest": "6.4.19",
|
|
88
89
|
"@storybook/addon-links": "6.4.19",
|
|
89
|
-
"@storybook/addon-queryparams": "6.2.9",
|
|
90
90
|
"@storybook/addons": "6.4.19",
|
|
91
91
|
"@storybook/react": "6.4.19",
|
|
92
92
|
"@svgr/rollup": "5.5.0",
|
|
@@ -124,12 +124,11 @@
|
|
|
124
124
|
"node-sass-glob-importer": "5.3.2",
|
|
125
125
|
"normalize.css": "8.0.1",
|
|
126
126
|
"prettier": "2.4.1",
|
|
127
|
-
"react": "
|
|
127
|
+
"react": "17.0.2",
|
|
128
128
|
"react-autosuggest": "10.0.2",
|
|
129
|
-
"react-docgen-typescript-loader": "3.
|
|
130
|
-
"react-dom": "
|
|
131
|
-
"react-
|
|
132
|
-
"react-test-renderer": "16.14.0",
|
|
129
|
+
"react-docgen-typescript-loader": "3.7.2",
|
|
130
|
+
"react-dom": "17.0.2",
|
|
131
|
+
"react-test-renderer": "17.0.2",
|
|
133
132
|
"rollup-plugin-postcss": "4.0.0",
|
|
134
133
|
"rollup-plugin-svg": "2.0.0",
|
|
135
134
|
"sass": "1.35.1",
|
package/src/__tests__/setup.ts
CHANGED
|
@@ -14,10 +14,10 @@ const exposedProperties = ["window", "navigator", "document"];
|
|
|
14
14
|
|
|
15
15
|
(global as any).window = window;
|
|
16
16
|
(global as any).document = window.document;
|
|
17
|
-
Object.keys(document.defaultView).forEach((property) => {
|
|
18
|
-
if (typeof global[property] === "undefined") {
|
|
17
|
+
Object.keys((document as Document).defaultView).forEach((property) => {
|
|
18
|
+
if (typeof (global as any)[property] === "undefined") {
|
|
19
19
|
exposedProperties.push(property);
|
|
20
|
-
global[property] = document.defaultView[property];
|
|
20
|
+
(global as any)[property] = (document as any).defaultView[property];
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ButtonTypes } from "../../components/Button/ButtonTypes";
|
|
1
|
+
import { range } from "../../utils/utils";
|
|
3
2
|
|
|
4
3
|
describe("range", () => {
|
|
5
4
|
it("returns an array of values not including the stop argument", () => {
|
|
@@ -17,24 +16,3 @@ describe("range", () => {
|
|
|
17
16
|
expect(range(2, 20, 5)).toEqual([2, 7, 12, 17]);
|
|
18
17
|
});
|
|
19
18
|
});
|
|
20
|
-
|
|
21
|
-
describe("getStorybookEnumValues", () => {
|
|
22
|
-
const enumValues = getStorybookEnumValues(ButtonTypes, "ButtonTypes");
|
|
23
|
-
|
|
24
|
-
it("returns an array of values from the enum passed", () => {
|
|
25
|
-
expect(enumValues.options).toEqual([
|
|
26
|
-
"ButtonTypes.Primary",
|
|
27
|
-
"ButtonTypes.Secondary",
|
|
28
|
-
"ButtonTypes.Callout",
|
|
29
|
-
"ButtonTypes.Pill",
|
|
30
|
-
"ButtonTypes.Link",
|
|
31
|
-
"ButtonTypes.NoBrand",
|
|
32
|
-
]);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("returns a function with the value of the argument passed", () => {
|
|
36
|
-
expect(enumValues.getValue("ButtonTypes.Primary")).toEqual("primary");
|
|
37
|
-
expect(enumValues.getValue("ButtonTypes.Callout")).toEqual("callout");
|
|
38
|
-
expect(enumValues.getValue("ButtonTypes.NoBrand")).toEqual("noBrand");
|
|
39
|
-
});
|
|
40
|
-
});
|
|
@@ -13,20 +13,28 @@ import { getCategory } from "../../utils/componentCategories";
|
|
|
13
13
|
|
|
14
14
|
## General Information
|
|
15
15
|
|
|
16
|
-
An application's "skip navigation
|
|
17
|
-
content of a page. This
|
|
18
|
-
visually hidden until a user focuses on the link.
|
|
19
|
-
NYPL, the
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
An application's "skip navigation" is used to skip to the primary or main
|
|
17
|
+
content of a page. This component usually contains one link that is located at
|
|
18
|
+
the top of the page and is visually hidden until a user focuses on the link.
|
|
19
|
+
In the case of NYPL applications, the skip navigation contains two links; the
|
|
20
|
+
first link points to the main content of the page and the second link points to
|
|
21
|
+
accessibility information on [NYPL.org/accessibility](https://nypl.org/accessibility).
|
|
22
|
+
For most digitial applications on the NYPL.org platform, the [NYPL Header](https://github.com/NYPL/dgx-header-component)
|
|
23
|
+
is used and this component already renders a skip navigation area with links.
|
|
24
|
+
|
|
25
|
+
In the Reservoir Design System (DS), the `SkipNavigation` component renders two
|
|
26
|
+
links.
|
|
27
|
+
|
|
28
|
+
The first link points to the `"#mainContent"` anchor which an NYPL page
|
|
29
|
+
is expected to have. The `TemplateAppContainer` component renders as a `main`
|
|
30
|
+
HTML element with a default `id` of `"mainContent"`. While it's possible to
|
|
31
|
+
update the target of the skip link and the id of the `<main>` element, this is
|
|
32
|
+
not recommended. When using the DS' `SkipNavigation` and `TemplateAppContainer`
|
|
33
|
+
components, this accessibility combination is automatically handled. When not
|
|
34
|
+
using the `TemplateAppContainer` component, make sure to render a `main` HTML
|
|
35
|
+
element with an `id` of `"mainContent"`.
|
|
36
|
+
|
|
37
|
+
The second link points to additional accessibility information on [NYPL.org/accessibility](https://nypl.org/accessibility).
|
|
30
38
|
|
|
31
39
|
## Resources
|
|
32
40
|
|
|
@@ -9,11 +9,7 @@ import ReactDOMServer from "react-dom/server";
|
|
|
9
9
|
import { withDesign } from "storybook-addon-designs";
|
|
10
10
|
|
|
11
11
|
import Accordion from "./Accordion";
|
|
12
|
-
import { AccordionTypes } from "./AccordionTypes";
|
|
13
12
|
import Card, { CardHeading, CardContent } from "../Card/Card";
|
|
14
|
-
import { HeadingLevels } from "../Heading/HeadingTypes";
|
|
15
|
-
import { ImageRatios } from "../Image/ImageTypes";
|
|
16
|
-
import { LayoutTypes } from "../../helpers/enums";
|
|
17
13
|
import { getCategory } from "../../utils/componentCategories";
|
|
18
14
|
|
|
19
15
|
<Meta
|
|
@@ -39,7 +35,7 @@ import { getCategory } from "../../utils/componentCategories";
|
|
|
39
35
|
| Component Version | DS Version |
|
|
40
36
|
| ----------------- | ---------- |
|
|
41
37
|
| Added | `0.1.0` |
|
|
42
|
-
| Latest | `0.
|
|
38
|
+
| Latest | `0.28.0` |
|
|
43
39
|
|
|
44
40
|
## Table of Contents
|
|
45
41
|
|
|
@@ -66,22 +62,25 @@ Note that you can pass in a string or DOM elements into the `panel` property in
|
|
|
66
62
|
object. This approach is needed because, internally, we deal with the logic to render
|
|
67
63
|
the necessary icon, Chakra components, and styles. Additionally, the `accordionType`
|
|
68
64
|
prop can be used to change the accordion button's background color. It takes a value
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
of `"default"` for `"ui.white"`, `"warning"` for `"ui.status.primary"`, and
|
|
66
|
+
`"error"` for `"ui.status.secondary"`.
|
|
71
67
|
|
|
72
68
|
```jsx
|
|
73
69
|
const accordionData = [
|
|
74
70
|
{
|
|
71
|
+
accordionType: "default",
|
|
75
72
|
label: "Tom Nook",
|
|
76
73
|
panel: (
|
|
77
74
|
<Card
|
|
78
|
-
layout=
|
|
75
|
+
layout="row"
|
|
79
76
|
center
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
imageProps={{
|
|
78
|
+
alt: "Alt text",
|
|
79
|
+
aspectRatio: "twoByOne",
|
|
80
|
+
src: "https://play.nintendo.com/images/AC_Tom_FRYtwIN.17345b1513ac044897cfc243542899dce541e8dc.9afde10b.png",
|
|
81
|
+
}}
|
|
83
82
|
>
|
|
84
|
-
<CardHeading level=
|
|
83
|
+
<CardHeading level="four" id="heading1">
|
|
85
84
|
Tom Nook
|
|
86
85
|
</CardHeading>
|
|
87
86
|
<CardContent>
|
|
@@ -107,19 +106,19 @@ const accordionData = [
|
|
|
107
106
|
args={{
|
|
108
107
|
accordionData: [
|
|
109
108
|
{
|
|
110
|
-
accordionType:
|
|
109
|
+
accordionType: "default",
|
|
111
110
|
label: "Tom Nook",
|
|
112
111
|
panel: (
|
|
113
112
|
<Card
|
|
114
113
|
imageProps={{
|
|
115
114
|
alt: "Alt text",
|
|
116
|
-
aspectRatio:
|
|
115
|
+
aspectRatio: "twoByOne",
|
|
117
116
|
src: "https://play.nintendo.com/images/AC_Tom_FRYtwIN.17345b1513ac044897cfc243542899dce541e8dc.9afde10b.png",
|
|
118
117
|
}}
|
|
119
118
|
isCentered
|
|
120
|
-
layout=
|
|
119
|
+
layout="row"
|
|
121
120
|
>
|
|
122
|
-
<CardHeading level=
|
|
121
|
+
<CardHeading level="four" id="heading1">
|
|
123
122
|
Tom Nook
|
|
124
123
|
</CardHeading>
|
|
125
124
|
<CardContent>
|
|
@@ -144,19 +143,19 @@ const accordionData = [
|
|
|
144
143
|
```jsx
|
|
145
144
|
const accordionData = [
|
|
146
145
|
{
|
|
147
|
-
accordionType:
|
|
146
|
+
accordionType: "default",
|
|
148
147
|
label: "Tom Nook",
|
|
149
148
|
panel: (
|
|
150
149
|
<Card
|
|
151
150
|
imageProps={{
|
|
152
151
|
alt: "Alt text",
|
|
153
|
-
aspectRatio:
|
|
152
|
+
aspectRatio: "twoByOne",
|
|
154
153
|
src: "https://play.nintendo.com/images/AC_Tom_FRYtwIN.17345b1513ac044897cfc243542899dce541e8dc.9afde10b.png",
|
|
155
154
|
}}
|
|
156
155
|
isCentered
|
|
157
|
-
layout=
|
|
156
|
+
layout="row"
|
|
158
157
|
>
|
|
159
|
-
<CardHeading level=
|
|
158
|
+
<CardHeading level="four" id="heading1">
|
|
160
159
|
Tom Nook
|
|
161
160
|
</CardHeading>
|
|
162
161
|
<CardContent>
|
|
@@ -192,19 +191,19 @@ Resources:
|
|
|
192
191
|
|
|
193
192
|
export const faqContent = [
|
|
194
193
|
{
|
|
195
|
-
accordionType:
|
|
194
|
+
accordionType: "default",
|
|
196
195
|
label: "Tom Nook",
|
|
197
196
|
panel: (
|
|
198
197
|
<Card
|
|
199
198
|
imageProps={{
|
|
200
199
|
alt: "Alt text",
|
|
201
|
-
aspectRatio:
|
|
200
|
+
aspectRatio: "twoByOne",
|
|
202
201
|
src: "https://play.nintendo.com/images/AC_Tom_FRYtwIN.17345b1513ac044897cfc243542899dce541e8dc.9afde10b.png",
|
|
203
202
|
}}
|
|
204
203
|
isCentered
|
|
205
|
-
layout=
|
|
204
|
+
layout="row"
|
|
206
205
|
>
|
|
207
|
-
<CardHeading level=
|
|
206
|
+
<CardHeading level="four" id="heading1-tom">
|
|
208
207
|
Tom Nook
|
|
209
208
|
</CardHeading>
|
|
210
209
|
<CardContent>
|
|
@@ -215,19 +214,19 @@ export const faqContent = [
|
|
|
215
214
|
),
|
|
216
215
|
},
|
|
217
216
|
{
|
|
218
|
-
accordionType:
|
|
217
|
+
accordionType: "warning",
|
|
219
218
|
label: "Isabelle",
|
|
220
219
|
panel: (
|
|
221
220
|
<Card
|
|
222
221
|
imageProps={{
|
|
223
222
|
alt: "Alt text",
|
|
224
|
-
aspectRatio:
|
|
223
|
+
aspectRatio: "twoByOne",
|
|
225
224
|
src: "https://play.nintendo.com/images/AC_Isabelle_7XU6aGu.17345b1513ac044897cfc243542899dce541e8dc.9afde10b.png",
|
|
226
225
|
}}
|
|
227
226
|
isCentered
|
|
228
|
-
layout=
|
|
227
|
+
layout="row"
|
|
229
228
|
>
|
|
230
|
-
<CardHeading level=
|
|
229
|
+
<CardHeading level="four" id="heading1-isabelle">
|
|
231
230
|
Isabelle
|
|
232
231
|
</CardHeading>
|
|
233
232
|
<CardContent>
|
|
@@ -240,19 +239,19 @@ export const faqContent = [
|
|
|
240
239
|
),
|
|
241
240
|
},
|
|
242
241
|
{
|
|
243
|
-
accordionType:
|
|
242
|
+
accordionType: "error",
|
|
244
243
|
label: "K.K. Slider",
|
|
245
244
|
panel: (
|
|
246
245
|
<Card
|
|
247
246
|
imageProps={{
|
|
248
247
|
alt: "Alt text",
|
|
249
|
-
aspectRatio:
|
|
248
|
+
aspectRatio: "twoByOne",
|
|
250
249
|
src: "https://play.nintendo.com/images/AC_KK_jh4yj5t.17345b1513ac044897cfc243542899dce541e8dc.9afde10b.png",
|
|
251
250
|
}}
|
|
252
251
|
isCentered
|
|
253
|
-
layout=
|
|
252
|
+
layout="row"
|
|
254
253
|
>
|
|
255
|
-
<CardHeading level=
|
|
254
|
+
<CardHeading level="four" id="heading1-kkslider">
|
|
256
255
|
K.K. Slider
|
|
257
256
|
</CardHeading>
|
|
258
257
|
<CardContent>
|
|
@@ -280,19 +279,19 @@ one object in the array passed into the `accordionData` prop.
|
|
|
280
279
|
```jsx
|
|
281
280
|
export const faqContent = [
|
|
282
281
|
{
|
|
283
|
-
accordionType:
|
|
282
|
+
accordionType: "default",
|
|
284
283
|
label: "Tom Nook",
|
|
285
284
|
panel: (
|
|
286
285
|
<Card
|
|
287
286
|
imageProps={{
|
|
288
287
|
alt: "Alt text",
|
|
289
|
-
aspectRatio:
|
|
288
|
+
aspectRatio: "twoByOne",
|
|
290
289
|
src: "https://play.nintendo.com/images/AC_Tom_FRYtwIN.17345b1513ac044897cfc243542899dce541e8dc.9afde10b.png",
|
|
291
290
|
}}
|
|
292
291
|
isCentered
|
|
293
|
-
layout=
|
|
292
|
+
layout="row"
|
|
294
293
|
>
|
|
295
|
-
<CardHeading level=
|
|
294
|
+
<CardHeading level="four" id="heading1-tom">
|
|
296
295
|
Tom Nook
|
|
297
296
|
</CardHeading>
|
|
298
297
|
<CardContent>
|
|
@@ -303,19 +302,19 @@ export const faqContent = [
|
|
|
303
302
|
),
|
|
304
303
|
},
|
|
305
304
|
{
|
|
306
|
-
accordionType:
|
|
305
|
+
accordionType: "warning",
|
|
307
306
|
label: "Isabelle",
|
|
308
307
|
panel: (
|
|
309
308
|
<Card
|
|
310
309
|
imageProps={{
|
|
311
310
|
alt: "Alt text",
|
|
312
|
-
aspectRatio:
|
|
311
|
+
aspectRatio: "twoByOne",
|
|
313
312
|
src: "https://play.nintendo.com/images/AC_Isabelle_7XU6aGu.17345b1513ac044897cfc243542899dce541e8dc.9afde10b.png",
|
|
314
313
|
}}
|
|
315
314
|
isCentered
|
|
316
|
-
layout=
|
|
315
|
+
layout="row"
|
|
317
316
|
>
|
|
318
|
-
<CardHeading level=
|
|
317
|
+
<CardHeading level="four" id="heading1-isabelle">
|
|
319
318
|
Isabelle
|
|
320
319
|
</CardHeading>
|
|
321
320
|
<CardContent>
|
|
@@ -328,19 +327,19 @@ export const faqContent = [
|
|
|
328
327
|
),
|
|
329
328
|
},
|
|
330
329
|
{
|
|
331
|
-
accordionType:
|
|
330
|
+
accordionType: "error",
|
|
332
331
|
label: "K.K. Slider",
|
|
333
332
|
panel: (
|
|
334
333
|
<Card
|
|
335
334
|
imageProps={{
|
|
336
335
|
alt: "Alt text",
|
|
337
|
-
aspectRatio:
|
|
336
|
+
aspectRatio: "twoByOne",
|
|
338
337
|
src: "https://play.nintendo.com/images/AC_KK_jh4yj5t.17345b1513ac044897cfc243542899dce541e8dc.9afde10b.png",
|
|
339
338
|
}}
|
|
340
339
|
isCentered
|
|
341
|
-
layout=
|
|
340
|
+
layout="row"
|
|
342
341
|
>
|
|
343
|
-
<CardHeading level=
|
|
342
|
+
<CardHeading level="four" id="heading1-kkslider">
|
|
344
343
|
K.K. Slider
|
|
345
344
|
</CardHeading>
|
|
346
345
|
<CardContent>
|
|
@@ -5,11 +5,7 @@ import renderer from "react-test-renderer";
|
|
|
5
5
|
import userEvent from "@testing-library/user-event";
|
|
6
6
|
|
|
7
7
|
import Accordion from "./Accordion";
|
|
8
|
-
import { AccordionTypes } from "./AccordionTypes";
|
|
9
8
|
import Card, { CardContent, CardHeading } from "../Card/Card";
|
|
10
|
-
import { HeadingLevels } from "../Heading/HeadingTypes";
|
|
11
|
-
import { ImageRatios } from "../Image/ImageTypes";
|
|
12
|
-
import { LayoutTypes } from "../../helpers/enums";
|
|
13
9
|
|
|
14
10
|
describe("Accordion Accessibility", () => {
|
|
15
11
|
it("passes axe accessibility test for one item", async () => {
|
|
@@ -166,13 +162,13 @@ describe("Accordion", () => {
|
|
|
166
162
|
id="card"
|
|
167
163
|
imageProps={{
|
|
168
164
|
alt: "Alt text",
|
|
169
|
-
aspectRatio:
|
|
165
|
+
aspectRatio: "twoByOne",
|
|
170
166
|
src: "https://cdn.onebauer.media/one/media/6176/76fd/405b/ab5f/f20f/2d52/gerri-1500-1.jpg?format=jpg&quality=80&width=850&ratio=1-1&resize=aspectfit",
|
|
171
167
|
}}
|
|
172
168
|
isCentered
|
|
173
|
-
layout=
|
|
169
|
+
layout="row"
|
|
174
170
|
>
|
|
175
|
-
<CardHeading id="heading1" level=
|
|
171
|
+
<CardHeading id="heading1" level="four">
|
|
176
172
|
Gerry Kellman
|
|
177
173
|
</CardHeading>
|
|
178
174
|
<CardContent>
|
|
@@ -196,9 +192,7 @@ describe("Accordion", () => {
|
|
|
196
192
|
const withError = renderer
|
|
197
193
|
.create(
|
|
198
194
|
<Accordion
|
|
199
|
-
accordionData={[
|
|
200
|
-
{ ...accordionData[0], accordionType: AccordionTypes.Error },
|
|
201
|
-
]}
|
|
195
|
+
accordionData={[{ ...accordionData[0], accordionType: "error" }]}
|
|
202
196
|
id="accordian"
|
|
203
197
|
isDefaultOpen
|
|
204
198
|
/>
|
|
@@ -207,9 +201,7 @@ describe("Accordion", () => {
|
|
|
207
201
|
const withWarning = renderer
|
|
208
202
|
.create(
|
|
209
203
|
<Accordion
|
|
210
|
-
accordionData={[
|
|
211
|
-
{ ...accordionData[0], accordionType: AccordionTypes.Warning },
|
|
212
|
-
]}
|
|
204
|
+
accordionData={[{ ...accordionData[0], accordionType: "warning" }]}
|
|
213
205
|
id="accordian"
|
|
214
206
|
isDefaultOpen
|
|
215
207
|
/>
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Accordion as ChakraAccordion,
|
|
3
|
-
AccordionItem,
|
|
4
3
|
AccordionButton,
|
|
4
|
+
AccordionItem,
|
|
5
5
|
AccordionPanel,
|
|
6
6
|
Box,
|
|
7
7
|
chakra,
|
|
8
8
|
} from "@chakra-ui/react";
|
|
9
9
|
import * as React from "react";
|
|
10
10
|
|
|
11
|
-
import { AccordionTypes } from "./AccordionTypes";
|
|
12
11
|
import Icon from "../Icons/Icon";
|
|
13
|
-
|
|
12
|
+
|
|
13
|
+
export type AccordionTypes = "default" | "warning" | "error";
|
|
14
14
|
export interface AccordionDataProps {
|
|
15
15
|
accordionType?: AccordionTypes;
|
|
16
16
|
label: string;
|
|
17
17
|
panel: string | React.ReactNode;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
19
|
export interface AccordionProps {
|
|
21
20
|
/** Array of data to display, and an optional accordionType */
|
|
22
21
|
accordionData: AccordionDataProps[];
|
|
@@ -30,14 +29,10 @@ export interface AccordionProps {
|
|
|
30
29
|
* Get the minus or plus icon depending on whether the accordion
|
|
31
30
|
* is open or closed.
|
|
32
31
|
*/
|
|
33
|
-
const getIcon = (isExpanded = false, index, id) => {
|
|
34
|
-
const iconName = isExpanded ?
|
|
32
|
+
const getIcon = (isExpanded = false, index: number, id: string) => {
|
|
33
|
+
const iconName = isExpanded ? "minus" : "plus";
|
|
35
34
|
return (
|
|
36
|
-
<Icon
|
|
37
|
-
id={`accordion-${id}-icon-${index}`}
|
|
38
|
-
name={iconName}
|
|
39
|
-
size={IconSizes.Small}
|
|
40
|
-
/>
|
|
35
|
+
<Icon id={`accordion-${id}-icon-${index}`} name={iconName} size="small" />
|
|
41
36
|
);
|
|
42
37
|
};
|
|
43
38
|
|
|
@@ -46,15 +41,15 @@ const getIcon = (isExpanded = false, index, id) => {
|
|
|
46
41
|
* array. This automatically creates the `AccordionButton` and `AccordionPanel`
|
|
47
42
|
* combination that is required for the Chakra `Accordion` component.
|
|
48
43
|
*/
|
|
49
|
-
const getElementsFromData = (data = [], id) => {
|
|
44
|
+
const getElementsFromData = (data: AccordionDataProps[] = [], id: string) => {
|
|
50
45
|
const colorMap = {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
default: "ui.white",
|
|
47
|
+
warning: "ui.status.primary",
|
|
48
|
+
error: "ui.status.secondary",
|
|
54
49
|
};
|
|
55
50
|
// For FAQ-style multiple accordions, the button should be bigger.
|
|
56
51
|
// Otherwise, use the default.
|
|
57
|
-
const multiplePadding = data?.length > 1 ? 4 :
|
|
52
|
+
const multiplePadding = data?.length > 1 ? "4" : "initial";
|
|
58
53
|
|
|
59
54
|
return data.map((content, index) => {
|
|
60
55
|
// This is done to support both string and DOM element input.
|
|
@@ -124,11 +119,12 @@ export const Accordion = chakra((props: AccordionProps) => {
|
|
|
124
119
|
const { accordionData, id, isDefaultOpen = false, ...rest } = props;
|
|
125
120
|
|
|
126
121
|
// Pass `0` to open the first accordion in the 0-index based array.
|
|
127
|
-
const openFirstAccordion = isDefaultOpen ? 0 : undefined;
|
|
122
|
+
const openFirstAccordion = isDefaultOpen ? [0] : undefined;
|
|
123
|
+
|
|
128
124
|
return (
|
|
129
125
|
<ChakraAccordion
|
|
130
126
|
id={id}
|
|
131
|
-
defaultIndex={
|
|
127
|
+
defaultIndex={openFirstAccordion}
|
|
132
128
|
allowMultiple
|
|
133
129
|
{...rest}
|
|
134
130
|
>
|