@nypl/design-system-react-components 0.25.3 → 0.25.4
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 +42 -0
- package/README.md +47 -11
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +4 -0
- package/dist/components/Button/Button.d.ts +9 -6
- package/dist/components/Button/ButtonTypes.d.ts +2 -1
- package/dist/components/Card/Card.d.ts +0 -25
- package/dist/components/Icons/IconSvgs.d.ts +3 -0
- package/dist/components/Icons/IconTypes.d.ts +3 -0
- package/dist/components/Notification/Notification.d.ts +6 -4
- package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +29 -0
- package/dist/components/ProgressIndicator/ProgressIndicatorTypes.d.ts +8 -0
- package/dist/components/SearchBar/SearchBar.d.ts +3 -3
- package/dist/components/Slider/Slider.d.ts +57 -0
- package/dist/components/Tabs/Tabs.d.ts +1 -1
- package/dist/components/TextInput/TextInput.d.ts +6 -0
- package/dist/design-system-react-components.cjs.development.js +707 -454
- 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 +700 -441
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/resources.scss +180 -170
- package/dist/styles.css +1 -1
- package/dist/theme/components/button.d.ts +10 -0
- package/dist/theme/components/progressIndicator.d.ts +50 -0
- package/dist/theme/components/slider.d.ts +51 -0
- package/dist/theme/foundations/breakpoints.d.ts +8 -8
- package/dist/theme/foundations/global.d.ts +6 -1
- package/package.json +72 -84
- package/src/__tests__/setup.ts +2 -2
- package/src/components/Accordion/Accordion.stories.mdx +30 -34
- package/src/components/Autosuggest/Autosuggest.stories.mdx +3 -3
- package/src/components/Autosuggest/Autosuggest.stories.tsx +1 -0
- package/src/components/Autosuggest/_Autosuggest.scss +5 -5
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +5 -6
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +23 -0
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +5 -1
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +198 -1
- package/src/components/Button/Button.stories.mdx +8 -6
- package/src/components/Button/Button.test.tsx +20 -0
- package/src/components/Button/Button.tsx +14 -23
- package/src/components/Button/ButtonTypes.tsx +1 -0
- package/src/components/Button/__snapshots__/Button.test.tsx.snap +29 -4
- package/src/components/Card/Card.stories.mdx +1 -1
- package/src/components/Card/Card.tsx +3 -3
- package/src/components/CardEdition/CardEdition.stories.tsx +15 -47
- package/src/components/CardEdition/_CardEdition.scss +22 -23
- package/src/components/Chakra/Box.stories.mdx +14 -15
- package/src/components/Chakra/Center.stories.mdx +15 -8
- package/src/components/Chakra/Grid.stories.mdx +16 -7
- package/src/components/Chakra/Stack.stories.mdx +35 -18
- package/src/components/DatePicker/DatePicker.test.tsx +31 -30
- package/src/components/DatePicker/DatePicker.tsx +7 -4
- package/src/components/DatePicker/_DatePicker.scss +4 -4
- package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +19 -5
- package/src/components/Form/Form.stories.mdx +4 -5
- package/src/components/Grid/SimpleGrid.stories.mdx +1 -0
- package/src/components/Hero/HeroTypes.tsx +1 -0
- package/src/components/HorizontalRule/HorizontalRule.stories.mdx +2 -3
- package/src/components/Icons/Icon.stories.mdx +2 -3
- package/src/components/Icons/IconSvgs.tsx +6 -0
- package/src/components/Icons/IconTypes.tsx +3 -0
- package/src/components/Image/Image.stories.mdx +2 -3
- package/src/components/Input/Input.stories.tsx +20 -64
- package/src/components/Input/_Input.scss +23 -14
- package/src/components/Modal/Modal.stories.mdx +3 -3
- package/src/components/Modal/_Modal.scss +2 -2
- package/src/components/Notification/Notification.stories.mdx +1 -1
- package/src/components/Notification/Notification.tsx +13 -4
- package/src/components/Pagination/Pagination.stories.mdx +3 -2
- package/src/components/Pagination/Pagination.stories.tsx +1 -2
- package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +292 -0
- package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +225 -0
- package/src/components/ProgressIndicator/ProgressIndicator.tsx +126 -0
- package/src/components/ProgressIndicator/ProgressIndicatorTypes.ts +8 -0
- package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +357 -0
- package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +3 -0
- package/src/components/RadioGroup/RadioGroup.stories.mdx +2 -3
- package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +4 -0
- package/src/components/SearchBar/SearchBar.Test.tsx +2 -1
- package/src/components/SearchBar/SearchBar.stories.mdx +109 -9
- package/src/components/SearchBar/SearchBar.tsx +11 -4
- package/src/components/Select/SelectTypes.tsx +1 -0
- package/src/components/Slider/Slider.stories.mdx +529 -0
- package/src/components/Slider/Slider.test.tsx +653 -0
- package/src/components/Slider/Slider.tsx +303 -0
- package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +1946 -0
- package/src/components/StyleGuide/Bidirectionality.stories.mdx +1 -1
- package/src/components/StyleGuide/Breakpoints.stories.mdx +21 -7
- package/src/components/StyleGuide/Buttons.stories.mdx +9 -2
- package/src/components/StyleGuide/DesignTokens.stories.mdx +170 -0
- package/src/components/Tabs/Tabs.tsx +5 -5
- package/src/components/Template/Template.stories.mdx +6 -6
- package/src/components/TextInput/TextInput.stories.mdx +1 -1
- package/src/components/TextInput/TextInput.tsx +15 -2
- package/src/components/TextInput/TextInputTypes.tsx +2 -0
- package/src/components/VideoPlayer/VideoPlayer.stories.mdx +2 -3
- package/src/docs/Chakra.stories.mdx +2 -2
- package/src/index.ts +10 -6
- package/src/resources.scss +5 -5
- package/src/styles/base/{_02-breakpoints.scss → _01-breakpoints.scss} +9 -10
- package/src/styles/base/{_03-mixins.scss → _02-mixins.scss} +16 -5
- package/src/styles/base/{_04-base.scss → _03-base.scss} +7 -2
- package/src/styles/base/{_05-focus.scss → _04-focus.scss} +0 -15
- package/src/styles/base/_place-holder.scss +14 -3
- package/src/styles/{03-space → space}/_space-inline.scss +14 -14
- package/src/styles/{03-space → space}/_space-inset.scss +10 -10
- package/src/styles/space/_space-stack.scss +116 -0
- package/src/styles.scss +13 -44
- package/src/theme/components/button.ts +10 -2
- package/src/theme/components/card.ts +11 -9
- package/src/theme/components/datePicker.ts +1 -1
- package/src/theme/components/list.ts +2 -2
- package/src/theme/components/notification.ts +5 -3
- package/src/theme/components/progressIndicator.ts +62 -0
- package/src/theme/components/skeletonLoader.ts +1 -1
- package/src/theme/components/slider.ts +79 -0
- package/src/theme/foundations/breakpoints.ts +8 -8
- package/src/theme/foundations/global.ts +6 -1
- package/src/theme/index.ts +4 -0
- package/src/utils/componentCategories.ts +3 -3
- package/src/styles/01-colors/_colors-brand.scss +0 -62
- package/src/styles/01-colors/_colors-utility.scss +0 -67
- package/src/styles/02-typography/_type-scale.css +0 -11
- package/src/styles/02-typography/_type-weight.css +0 -7
- package/src/styles/02-typography/_typefaces.css +0 -4
- package/src/styles/03-space/_space-stack.scss +0 -116
- package/src/styles/03-space/_space.css +0 -30
- package/src/styles/base/_card-grid.scss +0 -77
- package/src/styles/base/_typography.scss +0 -11
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
.card-edition {
|
|
2
|
-
|
|
2
|
+
margin-bottom: var(--nypl-space-s);
|
|
3
3
|
|
|
4
4
|
align-items: flex-start;
|
|
5
|
-
border: 1px solid var(--ui-gray-light-cool);
|
|
5
|
+
border: 1px solid var(--nypl-colors-ui-gray-light-cool);
|
|
6
6
|
border-radius: 5px;
|
|
7
7
|
display: flex;
|
|
8
8
|
flex-flow: column wrap;
|
|
9
|
-
padding: var(--space) var(--space-l);
|
|
9
|
+
padding: var(--nypl-space-s) var(--nypl-space-l);
|
|
10
10
|
|
|
11
11
|
&__heading,
|
|
12
12
|
&__footer {
|
|
@@ -19,20 +19,20 @@
|
|
|
19
19
|
justify-content: space-between;
|
|
20
20
|
width: 100%;
|
|
21
21
|
|
|
22
|
-
@include breakpoint($breakpoint-medium) {
|
|
22
|
+
@include breakpoint($nypl-breakpoint-medium) {
|
|
23
23
|
flex-flow: row wrap;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
&__columns + &__footer {
|
|
28
|
-
margin-top: var(--space-xs);
|
|
28
|
+
margin-top: var(--nypl-space-xs);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
&__image {
|
|
32
|
-
|
|
32
|
+
margin-bottom: var(--nypl-space-s);
|
|
33
33
|
|
|
34
34
|
align-items: center;
|
|
35
|
-
background-color: var(--ui-gray-x-light-cool);
|
|
35
|
+
background-color: var(--nypl-colors-ui-gray-x-light-cool);
|
|
36
36
|
display: flex;
|
|
37
37
|
flex: 0 0 150px;
|
|
38
38
|
height: 150px;
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
max-width: 100%;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
@include breakpoint($breakpoint-medium) {
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
@include breakpoint($nypl-breakpoint-medium) {
|
|
47
|
+
margin-bottom: 0;
|
|
48
|
+
margin-right: var(--nypl-space-s);
|
|
49
49
|
|
|
50
50
|
align-self: center;
|
|
51
51
|
width: 150px;
|
|
@@ -53,45 +53,44 @@
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
&__content {
|
|
56
|
-
|
|
56
|
+
margin-bottom: var(--nypl-space-s);
|
|
57
57
|
|
|
58
58
|
flex: 1 1;
|
|
59
59
|
|
|
60
|
-
@include breakpoint($breakpoint-medium) {
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
@include breakpoint($nypl-breakpoint-medium) {
|
|
61
|
+
margin-right: var(--nypl-space-s);
|
|
62
|
+
margin-bottom: 0;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
&__ctas {
|
|
67
67
|
flex: 0 1 20%;
|
|
68
68
|
|
|
69
|
-
@include breakpoint($breakpoint-medium) {
|
|
70
|
-
|
|
69
|
+
@include breakpoint($nypl-breakpoint-medium) {
|
|
70
|
+
margin-right: var(--nypl-space-s);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
&__content + &__ctas {
|
|
75
|
-
|
|
75
|
+
margin-right: var(--nypl-space-s);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
// Stories-only styles
|
|
80
80
|
.sb-show-main {
|
|
81
81
|
.var-docs {
|
|
82
|
-
padding: 0 0 var(--space) 0;
|
|
82
|
+
padding: 0 0 var(--nypl-space-s) 0;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
.example-card-edition {
|
|
86
86
|
.card__content {
|
|
87
87
|
> * {
|
|
88
|
-
|
|
88
|
+
margin-bottom: var(--nypl-space-xxs);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
.book__callout {
|
|
93
|
-
|
|
94
|
-
font-size: var(--font-size-1);
|
|
93
|
+
font-size: var(--nypl-fontSizes-1);
|
|
95
94
|
font-weight: 400;
|
|
96
95
|
line-height: 1.15;
|
|
97
96
|
margin: 0 0 0.5em;
|
|
@@ -123,12 +122,12 @@
|
|
|
123
122
|
}
|
|
124
123
|
|
|
125
124
|
> * {
|
|
126
|
-
|
|
125
|
+
margin-bottom: var(--nypl-space-xxs);
|
|
127
126
|
}
|
|
128
127
|
}
|
|
129
128
|
|
|
130
129
|
.book__filetype {
|
|
131
|
-
|
|
130
|
+
margin-bottom: var(--nypl-space-s);
|
|
132
131
|
}
|
|
133
132
|
|
|
134
133
|
.book__description {
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
VideoPlayerTypes,
|
|
8
8
|
VideoPlayerAspectRatios,
|
|
9
9
|
} from "../VideoPlayer/VideoPlayerTypes";
|
|
10
|
+
import DSProvider from "../../theme/provider";
|
|
10
11
|
|
|
11
12
|
<Meta title={getCategory("Box")} component={Box} />
|
|
12
13
|
|
|
@@ -16,7 +17,8 @@ import {
|
|
|
16
17
|
| ----------------- | ---------- |
|
|
17
18
|
| Added | `0.24.0` |
|
|
18
19
|
|
|
19
|
-
Note: This needs the use of the `DSProvider` component. See the
|
|
20
|
+
Note: This needs the use of the `DSProvider` component. See the
|
|
21
|
+
[README](https://nypl.github.io/nypl-design-system/storybook-static/?path=/story/chakra-ui--page#dsprovider)
|
|
20
22
|
for more information.
|
|
21
23
|
|
|
22
24
|
This component is directly exported from Chakra UI. The `Box` is a simple and
|
|
@@ -30,28 +32,25 @@ guide on the Chakra UI site.
|
|
|
30
32
|
<Story
|
|
31
33
|
name="Box"
|
|
32
34
|
args={{
|
|
33
|
-
|
|
35
|
+
padding: "s",
|
|
34
36
|
bg: "var(--nypl-colors-brand-primary)",
|
|
35
37
|
color: "white",
|
|
36
38
|
}}
|
|
37
39
|
>
|
|
38
|
-
{(args) =>
|
|
39
|
-
<Box {...args}>
|
|
40
|
-
So when I look up at the stars, I just wonder...what will they all
|
|
41
|
-
become someday?
|
|
42
|
-
</Box>
|
|
43
|
-
)}
|
|
40
|
+
{(args) => <Box {...args}>This text is inside a `Box` component.</Box>}
|
|
44
41
|
</Story>
|
|
45
42
|
</Canvas>
|
|
46
43
|
|
|
47
44
|
## With VideoPlayer Component Example
|
|
48
45
|
|
|
49
46
|
<Canvas>
|
|
50
|
-
<
|
|
51
|
-
<
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
<DSProvider>
|
|
48
|
+
<Box borderWidth="3px" padding="s" borderRadius="lg" overflow="hidden">
|
|
49
|
+
<VideoPlayer
|
|
50
|
+
videoId="nm-dD2tx6bk"
|
|
51
|
+
videoType={VideoPlayerTypes.YouTube}
|
|
52
|
+
aspectRatio={VideoPlayerAspectRatios.SixteenByNine}
|
|
53
|
+
/>
|
|
54
|
+
</Box>
|
|
55
|
+
</DSProvider>
|
|
57
56
|
</Canvas>
|
|
@@ -3,6 +3,7 @@ import { Box, Center, Square, Circle, HStack } from "@chakra-ui/react";
|
|
|
3
3
|
|
|
4
4
|
import { getCategory } from "../../utils/componentCategories";
|
|
5
5
|
import Image from "../Image/Image";
|
|
6
|
+
import { ImageSizes } from "../Image/ImageTypes";
|
|
6
7
|
import Icon from "../Icons/Icon";
|
|
7
8
|
import { IconNames, IconColors, IconSizes } from "../Icons/IconTypes";
|
|
8
9
|
import DSProvider from "../../theme/provider";
|
|
@@ -15,7 +16,8 @@ import DSProvider from "../../theme/provider";
|
|
|
15
16
|
| ----------------- | ---------- |
|
|
16
17
|
| Added | `0.24.0` |
|
|
17
18
|
|
|
18
|
-
Note: This needs the use of the `DSProvider` component. See the
|
|
19
|
+
Note: This needs the use of the `DSProvider` component. See the
|
|
20
|
+
[README](https://nypl.github.io/nypl-design-system/storybook-static/?path=/story/chakra-ui--page#dsprovider)
|
|
19
21
|
for more information.
|
|
20
22
|
|
|
21
23
|
These components are directly exported from Chakra UI. The `Center`, `Circle`,
|
|
@@ -30,7 +32,7 @@ guide on the Chakra UI site.
|
|
|
30
32
|
<Story
|
|
31
33
|
name="Center, Circle, Square"
|
|
32
34
|
args={{
|
|
33
|
-
|
|
35
|
+
padding: "s",
|
|
34
36
|
bg: "var(--nypl-colors-brand-primary)",
|
|
35
37
|
color: "var(--nypl-colors-ui-white)",
|
|
36
38
|
}}
|
|
@@ -39,8 +41,7 @@ guide on the Chakra UI site.
|
|
|
39
41
|
<Box>
|
|
40
42
|
Some text at the beginning.
|
|
41
43
|
<Center {...args}>
|
|
42
|
-
|
|
43
|
-
become someday?
|
|
44
|
+
This text is centered inside a `Center` component.
|
|
44
45
|
</Center>
|
|
45
46
|
Some text at the end.
|
|
46
47
|
</Box>
|
|
@@ -50,15 +51,20 @@ guide on the Chakra UI site.
|
|
|
50
51
|
|
|
51
52
|
<Canvas>
|
|
52
53
|
<DSProvider>
|
|
53
|
-
<Center>
|
|
54
|
-
<Image
|
|
54
|
+
<Center border="1px solid" borderColor="var(--nypl-colors-ui-gray-medium)">
|
|
55
|
+
<Image
|
|
56
|
+
src="https://placeimg.com/300/400/arch"
|
|
57
|
+
alt="Centered Image"
|
|
58
|
+
imageSize={ImageSizes.Medium}
|
|
59
|
+
/>
|
|
55
60
|
</Center>
|
|
56
61
|
</DSProvider>
|
|
57
62
|
</Canvas>
|
|
58
63
|
|
|
59
64
|
## Circle
|
|
60
65
|
|
|
61
|
-
|
|
66
|
+
This component is similar to the `Center` component but it is always rendered as
|
|
67
|
+
a circle.
|
|
62
68
|
|
|
63
69
|
<Canvas>
|
|
64
70
|
<DSProvider>
|
|
@@ -83,7 +89,8 @@ Similar to `Center` but is always a circle!
|
|
|
83
89
|
|
|
84
90
|
## Square
|
|
85
91
|
|
|
86
|
-
|
|
92
|
+
This component is similar to the `Circle` component but always has equal height
|
|
93
|
+
and width.
|
|
87
94
|
|
|
88
95
|
<Canvas>
|
|
89
96
|
<DSProvider>
|
|
@@ -2,6 +2,7 @@ import { Meta, Story, Canvas } from "@storybook/addon-docs/blocks";
|
|
|
2
2
|
import { Box } from "@chakra-ui/react";
|
|
3
3
|
import { Grid, GridItem } from "@chakra-ui/react";
|
|
4
4
|
import { getCategory } from "../../utils/componentCategories";
|
|
5
|
+
import DSProvider from "../../theme/provider";
|
|
5
6
|
|
|
6
7
|
<Meta title={getCategory("Grid")} component={Grid} />
|
|
7
8
|
|
|
@@ -11,13 +12,17 @@ import { getCategory } from "../../utils/componentCategories";
|
|
|
11
12
|
| ----------------- | ---------- |
|
|
12
13
|
| Added | `0.25.1` |
|
|
13
14
|
|
|
14
|
-
Note: This needs the use of the `DSProvider` component. See the
|
|
15
|
+
Note: This needs the use of the `DSProvider` component. See the
|
|
16
|
+
[README](https://nypl.github.io/nypl-design-system/storybook-static/?path=/story/chakra-ui--page#dsprovider)
|
|
15
17
|
for more information.
|
|
16
18
|
|
|
17
|
-
This component is directly exported from Chakra UI. The `Grid` component is
|
|
19
|
+
This component is directly exported from Chakra UI. The `Grid` component is
|
|
20
|
+
useful for grid layouts and offers more complexity and formatting options than
|
|
21
|
+
the DS `SimpleGrid` component. `Grid` is `Box` with `display: grid` and it comes
|
|
22
|
+
with helpful style shorthand. It renders a `div` element.
|
|
18
23
|
|
|
19
|
-
Details about available props and related child components can be found on the
|
|
20
|
-
page on the Chakra UI site.
|
|
24
|
+
Details about available props and related child components can be found on the
|
|
25
|
+
[Grid component](https://chakra-ui.com/docs/layout/grid) page on the Chakra UI site.
|
|
21
26
|
|
|
22
27
|
<Canvas>
|
|
23
28
|
<Story
|
|
@@ -46,12 +51,16 @@ page on the Chakra UI site.
|
|
|
46
51
|
|
|
47
52
|
## Complex Layouts with Grid Child Components
|
|
48
53
|
|
|
49
|
-
In some layouts, you may need certain grid items to span a specific amount of
|
|
54
|
+
In some layouts, you may need certain grid items to span a specific amount of
|
|
55
|
+
columns or rows instead of an even distribution. To achieve this, you need to
|
|
56
|
+
pass the `colSpan` prop to the `GridItem` component to span across columns and
|
|
57
|
+
also pass the `rowSpan` component to span across rows. You also need to specify
|
|
58
|
+
the `templateColumns` and `templateRows`.
|
|
50
59
|
|
|
51
60
|
<Canvas>
|
|
52
61
|
<DSProvider>
|
|
53
62
|
<Grid
|
|
54
|
-
|
|
63
|
+
height="200px"
|
|
55
64
|
templateRows="repeat(2, 1fr)"
|
|
56
65
|
templateColumns="repeat(5, 1fr)"
|
|
57
66
|
gap="32"
|
|
@@ -70,7 +79,7 @@ In some layouts, you may need certain grid items to span a specific amount of co
|
|
|
70
79
|
|
|
71
80
|
```jsx
|
|
72
81
|
<Grid
|
|
73
|
-
|
|
82
|
+
height="200px"
|
|
74
83
|
templateRows="repeat(2, 1fr)"
|
|
75
84
|
templateColumns="repeat(5, 1fr)"
|
|
76
85
|
gap="32"
|
|
@@ -4,8 +4,7 @@ import { Box, Stack, HStack, VStack, Circle } from "@chakra-ui/react";
|
|
|
4
4
|
import { getCategory } from "../../utils/componentCategories";
|
|
5
5
|
import DSProvider from "../../theme/provider";
|
|
6
6
|
import Icon from "../Icons/Icon";
|
|
7
|
-
import { IconNames,
|
|
8
|
-
import Radio from "../Radio/Radio";
|
|
7
|
+
import { IconNames, IconSizes } from "../Icons/IconTypes";
|
|
9
8
|
|
|
10
9
|
<Meta title={getCategory("Stack, HStack, VStack")} component={Stack} />
|
|
11
10
|
|
|
@@ -15,7 +14,8 @@ import Radio from "../Radio/Radio";
|
|
|
15
14
|
| ----------------- | ---------- |
|
|
16
15
|
| Added | `0.24.0` |
|
|
17
16
|
|
|
18
|
-
Note: This needs the use of the `DSProvider` component. See the
|
|
17
|
+
Note: This needs the use of the `DSProvider` component. See the
|
|
18
|
+
[README](https://nypl.github.io/nypl-design-system/storybook-static/?path=/story/chakra-ui--page#dsprovider)
|
|
19
19
|
for more information.
|
|
20
20
|
|
|
21
21
|
These components are directly exported from Chakra UI. The `Stack`, `HStack`,
|
|
@@ -25,17 +25,21 @@ with spacing between them.
|
|
|
25
25
|
All available props can be found on the [Style Props](https://chakra-ui.com/docs/features/style-props)
|
|
26
26
|
guide on the Chakra UI site.
|
|
27
27
|
|
|
28
|
+
In all the following examples, Design System `Icon` components are wrapped in
|
|
29
|
+
Chakra's `Circle` component.
|
|
30
|
+
|
|
28
31
|
## Stack
|
|
29
32
|
|
|
30
|
-
The `Stack` component is the most flexible component because it can stack
|
|
31
|
-
both horizontally and vertically through the `direction` prop
|
|
33
|
+
The `Stack` component is the most flexible component because it can stack
|
|
34
|
+
elements both horizontally and vertically through the `direction` prop and the
|
|
35
|
+
`"row"` and `"column"` values, respectively.
|
|
32
36
|
|
|
33
37
|
<Canvas>
|
|
34
38
|
<Story
|
|
35
39
|
name="Stack, HStack, VStack"
|
|
36
40
|
args={{
|
|
37
41
|
direction: "column",
|
|
38
|
-
spacing: "
|
|
42
|
+
spacing: "s",
|
|
39
43
|
}}
|
|
40
44
|
argTypes={{
|
|
41
45
|
direction: {
|
|
@@ -64,30 +68,43 @@ both horizontally and vertically through the `direction` prop.
|
|
|
64
68
|
|
|
65
69
|
## HStack
|
|
66
70
|
|
|
67
|
-
Stacks components horizontally.
|
|
71
|
+
Stacks components horizontally. This is the same as the `Stack` component with
|
|
72
|
+
a `direction` value of `"row"`.
|
|
68
73
|
|
|
69
74
|
<Canvas>
|
|
70
75
|
<DSProvider>
|
|
71
|
-
<HStack>
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
<
|
|
76
|
+
<HStack spacing="s">
|
|
77
|
+
<Circle size="50px" borderColor="ui.black" borderWidth="1px">
|
|
78
|
+
<Icon name={IconNames.ErrorFilled} size={IconSizes.Large} />
|
|
79
|
+
</Circle>
|
|
80
|
+
<Circle size="50px" borderColor="ui.black" borderWidth="1px">
|
|
81
|
+
<Icon name={IconNames.ErrorOutline} size={IconSizes.Large} />
|
|
82
|
+
</Circle>
|
|
83
|
+
<Circle size="50px" borderColor="ui.black" borderWidth="1px">
|
|
84
|
+
<Icon name={IconNames.Check} size={IconSizes.Large} />
|
|
85
|
+
</Circle>
|
|
76
86
|
</HStack>
|
|
77
87
|
</DSProvider>
|
|
78
88
|
</Canvas>
|
|
79
89
|
|
|
80
90
|
## VStack
|
|
81
91
|
|
|
82
|
-
Stacks components vertically.
|
|
92
|
+
Stacks components vertically. This is the same as the `Stack` component with
|
|
93
|
+
a `direction` value of `"column"`.Pass in a value to the `align` prop to align
|
|
94
|
+
all the elements in the stack.
|
|
83
95
|
|
|
84
96
|
<Canvas>
|
|
85
97
|
<DSProvider>
|
|
86
|
-
<VStack>
|
|
87
|
-
<
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
<
|
|
98
|
+
<VStack align="left" spacing="s">
|
|
99
|
+
<Circle size="50px" borderColor="ui.black" borderWidth="1px">
|
|
100
|
+
<Icon name={IconNames.ErrorFilled} size={IconSizes.Large} />
|
|
101
|
+
</Circle>
|
|
102
|
+
<Circle size="50px" borderColor="ui.black" borderWidth="1px">
|
|
103
|
+
<Icon name={IconNames.ErrorOutline} size={IconSizes.Large} />
|
|
104
|
+
</Circle>
|
|
105
|
+
<Circle size="50px" borderColor="ui.black" borderWidth="1px">
|
|
106
|
+
<Icon name={IconNames.Check} size={IconSizes.Large} />
|
|
107
|
+
</Circle>
|
|
91
108
|
</VStack>
|
|
92
109
|
</DSProvider>
|
|
93
110
|
</Canvas>
|
|
@@ -368,7 +368,7 @@ describe("DatePicker", () => {
|
|
|
368
368
|
// Note: Have to add an initial date so that the snapshot tests always
|
|
369
369
|
// pass. Otherwise, it'll use the _current_ date which changes
|
|
370
370
|
// based on the day it is tested and is not what we want.
|
|
371
|
-
it("renders the UI snapshot correctly", () => {
|
|
371
|
+
it.skip("renders the UI snapshot correctly", () => {
|
|
372
372
|
const basic = renderer
|
|
373
373
|
.create(
|
|
374
374
|
<DatePicker
|
|
@@ -614,51 +614,47 @@ describe("DatePicker", () => {
|
|
|
614
614
|
expect(disabled).toMatchSnapshot();
|
|
615
615
|
});
|
|
616
616
|
|
|
617
|
-
/* // REVISIT THIS TEST
|
|
618
617
|
it("should select two new dates", () => {
|
|
619
618
|
render(
|
|
620
619
|
<DatePicker
|
|
621
|
-
|
|
620
|
+
initialDate="3/2/1988"
|
|
621
|
+
initialDateTo="3/28/1988"
|
|
622
|
+
isDateRange
|
|
622
623
|
labelText="Select the date range you want to visit NYPL"
|
|
623
624
|
/>
|
|
624
625
|
);
|
|
625
626
|
const fromInput = screen.getByLabelText(/From/i);
|
|
626
627
|
const toInput = screen.getByLabelText(/To/i);
|
|
627
|
-
const date = getTodaysDateDisplay();
|
|
628
628
|
|
|
629
|
-
expect(
|
|
629
|
+
expect(fromInput).toHaveValue("1988-03-02");
|
|
630
|
+
expect(toInput).toHaveValue("1988-03-28");
|
|
631
|
+
// expect(screen.getAllByDisplayValue(date)).toHaveLength(2);
|
|
630
632
|
|
|
631
633
|
// Let's select a new day.
|
|
632
634
|
userEvent.click(fromInput);
|
|
633
635
|
// The popup displays. Select a new day.
|
|
634
|
-
const newDateFrom =
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
todaysDate.getDate() > 28 ? 18 : todaysDate.getDate() + 5;
|
|
638
|
-
const newDateToSelect = str_pad(newDateFrom);
|
|
639
|
-
userEvent.click(screen.getAllByText(newDateFrom)[0]);
|
|
636
|
+
const newDateFrom = 5;
|
|
637
|
+
const newDateTo = 25;
|
|
638
|
+
userEvent.click(screen.getByText(newDateFrom));
|
|
640
639
|
|
|
641
|
-
// We selected a new day but kept everything else the same.
|
|
642
|
-
//
|
|
643
|
-
|
|
644
|
-
const newFromValue = `${date.slice(0, -2)}${newDateToSelect}`;
|
|
645
|
-
expect(screen.getByDisplayValue(newFromValue)).toBeInTheDocument();
|
|
640
|
+
// We selected a new day but kept everything else the same.
|
|
641
|
+
// Example: 2021-03-02 -> 5 is selected -> 2021-03-05
|
|
642
|
+
expect(screen.getByDisplayValue("1988-03-05")).toBeInTheDocument();
|
|
646
643
|
// The "To" input should only have the older value now.
|
|
647
|
-
expect(screen.getAllByDisplayValue(date)).toHaveLength(1);
|
|
644
|
+
// expect(screen.getAllByDisplayValue(date)).toHaveLength(1);
|
|
648
645
|
|
|
649
646
|
// Now select the "To" date.
|
|
650
647
|
userEvent.click(toInput);
|
|
651
648
|
// The popup displays.
|
|
652
649
|
userEvent.click(screen.getByText(newDateTo));
|
|
653
650
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
expect(screen.
|
|
651
|
+
expect(screen.getByDisplayValue("1988-03-25")).toBeInTheDocument();
|
|
652
|
+
// The original date values are no longer in display.
|
|
653
|
+
expect(screen.queryByDisplayValue("1988-03-02")).not.toBeInTheDocument();
|
|
654
|
+
expect(screen.queryByDisplayValue("1988-03-28")).not.toBeInTheDocument();
|
|
658
655
|
// The "From" date value wasn't affected by this!
|
|
659
|
-
expect(screen.getByDisplayValue(
|
|
656
|
+
expect(screen.getByDisplayValue("1988-03-05")).toBeInTheDocument();
|
|
660
657
|
});
|
|
661
|
-
*/
|
|
662
658
|
});
|
|
663
659
|
|
|
664
660
|
describe("Popup Calendar", () => {
|
|
@@ -764,33 +760,38 @@ describe("DatePicker", () => {
|
|
|
764
760
|
render(
|
|
765
761
|
<DatePicker
|
|
766
762
|
dateType={DatePickerTypes.Month}
|
|
763
|
+
initialDate="4/1/1988"
|
|
767
764
|
labelText="Select the month you want to visit NYPL"
|
|
768
765
|
/>
|
|
769
766
|
);
|
|
770
767
|
const input = screen.getByLabelText(
|
|
771
768
|
/Select the month you want to visit NYPL/i
|
|
772
769
|
);
|
|
773
|
-
|
|
774
|
-
|
|
770
|
+
// In the "month" format.
|
|
771
|
+
const date = "04-1988";
|
|
772
|
+
// Let's select May as the new month.
|
|
773
|
+
let currentMonthSelected = monthArray[4];
|
|
775
774
|
let currentMonthSelectedDisplay = currentMonthSelected.slice(0, 3);
|
|
776
775
|
|
|
776
|
+
// We start off with April being displayed as "4-1988".
|
|
777
777
|
expect(screen.getByDisplayValue(date)).toBeInTheDocument();
|
|
778
778
|
expect(
|
|
779
779
|
screen.queryByText(currentMonthSelectedDisplay)
|
|
780
780
|
).not.toBeInTheDocument();
|
|
781
781
|
|
|
782
|
-
// Let's select a new day
|
|
782
|
+
// Let's select a new day by first clicking on the input to open
|
|
783
|
+
// the calendar popup.
|
|
783
784
|
userEvent.click(input);
|
|
784
|
-
// The popup displays.
|
|
785
785
|
|
|
786
|
+
// Now "May" appears as the next month in the calendar popup.
|
|
786
787
|
expect(screen.getByText(currentMonthSelectedDisplay)).toBeInTheDocument();
|
|
787
788
|
|
|
788
|
-
userEvent.click(screen.getByText(
|
|
789
|
+
userEvent.click(screen.getByText(currentMonthSelectedDisplay));
|
|
789
790
|
|
|
790
791
|
// We selected a new month but kept the year the same.
|
|
791
|
-
// Example:
|
|
792
|
+
// Example: 04-2021 -> "May" -> 05-2021
|
|
792
793
|
expect(
|
|
793
|
-
screen.getByDisplayValue(`
|
|
794
|
+
screen.getByDisplayValue(`05-${date.substr(3)}`)
|
|
794
795
|
).toBeInTheDocument();
|
|
795
796
|
});
|
|
796
797
|
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import React, { useState, forwardRef } from "react";
|
|
2
2
|
import ReactDatePicker from "react-datepicker";
|
|
3
3
|
|
|
4
|
-
import { FormRow, FormField } from "../Form/Form";
|
|
5
4
|
import { DatePickerTypes } from "./DatePickerTypes";
|
|
5
|
+
import Fieldset from "../Fieldset/Fieldset";
|
|
6
|
+
import { FormRow, FormField } from "../Form/Form";
|
|
7
|
+
import { FormSpacing } from "../Form/FormTypes";
|
|
8
|
+
import HelperErrorText from "../HelperErrorText/HelperErrorText";
|
|
6
9
|
import TextInput, {
|
|
7
10
|
InputProps,
|
|
8
11
|
TextInputRefType,
|
|
9
12
|
} from "../TextInput/TextInput";
|
|
10
|
-
import HelperErrorText from "../HelperErrorText/HelperErrorText";
|
|
11
13
|
import generateUUID from "../../helpers/generateUUID";
|
|
12
|
-
import Fieldset from "../Fieldset/Fieldset";
|
|
13
14
|
import { useMultiStyleConfig } from "@chakra-ui/system";
|
|
14
15
|
|
|
15
16
|
// The object shape for the DatePicker's start and end date state values.
|
|
@@ -214,7 +215,9 @@ const DateRangeRow: React.FC<DateRangeRowProps> = ({
|
|
|
214
215
|
children,
|
|
215
216
|
}) =>
|
|
216
217
|
isDateRange ? (
|
|
217
|
-
<FormRow id={`${id}-form-row`}
|
|
218
|
+
<FormRow id={`${id}-form-row`} gap={FormSpacing.ExtraSmall}>
|
|
219
|
+
{children}
|
|
220
|
+
</FormRow>
|
|
218
221
|
) : (
|
|
219
222
|
<>{children}</>
|
|
220
223
|
);
|
|
@@ -19,18 +19,18 @@
|
|
|
19
19
|
&--keyboard-selected,
|
|
20
20
|
&--in-range,
|
|
21
21
|
&--in-selecting-range {
|
|
22
|
-
background-color:
|
|
22
|
+
background-color: var(--nypl-colors-ui-black);
|
|
23
23
|
border-radius: 0;
|
|
24
|
-
color:
|
|
24
|
+
color: var(--nypl-colors-ui-white);
|
|
25
25
|
opacity: 0.3;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
// Selected states.
|
|
29
29
|
&-text--selected,
|
|
30
30
|
&--selected {
|
|
31
|
-
background-color:
|
|
31
|
+
background-color: var(--nypl-colors-ui-black);
|
|
32
32
|
border-radius: 0;
|
|
33
|
-
color:
|
|
33
|
+
color: var(--nypl-colors-ui-white);
|
|
34
34
|
opacity: 1;
|
|
35
35
|
}
|
|
36
36
|
}
|