@nypl/design-system-react-components 0.25.11 → 0.25.12
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 +31 -0
- package/README.md +4 -16
- package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +1 -0
- package/dist/components/Icons/IconTypes.d.ts +9 -7
- package/dist/components/Logo/LogoSvgs.d.ts +6 -0
- package/dist/components/Logo/LogoTypes.d.ts +6 -0
- package/dist/components/Pagination/Pagination.d.ts +6 -2
- package/dist/components/SearchBar/SearchBar.d.ts +1 -1
- package/dist/components/Template/Template.d.ts +1 -1
- package/dist/design-system-react-components.cjs.development.js +947 -438
- 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 +948 -439
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/theme/components/breadcrumb.d.ts +3 -0
- package/dist/theme/components/checkbox.d.ts +0 -2
- package/dist/theme/components/fieldset.d.ts +2 -0
- package/dist/theme/components/global.d.ts +15 -14
- package/dist/theme/components/globalMixins.d.ts +8 -8
- package/dist/theme/components/list.d.ts +6 -0
- package/dist/theme/components/notification.d.ts +3 -0
- package/dist/theme/components/radio.d.ts +3 -2
- package/dist/theme/components/select.d.ts +2 -9
- package/dist/theme/components/slider.d.ts +8 -4
- package/dist/theme/components/textInput.d.ts +8 -12
- package/dist/theme/components/toggle.d.ts +6 -2
- package/dist/theme/foundations/global.d.ts +31 -3
- package/dist/utils/utils.d.ts +10 -0
- package/package.json +1 -1
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +18 -1
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +10 -0
- package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +1 -0
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +99 -0
- package/src/components/Checkbox/Checkbox.stories.mdx +1 -1
- package/src/components/Checkbox/Checkbox.tsx +1 -0
- package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +6 -6
- package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +18 -18
- package/src/components/Fieldset/Fieldset.stories.mdx +1 -1
- package/src/components/Icons/Icon.stories.mdx +1 -1
- package/src/components/Icons/IconTypes.tsx +8 -6
- package/src/components/List/List.stories.mdx +1 -1
- package/src/components/Logo/Logo.stories.mdx +1 -1
- package/src/components/Logo/LogoSvgs.tsx +12 -0
- package/src/components/Logo/LogoTypes.tsx +6 -0
- package/src/components/Notification/Notification.stories.mdx +6 -1
- package/src/components/Notification/Notification.test.tsx +20 -9
- package/src/components/Notification/Notification.tsx +6 -4
- package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +103 -8
- package/src/components/Pagination/Pagination.stories.mdx +54 -12
- package/src/components/Pagination/Pagination.test.tsx +63 -5
- package/src/components/Pagination/Pagination.tsx +45 -23
- package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +3 -3
- package/src/components/Radio/Radio.stories.mdx +1 -1
- package/src/components/Radio/Radio.tsx +1 -0
- package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +5 -5
- package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +18 -18
- package/src/components/SearchBar/SearchBar.Test.tsx +20 -2
- package/src/components/SearchBar/SearchBar.stories.mdx +4 -4
- package/src/components/SearchBar/SearchBar.tsx +3 -2
- package/src/components/Select/Select.stories.mdx +1 -1
- package/src/components/Slider/Slider.stories.mdx +1 -1
- package/src/components/Slider/Slider.tsx +4 -1
- package/src/components/StyleGuide/Bidirectionality.stories.mdx +4 -4
- package/src/components/StyleGuide/Colors.stories.mdx +33 -18
- package/src/components/Template/Template.stories.mdx +1 -1
- package/src/components/Template/Template.tsx +2 -6
- package/src/components/Template/__snapshots__/Template.test.tsx.snap +2 -2
- package/src/components/Toggle/Toggle.stories.mdx +1 -1
- package/src/components/Toggle/Toggle.tsx +2 -1
- package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +4 -4
- package/src/docs/Chakra.stories.mdx +1 -1
- package/src/styles/base/_place-holder.scss +2 -0
- package/src/styles.scss +0 -2
- package/src/theme/components/breadcrumb.ts +4 -0
- package/src/theme/components/checkbox.ts +3 -7
- package/src/theme/components/fieldset.ts +2 -0
- package/src/theme/components/global.ts +18 -15
- package/src/theme/components/globalMixins.ts +8 -8
- package/src/theme/components/list.ts +4 -0
- package/src/theme/components/notification.ts +3 -0
- package/src/theme/components/radio.ts +3 -6
- package/src/theme/components/select.ts +3 -3
- package/src/theme/components/slider.ts +12 -9
- package/src/theme/components/textInput.ts +2 -2
- package/src/theme/components/toggle.ts +41 -37
- package/src/theme/foundations/colors.ts +19 -12
- package/src/theme/foundations/global.ts +17 -5
- package/src/theme/foundations/typography.ts +1 -1
- package/src/utils/componentCategories.ts +1 -1
- package/src/utils/utils.ts +28 -0
- package/dist/components/Pagination/Pagination.stories.d.ts +0 -13
- package/src/components/Pagination/Pagination.stories.tsx +0 -54
- package/src/styles/base/_03-base.scss +0 -25
- package/src/styles/base/_04-focus.scss +0 -22
|
@@ -82,30 +82,31 @@ const colors: Colors = {
|
|
|
82
82
|
|
|
83
83
|
/** Brand fills for sections on NYPL pages. */
|
|
84
84
|
section: {
|
|
85
|
-
/**
|
|
86
|
-
|
|
87
|
-
primary:
|
|
88
|
-
secondary:
|
|
85
|
+
/** Blogs is used for the Blogs section. */
|
|
86
|
+
blogs: {
|
|
87
|
+
primary: grayLightCool,
|
|
88
|
+
secondary: grayMedium,
|
|
89
89
|
},
|
|
90
90
|
|
|
91
91
|
/** Books and More is used for the Catalog, Staff Picks, Recommendations,
|
|
92
92
|
* New Arrivals, and E-Book Central. */
|
|
93
93
|
"books-and-more": brandObj,
|
|
94
94
|
|
|
95
|
-
/**
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
/** Education is used for the Education section front and associated
|
|
96
|
+
* sub-sections. */
|
|
97
|
+
education: {
|
|
98
|
+
primary: "#1D62E6",
|
|
99
|
+
secondary: "#2540A4",
|
|
99
100
|
},
|
|
100
101
|
|
|
101
102
|
/** Locations is used for Location Finder and all branch pages with
|
|
102
103
|
* the exceptions of some research libraries. */
|
|
103
104
|
locations: brandObj,
|
|
104
105
|
|
|
105
|
-
/**
|
|
106
|
-
|
|
107
|
-
primary:
|
|
108
|
-
secondary:
|
|
106
|
+
/** Research is used for the Research Catalog and SCC. */
|
|
107
|
+
research: {
|
|
108
|
+
primary: "#00838a",
|
|
109
|
+
secondary: "#006166",
|
|
109
110
|
},
|
|
110
111
|
|
|
111
112
|
/** Research libraries with specific brand colors to adhere to. */
|
|
@@ -114,6 +115,12 @@ const colors: Colors = {
|
|
|
114
115
|
schomburg: "#a03e31",
|
|
115
116
|
schwartzman: brandSecondary,
|
|
116
117
|
},
|
|
118
|
+
|
|
119
|
+
/** What's On is used for Exhibitions & Events. */
|
|
120
|
+
"whats-on": {
|
|
121
|
+
primary: "#242424",
|
|
122
|
+
secondary: "#000000",
|
|
123
|
+
},
|
|
117
124
|
},
|
|
118
125
|
|
|
119
126
|
/**
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { activeFocus } from "../components/global";
|
|
2
|
+
import { textMargin } from "../components/global";
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* These rules affect all the global elements on the `body` element of the
|
|
3
|
-
* page when the `DSProvider` component is used.
|
|
4
|
-
* `nypl-ds` CSS class name is not used in a consuming application, these
|
|
5
|
-
* rules will still take effect.
|
|
6
|
+
* page when the `DSProvider` component is used.
|
|
6
7
|
*/
|
|
7
8
|
const global = {
|
|
8
9
|
// styles for the `body` element
|
|
@@ -23,8 +24,19 @@ const global = {
|
|
|
23
24
|
svg: {
|
|
24
25
|
display: "inline",
|
|
25
26
|
},
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
"button, select, input, textarea": {
|
|
28
|
+
"&:not([disabled])": {
|
|
29
|
+
_focus: activeFocus(),
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
"iframe, [href], [tabindex], [contentEditable='true']": {
|
|
33
|
+
_focus: activeFocus(),
|
|
34
|
+
},
|
|
35
|
+
p: textMargin,
|
|
36
|
+
ul: textMargin,
|
|
37
|
+
ol: textMargin,
|
|
38
|
+
"*, *::before, &::after": {
|
|
39
|
+
boxSizing: "inherit",
|
|
28
40
|
},
|
|
29
41
|
};
|
|
30
42
|
|
|
@@ -28,7 +28,7 @@ const typography: Typography = {
|
|
|
28
28
|
// Values from "src/styles/02-typography/_typeface.css"
|
|
29
29
|
fonts: {
|
|
30
30
|
body: "-apple-system, BlinkMacSystemFont, system-ui, sans-serif",
|
|
31
|
-
heading: "-apple-system, BlinkMacSystemFont, system-ui, sans-
|
|
31
|
+
heading: "-apple-system, BlinkMacSystemFont, system-ui, sans-serif",
|
|
32
32
|
},
|
|
33
33
|
// Values from "src/styles/02-typography/_type-scale.css"
|
|
34
34
|
fontSizes: {
|
package/src/utils/utils.ts
CHANGED
|
@@ -44,3 +44,31 @@ export const getStorybookEnumValues = (enumObject, name) => {
|
|
|
44
44
|
};
|
|
45
45
|
return { options, getValue };
|
|
46
46
|
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Given a pagination's pageCount, this will return (1) a page number,
|
|
50
|
+
* derived from the current URL, and (2) a function that, when passed to
|
|
51
|
+
* Pagination component, makes the URL change and refreshes the page.
|
|
52
|
+
* @NOTE this is only used for Storybook documentation.
|
|
53
|
+
*/
|
|
54
|
+
export const getStorybookHrefProps = (pageCount) => {
|
|
55
|
+
// This uses the `addon-queryparams` Storybook addon.
|
|
56
|
+
const urlParams = new URLSearchParams(document.location.search);
|
|
57
|
+
const pageParam = urlParams.get("page");
|
|
58
|
+
|
|
59
|
+
const getPageNumber = (page: number, pageCount: number) => {
|
|
60
|
+
return page > 0 && page <= pageCount ? page : 1;
|
|
61
|
+
};
|
|
62
|
+
const computedCurrentPage =
|
|
63
|
+
pageParam &&
|
|
64
|
+
Number(pageParam) &&
|
|
65
|
+
getPageNumber(Number(pageParam), pageCount);
|
|
66
|
+
const location = window.location;
|
|
67
|
+
// Passing this function into `Pagination` makes the URL to change
|
|
68
|
+
// and refreshes the page.
|
|
69
|
+
const getPageHref = (selectedPage) => {
|
|
70
|
+
return `${location.href}&page=${selectedPage}`;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return { computedCurrentPage, getPageHref };
|
|
74
|
+
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Story } from "@storybook/react/types-6-0";
|
|
2
|
-
import { PaginationProps } from "./Pagination";
|
|
3
|
-
/**
|
|
4
|
-
* PaginationGetPageHref will refresh the browser as a new page is selected.
|
|
5
|
-
* In this example, `getPageHref` creates the `href` attribute for each
|
|
6
|
-
* page URL.
|
|
7
|
-
*/
|
|
8
|
-
export declare const PaginationGetPageHref: Story<PaginationProps>;
|
|
9
|
-
/**
|
|
10
|
-
* PaginationOnPageChange will update the current page to the value that is
|
|
11
|
-
* selected but will not change the URL or refresh the page.
|
|
12
|
-
*/
|
|
13
|
-
export declare const PaginationOnPageChange: Story<PaginationProps>;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Story } from "@storybook/react/types-6-0";
|
|
3
|
-
|
|
4
|
-
import Pagination, { PaginationProps } from "./Pagination";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* PaginationGetPageHref will refresh the browser as a new page is selected.
|
|
8
|
-
* In this example, `getPageHref` creates the `href` attribute for each
|
|
9
|
-
* page URL.
|
|
10
|
-
*/
|
|
11
|
-
export const PaginationGetPageHref: Story<PaginationProps> = (args) => {
|
|
12
|
-
// This uses the `addon-queryparams` Storybook addon.
|
|
13
|
-
const urlParams = new URLSearchParams(document.location.search);
|
|
14
|
-
const pageParam = urlParams.get("page");
|
|
15
|
-
const getPageNumber = (page: number, pageCount: number) => {
|
|
16
|
-
return page > 0 && page <= pageCount ? page : 1;
|
|
17
|
-
};
|
|
18
|
-
const computedCurrentPage =
|
|
19
|
-
pageParam &&
|
|
20
|
-
Number(pageParam) &&
|
|
21
|
-
getPageNumber(Number(pageParam), args.pageCount);
|
|
22
|
-
const location = window.location;
|
|
23
|
-
// Passing this function into `Pagination` makes the URL to change
|
|
24
|
-
// and refreshes the page.
|
|
25
|
-
const getPageHref = (selectedPage) => {
|
|
26
|
-
return `${location.href}&page=${selectedPage}`;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<Pagination
|
|
31
|
-
pageCount={args.pageCount}
|
|
32
|
-
initialPage={computedCurrentPage || args.initialPage}
|
|
33
|
-
getPageHref={getPageHref}
|
|
34
|
-
/>
|
|
35
|
-
);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* PaginationOnPageChange will update the current page to the value that is
|
|
40
|
-
* selected but will not change the URL or refresh the page.
|
|
41
|
-
*/
|
|
42
|
-
export const PaginationOnPageChange: Story<PaginationProps> = (args) => {
|
|
43
|
-
const onPageChange = (currentPage: number) => {
|
|
44
|
-
console.log(`Current page: ${currentPage}`);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<Pagination
|
|
49
|
-
pageCount={args.pageCount}
|
|
50
|
-
initialPage={args.initialPage}
|
|
51
|
-
onPageChange={onPageChange}
|
|
52
|
-
/>
|
|
53
|
-
);
|
|
54
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// Kept for backwards compatibility.
|
|
2
|
-
.nypl-ds {
|
|
3
|
-
box-sizing: border-box;
|
|
4
|
-
color: var(--nypl-colors-ui-black);
|
|
5
|
-
font-family: var(--nypl-fonts-body);
|
|
6
|
-
|
|
7
|
-
// Sets up the base font-size, 1rem, for the system
|
|
8
|
-
font-size: var(--nypl-fontSizes-text-default);
|
|
9
|
-
font-weight: 300;
|
|
10
|
-
line-height: 1.5;
|
|
11
|
-
|
|
12
|
-
// Users with non-overlay scrollbars have a small horizontal scrollbar from
|
|
13
|
-
// our breakout mixin. Fix identified here: https://cloudfour.com/thinks/breaking-out-with-viewport-units-and-calc/#one-big-dumb-caveat
|
|
14
|
-
overflow-x: hidden;
|
|
15
|
-
|
|
16
|
-
p {
|
|
17
|
-
margin: 0 0 var(--nypl-space-s);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
*,
|
|
21
|
-
*::after,
|
|
22
|
-
*::before {
|
|
23
|
-
box-sizing: inherit;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// Apply :focus behavior to focusable elements only (For IE 11)
|
|
2
|
-
.nypl-ds {
|
|
3
|
-
input,
|
|
4
|
-
select,
|
|
5
|
-
textarea,
|
|
6
|
-
button {
|
|
7
|
-
&:not([disabled]) {
|
|
8
|
-
&:focus {
|
|
9
|
-
@include focus-outline;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
iframe,
|
|
15
|
-
[href],
|
|
16
|
-
[tabindex],
|
|
17
|
-
[contentEditable="true"] {
|
|
18
|
-
&:focus {
|
|
19
|
-
@include focus-outline;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|