@nypl/design-system-react-components 0.25.12 → 0.25.13
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 +63 -1
- package/dist/components/Accordion/Accordion.d.ts +5 -3
- package/dist/components/Accordion/AccordionTypes.d.ts +5 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +3 -3
- package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +1 -1
- package/dist/components/Card/Card.d.ts +11 -20
- package/dist/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +4 -2
- package/dist/components/Heading/Heading.d.ts +4 -4
- package/dist/components/Heading/HeadingTypes.d.ts +1 -1
- package/dist/components/Hero/Hero.d.ts +7 -4
- package/dist/components/Icons/IconTypes.d.ts +1 -0
- package/dist/components/Image/Image.d.ts +25 -7
- package/dist/components/Image/ImageTypes.d.ts +4 -4
- package/dist/components/Logo/LogoTypes.d.ts +2 -2
- package/dist/components/Notification/Notification.d.ts +4 -4
- package/dist/components/Radio/Radio.d.ts +1 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +4 -2
- package/dist/components/Select/Select.d.ts +2 -2
- package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -3
- package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +0 -4
- package/dist/components/StructuredContent/StructuredContent.d.ts +9 -22
- package/dist/components/Tabs/Tabs.d.ts +3 -3
- package/dist/components/Template/Template.d.ts +13 -5
- package/dist/components/Text/Text.d.ts +3 -3
- package/dist/components/Text/TextTypes.d.ts +1 -1
- package/dist/components/TextInput/TextInput.d.ts +2 -2
- package/dist/components/Toggle/Toggle.d.ts +6 -7
- package/dist/components/Toggle/{ToggleSizes.d.ts → ToggleTypes.d.ts} +1 -1
- package/dist/design-system-react-components.cjs.development.js +505 -422
- 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 +514 -435
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/helpers/enums.d.ts +4 -0
- package/dist/index.d.ts +7 -8
- package/dist/theme/components/accordion.d.ts +7 -12
- package/dist/theme/components/breadcrumb.d.ts +3 -0
- package/dist/theme/components/card.d.ts +4 -4
- package/dist/theme/components/checkbox.d.ts +1 -0
- package/dist/theme/components/checkboxGroup.d.ts +3 -1
- package/dist/theme/components/global.d.ts +2 -1
- package/dist/theme/components/hero.d.ts +1 -1
- package/dist/theme/components/image.d.ts +1 -1
- package/dist/theme/components/notification.d.ts +4 -4
- package/dist/theme/components/pagination.d.ts +2 -5
- package/dist/theme/components/radio.d.ts +1 -0
- package/dist/theme/components/radioGroup.d.ts +3 -1
- package/dist/theme/components/select.d.ts +3 -0
- package/dist/theme/components/toggle.d.ts +13 -1
- package/package.json +1 -1
- package/src/components/AccessibilityGuide/SkipNavigation.stories.mdx +34 -0
- package/src/components/Accordion/Accordion.stories.mdx +150 -66
- package/src/components/Accordion/Accordion.test.tsx +44 -17
- package/src/components/Accordion/Accordion.tsx +50 -20
- package/src/components/Accordion/AccordionTypes.tsx +5 -0
- package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +244 -2
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +17 -15
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +6 -6
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +6 -6
- package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +1 -1
- package/src/components/Card/Card.stories.mdx +236 -165
- package/src/components/Card/Card.test.tsx +36 -18
- package/src/components/Card/Card.tsx +84 -59
- package/src/components/Card/__snapshots__/Card.test.tsx.snap +25 -65
- package/src/components/Chakra/Center.stories.mdx +2 -2
- package/src/components/Checkbox/Checkbox.stories.mdx +13 -1
- package/src/components/Checkbox/Checkbox.test.tsx +58 -2
- package/src/components/Checkbox/Checkbox.tsx +6 -1
- package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +76 -0
- package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +73 -9
- package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +79 -9
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +10 -7
- package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +169 -0
- package/src/components/ComponentWrapper/ComponentWrapper.tsx +1 -1
- package/src/components/DatePicker/DatePicker.test.tsx +5 -2
- package/src/components/DatePicker/DatePicker.tsx +5 -2
- package/src/components/Form/Form.stories.mdx +47 -9
- package/src/components/Form/Form.test.tsx +1 -1
- package/src/components/Form/Form.tsx +3 -1
- package/src/components/Grid/SimpleGrid.stories.mdx +53 -35
- package/src/components/Grid/SimpleGrid.test.tsx +15 -9
- package/src/components/Heading/Heading.stories.mdx +21 -23
- package/src/components/Heading/Heading.test.tsx +7 -7
- package/src/components/Heading/Heading.tsx +10 -14
- package/src/components/Heading/HeadingTypes.tsx +1 -1
- package/src/components/Heading/__snapshots__/Heading.test.tsx.snap +1 -1
- package/src/components/Hero/Hero.stories.mdx +27 -27
- package/src/components/Hero/Hero.test.tsx +113 -58
- package/src/components/Hero/Hero.tsx +43 -20
- package/src/components/HorizontalRule/HorizontalRule.test.tsx +6 -4
- package/src/components/HorizontalRule/HorizontalRule.tsx +3 -2
- package/src/components/Icons/Icon.stories.mdx +50 -18
- package/src/components/Icons/Icon.test.tsx +13 -2
- package/src/components/Icons/Icon.tsx +11 -6
- package/src/components/Icons/IconTypes.tsx +1 -0
- package/src/components/Image/Image.stories.mdx +133 -68
- package/src/components/Image/Image.test.tsx +32 -48
- package/src/components/Image/Image.tsx +46 -26
- package/src/components/Image/ImageTypes.ts +4 -4
- package/src/components/Image/__snapshots__/Image.test.tsx.snap +60 -13
- package/src/components/Link/Link.tsx +8 -1
- package/src/components/List/List.stories.mdx +1 -1
- package/src/components/List/List.test.tsx +7 -4
- package/src/components/List/List.tsx +7 -4
- package/src/components/Logo/Logo.stories.mdx +13 -13
- package/src/components/Logo/Logo.test.tsx +12 -2
- package/src/components/Logo/Logo.tsx +10 -5
- package/src/components/Logo/LogoTypes.tsx +1 -1
- package/src/components/Notification/Notification.stories.mdx +5 -5
- package/src/components/Notification/Notification.tsx +10 -10
- package/src/components/Pagination/Pagination.stories.mdx +4 -3
- package/src/components/Pagination/Pagination.test.tsx +30 -2
- package/src/components/Pagination/Pagination.tsx +6 -3
- package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +1 -1
- package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +6 -2
- package/src/components/ProgressIndicator/ProgressIndicator.tsx +3 -1
- package/src/components/Radio/Radio.stories.mdx +13 -1
- package/src/components/Radio/Radio.test.tsx +56 -2
- package/src/components/Radio/Radio.tsx +6 -1
- package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +61 -0
- package/src/components/RadioGroup/RadioGroup.stories.mdx +73 -9
- package/src/components/RadioGroup/RadioGroup.test.tsx +72 -7
- package/src/components/RadioGroup/RadioGroup.tsx +10 -7
- package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +140 -0
- package/src/components/SearchBar/SearchBar.stories.mdx +1 -1
- package/src/components/SearchBar/SearchBar.tsx +3 -3
- package/src/components/Select/Select.stories.mdx +26 -16
- package/src/components/Select/Select.test.tsx +1 -36
- package/src/components/Select/Select.tsx +4 -16
- package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +12 -14
- package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +6 -8
- package/src/components/SkeletonLoader/SkeletonLoader.tsx +5 -7
- package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +0 -5
- package/src/components/Slider/Slider.stories.mdx +41 -8
- package/src/components/Slider/Slider.tsx +4 -4
- package/src/components/StatusBadge/StatusBadge.test.tsx +3 -1
- package/src/components/StatusBadge/StatusBadge.tsx +1 -1
- package/src/components/StructuredContent/StructuredContent.stories.mdx +103 -54
- package/src/components/StructuredContent/StructuredContent.test.tsx +129 -102
- package/src/components/StructuredContent/StructuredContent.tsx +43 -53
- package/src/components/StyleGuide/ColorCard.tsx +3 -3
- package/src/components/StyleGuide/Typography.stories.mdx +17 -12
- package/src/components/Table/Table.test.tsx +1 -1
- package/src/components/Table/Table.tsx +3 -1
- package/src/components/Tabs/Tabs.stories.mdx +8 -8
- package/src/components/Tabs/Tabs.test.tsx +13 -11
- package/src/components/Tabs/Tabs.tsx +18 -15
- package/src/components/Template/Template.stories.mdx +62 -25
- package/src/components/Template/Template.test.tsx +35 -5
- package/src/components/Template/Template.tsx +26 -13
- package/src/components/Template/__snapshots__/Template.test.tsx.snap +4 -2
- package/src/components/Text/Text.stories.mdx +13 -15
- package/src/components/Text/Text.test.tsx +6 -15
- package/src/components/Text/Text.tsx +7 -12
- package/src/components/Text/TextTypes.tsx +1 -1
- package/src/components/TextInput/TextInput.stories.mdx +9 -9
- package/src/components/TextInput/TextInput.test.tsx +28 -27
- package/src/components/TextInput/TextInput.tsx +4 -4
- package/src/components/Toggle/Toggle.stories.mdx +12 -22
- package/src/components/Toggle/Toggle.test.tsx +15 -2
- package/src/components/Toggle/Toggle.tsx +8 -9
- package/src/components/Toggle/{ToggleSizes.tsx → ToggleTypes.tsx} +1 -1
- package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +64 -0
- package/src/components/VideoPlayer/VideoPlayer.test.tsx +18 -6
- package/src/components/VideoPlayer/VideoPlayer.tsx +14 -7
- package/src/docs/{Intro.stories.mdx → Welcome.stories.mdx} +5 -9
- package/src/{components/Card/CardTypes.tsx → helpers/enums.ts} +2 -2
- package/src/hooks/tests/useNYPLTheme.test.tsx +1 -1
- package/src/hooks/useCarouselStyles.stories.mdx +10 -0
- package/src/hooks/useNYPLTheme.ts +1 -1
- package/src/index.ts +7 -14
- package/src/theme/components/accordion.ts +7 -12
- package/src/theme/components/breadcrumb.ts +3 -0
- package/src/theme/components/card.ts +29 -20
- package/src/theme/components/checkboxGroup.ts +3 -1
- package/src/theme/components/global.ts +4 -3
- package/src/theme/components/hero.ts +1 -1
- package/src/theme/components/icon.ts +5 -2
- package/src/theme/components/image.ts +1 -1
- package/src/theme/components/list.ts +1 -1
- package/src/theme/components/notification.ts +5 -5
- package/src/theme/components/pagination.ts +2 -5
- package/src/theme/components/progressIndicator.ts +3 -3
- package/src/theme/components/radioGroup.ts +3 -1
- package/src/theme/components/select.ts +6 -0
- package/src/theme/components/toggle.ts +26 -3
- package/src/utils/componentCategories.ts +27 -19
- package/dist/components/Card/CardTypes.d.ts +0 -4
- package/dist/components/CheckboxGroup/CheckboxGroupLayoutTypes.d.ts +0 -4
- package/dist/components/RadioGroup/RadioGroupLayoutTypes.d.ts +0 -4
- package/src/components/CheckboxGroup/CheckboxGroupLayoutTypes.tsx +0 -4
- package/src/components/RadioGroup/RadioGroupLayoutTypes.tsx +0 -4
|
@@ -3,15 +3,37 @@ import * as React from "react";
|
|
|
3
3
|
|
|
4
4
|
import { ImageRatios, ImageSizes, ImageTypes } from "./ImageTypes";
|
|
5
5
|
|
|
6
|
+
// Used for components that have an `imageProps` prop.
|
|
7
|
+
export interface ComponentImageProps {
|
|
8
|
+
/** String value used to populate the `alt` attribute of the internal `Image`
|
|
9
|
+
* component's `img` element. @NOTE if an image is used, this value must be passed. */
|
|
10
|
+
alt?: string;
|
|
11
|
+
/** Optional value to control the aspect ratio of the internal `Image` component.
|
|
12
|
+
* Defaults to `ImageRatios.Square`. */
|
|
13
|
+
aspectRatio?: ImageRatios;
|
|
14
|
+
/** Optional value to render as a caption for the internal `Image` component. */
|
|
15
|
+
caption?: string;
|
|
16
|
+
/** Optional DOM element to use instead of the DS `Image` component. */
|
|
17
|
+
component?: JSX.Element;
|
|
18
|
+
/** Optional value to render as a credit for the internal `Image` component. */
|
|
19
|
+
credit?: string;
|
|
20
|
+
/** Optional value to control the size of the internal `Image` component.
|
|
21
|
+
* Defaults to `ImageSizes.Medium`. */
|
|
22
|
+
size?: ImageSizes;
|
|
23
|
+
/** Optional value that contains the path to an image. If omitted, the internal
|
|
24
|
+
* DS `Image` component will not render. */
|
|
25
|
+
src?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
6
28
|
interface ImageWrapperProps {
|
|
7
29
|
/** Optionally pass in additional Chakra-based styles. */
|
|
8
30
|
additionalWrapperStyles?: { [key: string]: any };
|
|
9
31
|
/** ClassName you can add in addition to 'image' */
|
|
10
32
|
className?: string;
|
|
11
33
|
/** Optional value to control the aspect ratio of the cartd image; default value is `square` */
|
|
12
|
-
|
|
34
|
+
aspectRatio?: ImageRatios;
|
|
13
35
|
/** Optional value to control the size of the image */
|
|
14
|
-
|
|
36
|
+
size?: ImageSizes;
|
|
15
37
|
}
|
|
16
38
|
|
|
17
39
|
export interface ImageProps extends ImageWrapperProps {
|
|
@@ -21,14 +43,12 @@ export interface ImageProps extends ImageWrapperProps {
|
|
|
21
43
|
additionalImageStyles?: { [key: string]: any };
|
|
22
44
|
/** Alternate text description of the image */
|
|
23
45
|
alt: string;
|
|
46
|
+
/** Adding will wrap the image in a <figure> */
|
|
47
|
+
caption?: string;
|
|
24
48
|
/** Custom image component */
|
|
25
49
|
component?: JSX.Element | null;
|
|
26
50
|
/** Adding will wrap the image in a <figure> */
|
|
27
|
-
|
|
28
|
-
/** Adding will wrap the image in a <figure> */
|
|
29
|
-
imageCredit?: string;
|
|
30
|
-
/** Optional value to control the size of the image */
|
|
31
|
-
imageSize?: ImageSizes;
|
|
51
|
+
credit?: string;
|
|
32
52
|
/** Optional value for the image type */
|
|
33
53
|
imageType?: ImageTypes;
|
|
34
54
|
/** The src attribute is required, and contains the path to the image you want to embed. */
|
|
@@ -40,12 +60,12 @@ function ImageWrapper(props: React.PropsWithChildren<ImageWrapperProps>) {
|
|
|
40
60
|
additionalWrapperStyles = {},
|
|
41
61
|
className = "",
|
|
42
62
|
children,
|
|
43
|
-
|
|
44
|
-
|
|
63
|
+
aspectRatio = ImageRatios.Original,
|
|
64
|
+
size = ImageSizes.Default,
|
|
45
65
|
} = props;
|
|
46
66
|
const styles = useMultiStyleConfig("CustomImageWrapper", {
|
|
47
|
-
ratio:
|
|
48
|
-
size
|
|
67
|
+
ratio: aspectRatio,
|
|
68
|
+
size,
|
|
49
69
|
});
|
|
50
70
|
return (
|
|
51
71
|
<Box
|
|
@@ -65,23 +85,25 @@ export default function Image(props: ImageProps) {
|
|
|
65
85
|
additionalImageStyles = {},
|
|
66
86
|
additionalWrapperStyles = {},
|
|
67
87
|
alt,
|
|
88
|
+
aspectRatio = ImageRatios.Original,
|
|
89
|
+
caption,
|
|
68
90
|
className = "",
|
|
69
91
|
component,
|
|
70
|
-
|
|
71
|
-
imageCaption,
|
|
72
|
-
imageCredit,
|
|
73
|
-
imageSize = ImageSizes.Default,
|
|
92
|
+
credit,
|
|
74
93
|
imageType = ImageTypes.Default,
|
|
94
|
+
size = ImageSizes.Default,
|
|
75
95
|
src,
|
|
76
96
|
} = props;
|
|
77
|
-
const useImageWrapper =
|
|
97
|
+
const useImageWrapper = aspectRatio !== ImageRatios.Original;
|
|
78
98
|
const styles = useMultiStyleConfig("CustomImage", {
|
|
79
99
|
variant: imageType,
|
|
80
|
-
size
|
|
100
|
+
size,
|
|
81
101
|
});
|
|
82
102
|
|
|
83
103
|
if (alt && alt.length > 300) {
|
|
84
|
-
throw new Error(
|
|
104
|
+
throw new Error(
|
|
105
|
+
"NYPL Reservoir Image: Alt text must be less than 300 characters."
|
|
106
|
+
);
|
|
85
107
|
}
|
|
86
108
|
|
|
87
109
|
const imageComponent: JSX.Element = component ? (
|
|
@@ -96,10 +118,10 @@ export default function Image(props: ImageProps) {
|
|
|
96
118
|
);
|
|
97
119
|
const finalImage = useImageWrapper ? (
|
|
98
120
|
<ImageWrapper
|
|
99
|
-
className={className}
|
|
100
|
-
imageAspectRatio={imageAspectRatio}
|
|
101
|
-
imageSize={imageSize}
|
|
102
121
|
additionalWrapperStyles={additionalWrapperStyles}
|
|
122
|
+
aspectRatio={aspectRatio}
|
|
123
|
+
className={className}
|
|
124
|
+
size={size}
|
|
103
125
|
>
|
|
104
126
|
{imageComponent}
|
|
105
127
|
</ImageWrapper>
|
|
@@ -107,14 +129,12 @@ export default function Image(props: ImageProps) {
|
|
|
107
129
|
imageComponent
|
|
108
130
|
);
|
|
109
131
|
|
|
110
|
-
return
|
|
132
|
+
return caption || credit ? (
|
|
111
133
|
<Box as="figure" __css={{ ...styles.figure, ...additionalFigureStyles }}>
|
|
112
134
|
{finalImage}
|
|
113
135
|
<Box as="figcaption" __css={styles.figcaption}>
|
|
114
|
-
{
|
|
115
|
-
|
|
116
|
-
)}
|
|
117
|
-
{imageCredit && <Box __css={styles.captionWrappers}>{imageCredit}</Box>}
|
|
136
|
+
{caption && <Box __css={styles.captionWrappers}>{caption}</Box>}
|
|
137
|
+
{credit && <Box __css={styles.captionWrappers}>{credit}</Box>}
|
|
118
138
|
</Box>
|
|
119
139
|
</Box>
|
|
120
140
|
) : (
|
|
@@ -11,11 +11,11 @@ export enum ImageRatios {
|
|
|
11
11
|
|
|
12
12
|
export enum ImageSizes {
|
|
13
13
|
Default = "default",
|
|
14
|
-
Large = "large",
|
|
15
|
-
Medium = "medium",
|
|
16
|
-
Small = "small",
|
|
17
|
-
ExtraSmall = "xsmall",
|
|
18
14
|
ExtraExtraSmall = "xxsmall",
|
|
15
|
+
ExtraSmall = "xsmall",
|
|
16
|
+
Small = "small",
|
|
17
|
+
Medium = "medium",
|
|
18
|
+
Large = "large",
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export enum ImageTypes {
|
|
@@ -30,6 +30,53 @@ exports[`Image Renders the UI snapshot correctly 2`] = `
|
|
|
30
30
|
`;
|
|
31
31
|
|
|
32
32
|
exports[`Image Renders the UI snapshot correctly 3`] = `
|
|
33
|
+
<figure
|
|
34
|
+
className="css-0"
|
|
35
|
+
>
|
|
36
|
+
<img
|
|
37
|
+
alt=""
|
|
38
|
+
className="css-0"
|
|
39
|
+
src="test.png"
|
|
40
|
+
/>
|
|
41
|
+
<figcaption
|
|
42
|
+
className="css-0"
|
|
43
|
+
>
|
|
44
|
+
<div
|
|
45
|
+
className="css-0"
|
|
46
|
+
>
|
|
47
|
+
Credit
|
|
48
|
+
</div>
|
|
49
|
+
</figcaption>
|
|
50
|
+
</figure>
|
|
51
|
+
`;
|
|
52
|
+
|
|
53
|
+
exports[`Image Renders the UI snapshot correctly 4`] = `
|
|
54
|
+
<figure
|
|
55
|
+
className="css-0"
|
|
56
|
+
>
|
|
57
|
+
<img
|
|
58
|
+
alt=""
|
|
59
|
+
className="css-0"
|
|
60
|
+
src="test.png"
|
|
61
|
+
/>
|
|
62
|
+
<figcaption
|
|
63
|
+
className="css-0"
|
|
64
|
+
>
|
|
65
|
+
<div
|
|
66
|
+
className="css-0"
|
|
67
|
+
>
|
|
68
|
+
Caption
|
|
69
|
+
</div>
|
|
70
|
+
<div
|
|
71
|
+
className="css-0"
|
|
72
|
+
>
|
|
73
|
+
Credit
|
|
74
|
+
</div>
|
|
75
|
+
</figcaption>
|
|
76
|
+
</figure>
|
|
77
|
+
`;
|
|
78
|
+
|
|
79
|
+
exports[`Image Renders the UI snapshot correctly 5`] = `
|
|
33
80
|
<img
|
|
34
81
|
alt=""
|
|
35
82
|
className="css-0"
|
|
@@ -37,7 +84,7 @@ exports[`Image Renders the UI snapshot correctly 3`] = `
|
|
|
37
84
|
/>
|
|
38
85
|
`;
|
|
39
86
|
|
|
40
|
-
exports[`Image Renders the UI snapshot correctly
|
|
87
|
+
exports[`Image Renders the UI snapshot correctly 6`] = `
|
|
41
88
|
<img
|
|
42
89
|
alt=""
|
|
43
90
|
className="css-0"
|
|
@@ -45,7 +92,7 @@ exports[`Image Renders the UI snapshot correctly 4`] = `
|
|
|
45
92
|
/>
|
|
46
93
|
`;
|
|
47
94
|
|
|
48
|
-
exports[`Image Renders the UI snapshot correctly
|
|
95
|
+
exports[`Image Renders the UI snapshot correctly 7`] = `
|
|
49
96
|
<img
|
|
50
97
|
alt=""
|
|
51
98
|
className="css-0"
|
|
@@ -53,7 +100,7 @@ exports[`Image Renders the UI snapshot correctly 5`] = `
|
|
|
53
100
|
/>
|
|
54
101
|
`;
|
|
55
102
|
|
|
56
|
-
exports[`Image Renders the UI snapshot correctly
|
|
103
|
+
exports[`Image Renders the UI snapshot correctly 8`] = `
|
|
57
104
|
<img
|
|
58
105
|
alt=""
|
|
59
106
|
className="css-0"
|
|
@@ -61,7 +108,7 @@ exports[`Image Renders the UI snapshot correctly 6`] = `
|
|
|
61
108
|
/>
|
|
62
109
|
`;
|
|
63
110
|
|
|
64
|
-
exports[`Image Renders the UI snapshot correctly
|
|
111
|
+
exports[`Image Renders the UI snapshot correctly 9`] = `
|
|
65
112
|
<img
|
|
66
113
|
alt=""
|
|
67
114
|
className="css-0"
|
|
@@ -69,7 +116,7 @@ exports[`Image Renders the UI snapshot correctly 7`] = `
|
|
|
69
116
|
/>
|
|
70
117
|
`;
|
|
71
118
|
|
|
72
|
-
exports[`Image Renders the UI snapshot correctly
|
|
119
|
+
exports[`Image Renders the UI snapshot correctly 10`] = `
|
|
73
120
|
<div
|
|
74
121
|
className="the-wrap css-0"
|
|
75
122
|
>
|
|
@@ -85,7 +132,7 @@ exports[`Image Renders the UI snapshot correctly 8`] = `
|
|
|
85
132
|
</div>
|
|
86
133
|
`;
|
|
87
134
|
|
|
88
|
-
exports[`Image Renders the UI snapshot correctly
|
|
135
|
+
exports[`Image Renders the UI snapshot correctly 11`] = `
|
|
89
136
|
<div
|
|
90
137
|
className="the-wrap css-0"
|
|
91
138
|
>
|
|
@@ -101,7 +148,7 @@ exports[`Image Renders the UI snapshot correctly 9`] = `
|
|
|
101
148
|
</div>
|
|
102
149
|
`;
|
|
103
150
|
|
|
104
|
-
exports[`Image Renders the UI snapshot correctly
|
|
151
|
+
exports[`Image Renders the UI snapshot correctly 12`] = `
|
|
105
152
|
<img
|
|
106
153
|
alt=""
|
|
107
154
|
className="css-0"
|
|
@@ -109,7 +156,7 @@ exports[`Image Renders the UI snapshot correctly 10`] = `
|
|
|
109
156
|
/>
|
|
110
157
|
`;
|
|
111
158
|
|
|
112
|
-
exports[`Image Renders the UI snapshot correctly
|
|
159
|
+
exports[`Image Renders the UI snapshot correctly 13`] = `
|
|
113
160
|
<div
|
|
114
161
|
className="the-wrap css-0"
|
|
115
162
|
>
|
|
@@ -125,7 +172,7 @@ exports[`Image Renders the UI snapshot correctly 11`] = `
|
|
|
125
172
|
</div>
|
|
126
173
|
`;
|
|
127
174
|
|
|
128
|
-
exports[`Image Renders the UI snapshot correctly
|
|
175
|
+
exports[`Image Renders the UI snapshot correctly 14`] = `
|
|
129
176
|
<div
|
|
130
177
|
className="the-wrap css-0"
|
|
131
178
|
>
|
|
@@ -141,7 +188,7 @@ exports[`Image Renders the UI snapshot correctly 12`] = `
|
|
|
141
188
|
</div>
|
|
142
189
|
`;
|
|
143
190
|
|
|
144
|
-
exports[`Image Renders the UI snapshot correctly
|
|
191
|
+
exports[`Image Renders the UI snapshot correctly 15`] = `
|
|
145
192
|
<div
|
|
146
193
|
className="the-wrap css-0"
|
|
147
194
|
>
|
|
@@ -157,7 +204,7 @@ exports[`Image Renders the UI snapshot correctly 13`] = `
|
|
|
157
204
|
</div>
|
|
158
205
|
`;
|
|
159
206
|
|
|
160
|
-
exports[`Image Renders the UI snapshot correctly
|
|
207
|
+
exports[`Image Renders the UI snapshot correctly 16`] = `
|
|
161
208
|
<div
|
|
162
209
|
className="the-wrap css-0"
|
|
163
210
|
>
|
|
@@ -173,7 +220,7 @@ exports[`Image Renders the UI snapshot correctly 14`] = `
|
|
|
173
220
|
</div>
|
|
174
221
|
`;
|
|
175
222
|
|
|
176
|
-
exports[`Image Renders the UI snapshot correctly
|
|
223
|
+
exports[`Image Renders the UI snapshot correctly 17`] = `
|
|
177
224
|
<div
|
|
178
225
|
className="the-wrap css-0"
|
|
179
226
|
>
|
|
@@ -189,7 +236,7 @@ exports[`Image Renders the UI snapshot correctly 15`] = `
|
|
|
189
236
|
</div>
|
|
190
237
|
`;
|
|
191
238
|
|
|
192
|
-
exports[`Image Renders the UI snapshot correctly
|
|
239
|
+
exports[`Image Renders the UI snapshot correctly 18`] = `
|
|
193
240
|
<div
|
|
194
241
|
className="the-wrap css-0"
|
|
195
242
|
>
|
|
@@ -3,7 +3,12 @@ import { Box, useStyleConfig } from "@chakra-ui/react";
|
|
|
3
3
|
|
|
4
4
|
import { LinkTypes } from "./LinkTypes";
|
|
5
5
|
import Icon from "../Icons/Icon";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
IconRotationTypes,
|
|
8
|
+
IconNames,
|
|
9
|
+
IconAlign,
|
|
10
|
+
IconSizes,
|
|
11
|
+
} from "../Icons/IconTypes";
|
|
7
12
|
import generateUUID from "../../helpers/generateUUID";
|
|
8
13
|
|
|
9
14
|
export interface LinkProps {
|
|
@@ -51,6 +56,7 @@ function getWithDirectionIcon(children, type: LinkTypes, linkId) {
|
|
|
51
56
|
iconRotation={iconRotation}
|
|
52
57
|
id={iconId}
|
|
53
58
|
name={IconNames.Arrow}
|
|
59
|
+
size={IconSizes.Medium}
|
|
54
60
|
/>
|
|
55
61
|
);
|
|
56
62
|
|
|
@@ -71,6 +77,7 @@ function getExternalIcon(children, linkId) {
|
|
|
71
77
|
className="more-link"
|
|
72
78
|
id={iconId}
|
|
73
79
|
name={IconNames.ActionLaunch}
|
|
80
|
+
size={IconSizes.Medium}
|
|
74
81
|
/>
|
|
75
82
|
);
|
|
76
83
|
|
|
@@ -138,7 +138,8 @@ describe("List", () => {
|
|
|
138
138
|
</List>
|
|
139
139
|
);
|
|
140
140
|
expect(warn).toHaveBeenCalledWith(
|
|
141
|
-
"Pass in either `<li>`, `<dt>`, or `<dd>` children
|
|
141
|
+
"NYPL Reservoir List: Pass in either `<li>`, `<dt>`, or `<dd>` children " +
|
|
142
|
+
"or use the `listItems` data prop. Do not use both."
|
|
142
143
|
);
|
|
143
144
|
});
|
|
144
145
|
|
|
@@ -146,7 +147,8 @@ describe("List", () => {
|
|
|
146
147
|
const warn = jest.spyOn(console, "warn");
|
|
147
148
|
render(<List type={ListTypes.Ordered}></List>);
|
|
148
149
|
expect(warn).toHaveBeenCalledWith(
|
|
149
|
-
"
|
|
150
|
+
"NYPL Reservoir List: Pass in either `<li>` children or pass data in " +
|
|
151
|
+
"the `listItems` prop, not both."
|
|
150
152
|
);
|
|
151
153
|
});
|
|
152
154
|
|
|
@@ -160,7 +162,7 @@ describe("List", () => {
|
|
|
160
162
|
</List>
|
|
161
163
|
);
|
|
162
164
|
expect(warn).toHaveBeenCalledWith(
|
|
163
|
-
"Direct children of `List` (ol)
|
|
165
|
+
"NYPL Reservoir List: Direct children of `List` (ol) must be `<li>`s."
|
|
164
166
|
);
|
|
165
167
|
});
|
|
166
168
|
|
|
@@ -174,7 +176,8 @@ describe("List", () => {
|
|
|
174
176
|
</List>
|
|
175
177
|
);
|
|
176
178
|
expect(warn).toHaveBeenCalledWith(
|
|
177
|
-
"Direct children of `List` (definition)
|
|
179
|
+
"NYPL Reservoir List: Direct children of `List` (definition) must be " +
|
|
180
|
+
"`<dt>`s and `<dd>`s."
|
|
178
181
|
);
|
|
179
182
|
});
|
|
180
183
|
|
|
@@ -60,13 +60,15 @@ export default function List(props: React.PropsWithChildren<ListProps>) {
|
|
|
60
60
|
// prop must be used.
|
|
61
61
|
if (children && (listItems || listItems?.length > 0)) {
|
|
62
62
|
console.warn(
|
|
63
|
-
"Pass in either `<li>`, `<dt>`, or `<dd>`
|
|
63
|
+
"NYPL Reservoir List: Pass in either `<li>`, `<dt>`, or `<dd>` " +
|
|
64
|
+
"children or use the `listItems` data prop. Do not use both."
|
|
64
65
|
);
|
|
65
66
|
return null;
|
|
66
67
|
}
|
|
67
68
|
if (!children && !listItems) {
|
|
68
69
|
console.warn(
|
|
69
|
-
"
|
|
70
|
+
"NYPL Reservoir List: Pass in either `<li>` children or pass data in " +
|
|
71
|
+
"the `listItems` prop, not both."
|
|
70
72
|
);
|
|
71
73
|
return null;
|
|
72
74
|
}
|
|
@@ -100,7 +102,7 @@ export default function List(props: React.PropsWithChildren<ListProps>) {
|
|
|
100
102
|
React.Children.map(children, (child: React.ReactElement) => {
|
|
101
103
|
if (child && child?.type !== "li" && child?.props?.mdxType !== "li") {
|
|
102
104
|
console.warn(
|
|
103
|
-
`Direct children of \`List\` (${listType})
|
|
105
|
+
`NYPL Reservoir List: Direct children of \`List\` (${listType}) must be \`<li>\`s.`
|
|
104
106
|
);
|
|
105
107
|
}
|
|
106
108
|
});
|
|
@@ -120,7 +122,8 @@ export default function List(props: React.PropsWithChildren<ListProps>) {
|
|
|
120
122
|
child.props.mdxType !== React.Fragment
|
|
121
123
|
) {
|
|
122
124
|
console.warn(
|
|
123
|
-
"Direct children of `List` (definition)
|
|
125
|
+
"NYPL Reservoir List: Direct children of `List` (definition) must " +
|
|
126
|
+
"be `<dt>`s and `<dd>`s."
|
|
124
127
|
);
|
|
125
128
|
}
|
|
126
129
|
});
|
|
@@ -148,24 +148,12 @@ is the logo's code name. Pass in better descriptive text in the `title` prop
|
|
|
148
148
|
when using the `Logo` component in your application. This will give screenreaders
|
|
149
149
|
a better descriptive title for the `svg` graphic.
|
|
150
150
|
|
|
151
|
-
## All Logos
|
|
152
|
-
|
|
153
|
-
The `Logo` component contains the logos most commonly used by are listed available
|
|
154
|
-
logos are listed in the `LogoNames` enum in `src/components/Logos/LogoTypes.tsx`.
|
|
155
|
-
|
|
156
|
-
If you feel a necessary logo should be added to the `Logo` component, please reach out
|
|
157
|
-
to the DS team.
|
|
158
|
-
|
|
159
|
-
<Canvas withToolbar>
|
|
160
|
-
<Story name="All Logos">{allLogosGrid(logos)}</Story>
|
|
161
|
-
</Canvas>
|
|
162
|
-
|
|
163
151
|
## Logo Sizes
|
|
164
152
|
|
|
165
153
|
Update the size of the `Logo` component by passing the `size` prop with a value from
|
|
166
154
|
`LogoSizes`. The `LogoSizes` enum can be found in`src/components/Logo/LogoTypes.tsx`.
|
|
167
155
|
|
|
168
|
-
Note: `LogoSizes.Default` sets the width to `100%` and the logo will expand to
|
|
156
|
+
Note: `LogoSizes.Default` sets the width to `100%` and the rendered logo will expand to
|
|
169
157
|
fill the full width of the parent element.
|
|
170
158
|
|
|
171
159
|
```jsx
|
|
@@ -177,6 +165,18 @@ fill the full width of the parent element.
|
|
|
177
165
|
<Story name="Logo Sizes">{allLogosGrid(sizes)}</Story>
|
|
178
166
|
</Canvas>
|
|
179
167
|
|
|
168
|
+
## All Logos
|
|
169
|
+
|
|
170
|
+
The `Logo` component contains the logos most commonly used by are listed available
|
|
171
|
+
logos are listed in the `LogoNames` enum in `src/components/Logos/LogoTypes.tsx`.
|
|
172
|
+
|
|
173
|
+
If you feel a necessary logo should be added to the `Logo` component, please reach out
|
|
174
|
+
to the DS team.
|
|
175
|
+
|
|
176
|
+
<Canvas withToolbar>
|
|
177
|
+
<Story name="All Logos">{allLogosGrid(logos)}</Story>
|
|
178
|
+
</Canvas>
|
|
179
|
+
|
|
180
180
|
## Custom Logos
|
|
181
181
|
|
|
182
182
|
If you'd like to pass a custom `svg` to your application, you can pass it a
|
|
@@ -28,7 +28,7 @@ describe("Logo", () => {
|
|
|
28
28
|
</Logo>
|
|
29
29
|
);
|
|
30
30
|
expect(warn).toHaveBeenCalledWith(
|
|
31
|
-
"Logo
|
|
31
|
+
"NYPL Reservoir Logo: Pass either a `name` prop or an `svg` element child. Do not pass both."
|
|
32
32
|
);
|
|
33
33
|
});
|
|
34
34
|
|
|
@@ -36,7 +36,17 @@ describe("Logo", () => {
|
|
|
36
36
|
const warn = jest.spyOn(console, "warn");
|
|
37
37
|
render(<Logo />);
|
|
38
38
|
expect(warn).toHaveBeenCalledWith(
|
|
39
|
-
"Pass a logo `name` prop or an SVG child to
|
|
39
|
+
"NYPL Reservoir Logo: Pass a logo `name` prop or an SVG child to " +
|
|
40
|
+
"`Logo` to ensure a logo appears."
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("consoles a warning if name is not passed and a child is but it's not an SVG element", () => {
|
|
45
|
+
const warn = jest.spyOn(console, "warn");
|
|
46
|
+
render(<Logo>Not an SVG</Logo>);
|
|
47
|
+
expect(warn).toHaveBeenCalledWith(
|
|
48
|
+
"NYPL Reservoir Logo: An `svg` element must be passed to the `Logo` " +
|
|
49
|
+
"component as its child."
|
|
40
50
|
);
|
|
41
51
|
});
|
|
42
52
|
|
|
@@ -55,12 +55,14 @@ export default function Logo(props: React.PropsWithChildren<LogoProps>) {
|
|
|
55
55
|
// Component prop validation
|
|
56
56
|
if (name && children) {
|
|
57
57
|
console.warn(
|
|
58
|
-
"Logo
|
|
58
|
+
"NYPL Reservoir Logo: Pass either a `name` prop or an `svg` element " +
|
|
59
|
+
"child. Do not pass both."
|
|
59
60
|
);
|
|
60
61
|
return null;
|
|
61
62
|
} else if (!name && !children) {
|
|
62
63
|
console.warn(
|
|
63
|
-
"Pass a logo `name` prop or an SVG child to
|
|
64
|
+
"NYPL Reservoir Logo: Pass a logo `name` prop or an SVG child to " +
|
|
65
|
+
"`Logo` to ensure a logo appears."
|
|
64
66
|
);
|
|
65
67
|
return null;
|
|
66
68
|
}
|
|
@@ -83,14 +85,17 @@ export default function Logo(props: React.PropsWithChildren<LogoProps>) {
|
|
|
83
85
|
// Apply logo props to the SVG child.
|
|
84
86
|
if (
|
|
85
87
|
(children as JSX.Element).type === "svg" ||
|
|
86
|
-
(children as JSX.Element).props
|
|
87
|
-
(children as JSX.Element).props
|
|
88
|
+
(children as JSX.Element).props?.type === "svg" ||
|
|
89
|
+
(children as JSX.Element).props?.mdxType === "svg"
|
|
88
90
|
) {
|
|
89
91
|
childSVG = React.cloneElement(children as JSX.Element, {
|
|
90
92
|
...logoProps,
|
|
91
93
|
});
|
|
92
94
|
} else {
|
|
93
|
-
console.warn(
|
|
95
|
+
console.warn(
|
|
96
|
+
"NYPL Reservoir Logo: An `svg` element must be passed to the `Logo` " +
|
|
97
|
+
"component as its child."
|
|
98
|
+
);
|
|
94
99
|
}
|
|
95
100
|
|
|
96
101
|
return <Box __css={styles}>{childSVG}</Box>;
|
|
@@ -5,12 +5,12 @@ export enum LogoColors {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export enum LogoSizes {
|
|
8
|
+
Default = "default",
|
|
8
9
|
ExtraExtraSmall = "xxsmall",
|
|
9
10
|
ExtraSmall = "xsmall",
|
|
10
11
|
Small = "small",
|
|
11
12
|
Medium = "medium",
|
|
12
13
|
Large = "large",
|
|
13
|
-
Default = "default",
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export enum LogoNames {
|
|
@@ -33,15 +33,15 @@ export const enumValues = getStorybookEnumValues(
|
|
|
33
33
|
jest: ["Notification.test.tsx"],
|
|
34
34
|
}}
|
|
35
35
|
argTypes={{
|
|
36
|
-
centered: {
|
|
37
|
-
table: { defaultValue: { summary: false } },
|
|
38
|
-
},
|
|
39
36
|
className: { control: false },
|
|
40
37
|
dismissible: {
|
|
41
38
|
table: { defaultValue: { summary: false } },
|
|
42
39
|
},
|
|
43
40
|
icon: { control: false },
|
|
44
41
|
id: { control: false },
|
|
42
|
+
isCentered: {
|
|
43
|
+
table: { defaultValue: { summary: false } },
|
|
44
|
+
},
|
|
45
45
|
noMargin: {
|
|
46
46
|
table: { defaultValue: { summary: false } },
|
|
47
47
|
},
|
|
@@ -59,7 +59,7 @@ export const enumValues = getStorybookEnumValues(
|
|
|
59
59
|
| Component Version | DS Version |
|
|
60
60
|
| ----------------- | ---------- |
|
|
61
61
|
| Added | `0.23.2` |
|
|
62
|
-
| Latest | `0.25.
|
|
62
|
+
| Latest | `0.25.13` |
|
|
63
63
|
|
|
64
64
|
<Description of={Notification} />
|
|
65
65
|
|
|
@@ -75,11 +75,11 @@ within a parent element.
|
|
|
75
75
|
name="Notification with Controls"
|
|
76
76
|
args={{
|
|
77
77
|
ariaLabel: "Notification label",
|
|
78
|
-
centered: false,
|
|
79
78
|
className: undefined,
|
|
80
79
|
dismissible: false,
|
|
81
80
|
icon: undefined,
|
|
82
81
|
id: "notification-id",
|
|
82
|
+
isCentered: false,
|
|
83
83
|
noMargin: false,
|
|
84
84
|
notificationHeading: "Notification Heading",
|
|
85
85
|
notificationContent: (
|