@nypl/design-system-react-components 0.25.3 → 0.25.7
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 +65 -0
- package/README.md +47 -11
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +4 -0
- package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +1 -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 +1022 -455
- 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 +1015 -444
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/resources.scss +180 -170
- package/dist/styles.css +1 -1
- package/dist/theme/components/breadcrumb.d.ts +9 -0
- 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 +71 -83
- 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 +24 -8
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +33 -0
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +5 -1
- package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +1 -0
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +297 -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 +66 -21
- package/src/components/SearchBar/SearchBar.stories.mdx +110 -11
- package/src/components/SearchBar/SearchBar.tsx +15 -5
- 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 +12 -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/breadcrumb.ts +10 -0
- 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
|
@@ -237,7 +237,7 @@ help reduce any visual mistakes.
|
|
|
237
237
|
|
|
238
238
|
<Canvas>
|
|
239
239
|
<DSProvider>
|
|
240
|
-
<div style={{ display: "flex",
|
|
240
|
+
<div style={{ display: "flex", flexDirection: "column" }}>
|
|
241
241
|
<div style={{ width: "300px" }}>
|
|
242
242
|
A regular button:
|
|
243
243
|
<Button buttonType={ButtonTypes.Primary} id="button-ex4" type="submit">
|
|
@@ -28,20 +28,34 @@ import { getCategory } from "../../utils/componentCategories";
|
|
|
28
28
|
|
|
29
29
|
The DS adheres to four global breakpoints for responsive layouts and typography.
|
|
30
30
|
|
|
31
|
-
- Desktop: 1280px
|
|
32
|
-
- Tablet Landscape: 960px
|
|
33
|
-
- Tablet Portrait: 600px
|
|
34
31
|
- Mobile: 320px
|
|
32
|
+
- Tablet Portrait: 600px
|
|
33
|
+
- Tablet Landscape: 960px
|
|
34
|
+
- Desktop: 1280px
|
|
35
35
|
|
|
36
36
|
## CSS Variables
|
|
37
37
|
|
|
38
38
|
The following CSS variables are available through the DS.
|
|
39
39
|
|
|
40
|
+
```scss
|
|
41
|
+
--nypl-breakpoint-small: 320px;
|
|
42
|
+
--nypl-breakpoint-medium: 600px;
|
|
43
|
+
--nypl-breakpoint-large: 960px;
|
|
44
|
+
--nypl-breakpoint-xl: 1280px;
|
|
40
45
|
```
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
|
|
47
|
+
## SCSS Variables
|
|
48
|
+
|
|
49
|
+
If you are using SCSS and imported the NYPL Design System `/dist/resources.scss`
|
|
50
|
+
file, then you can use the following SCSS variables in your media queries or
|
|
51
|
+
SCSS `breakpoint` function (if used).
|
|
52
|
+
|
|
53
|
+
```scss
|
|
54
|
+
$nypl-breakpoint-small: 320px;
|
|
55
|
+
$nypl-breakpoint-medium: 600px;
|
|
56
|
+
$nypl-breakpoint-large: 960px;
|
|
57
|
+
$nypl-breakpoint-xl: 1280px;
|
|
58
|
+
$nypl-max-width: $nypl-breakpoint-xl;
|
|
45
59
|
```
|
|
46
60
|
|
|
47
61
|
## Figma Reference
|
|
@@ -27,8 +27,7 @@ import DSProvider from "../../theme/provider";
|
|
|
27
27
|
parameters={{
|
|
28
28
|
design: {
|
|
29
29
|
type: "figma",
|
|
30
|
-
url:
|
|
31
|
-
"https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Master?node-id=11477%3A2298",
|
|
30
|
+
url: "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Master?node-id=11477%3A2298",
|
|
32
31
|
},
|
|
33
32
|
}}
|
|
34
33
|
/>
|
|
@@ -123,6 +122,7 @@ component. Note that the `SearchBar` type is only used internally in the
|
|
|
123
122
|
<Button buttonType={ButtonTypes.Pill}>Pill Button</Button>
|
|
124
123
|
<Button buttonType={ButtonTypes.Link}>Link Button</Button>
|
|
125
124
|
<Button buttonType={ButtonTypes.SearchBar}>SearchBar Button</Button>
|
|
125
|
+
<Button buttonType={ButtonTypes.NoBrand}>NoBrand Button</Button>
|
|
126
126
|
</ButtonGroup>
|
|
127
127
|
</DSProvider>
|
|
128
128
|
</Canvas>
|
|
@@ -160,6 +160,11 @@ component. Note that the `SearchBar` type is only used internally in the
|
|
|
160
160
|
to the `TextInput` component
|
|
161
161
|
- Visual Treatment: rectangular, filled, no border radius on the left side
|
|
162
162
|
|
|
163
|
+
### ButtonTypes.NoBrand
|
|
164
|
+
|
|
165
|
+
- used in cases where there is no brand color
|
|
166
|
+
- Visual Treatment: rectangular, filled with a black background
|
|
167
|
+
|
|
163
168
|
## Patterns
|
|
164
169
|
|
|
165
170
|
- Buttons are blue by default.
|
|
@@ -169,6 +174,8 @@ component. Note that the `SearchBar` type is only used internally in the
|
|
|
169
174
|
include an up arrow icon.
|
|
170
175
|
- Previous and Next buttons should be set as `ButtonTypes.Secondary` and be
|
|
171
176
|
wrapped in a `ButtonGroup`.
|
|
177
|
+
- Only use the `ButtonTypes.NoBrand` style where there is no brand color. _This
|
|
178
|
+
should be rarely used._
|
|
172
179
|
|
|
173
180
|
<Canvas>
|
|
174
181
|
<DSProvider>
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Meta,
|
|
3
|
+
Story,
|
|
4
|
+
Canvas,
|
|
5
|
+
ArgsTable,
|
|
6
|
+
Description,
|
|
7
|
+
} from "@storybook/addon-docs/blocks";
|
|
8
|
+
import { withDesign } from "storybook-addon-designs";
|
|
9
|
+
import { getCategory } from "../../utils/componentCategories";
|
|
10
|
+
|
|
11
|
+
<Meta title={getCategory("Design Tokens")} />
|
|
12
|
+
|
|
13
|
+
# Design Tokens
|
|
14
|
+
|
|
15
|
+
| Table of Contents |
|
|
16
|
+
| ------------------------------------------------------------------------------------ |
|
|
17
|
+
| 1. [What are Design Tokens?](#what-are-design-tokens) |
|
|
18
|
+
| 2. [Why Use Design Tokens?](#why-use-design-tokens) |
|
|
19
|
+
| 3. [How to Use the NYPL Design Tokens](#figma-reference) |
|
|
20
|
+
| 4. [Using NYPL Design Tokens in CSS](#using-nypl-design-tokens-in-css) |
|
|
21
|
+
| 5. [Using NYPL Design Tokens in Javascript](#using-nypl-design-tokens-in-javascript) |
|
|
22
|
+
| 6. [NYPL Design Token Categories](#nypl-design-token-categories) |
|
|
23
|
+
|
|
24
|
+
## What are Design Tokens?
|
|
25
|
+
|
|
26
|
+
Design tokens are the style values that define a design system. These values can include, but may not be limited to, spacing, color, typography, breakpoints and object styles. Ultimately, these values are used to construct and maintain the components that make up our system.
|
|
27
|
+
|
|
28
|
+
## Why Use Design Tokens?
|
|
29
|
+
|
|
30
|
+
_"With design tokens, you can capture low-level values and then use them to create the styles for your product or app. You can maintain a scalable and consistent visual system for UI development."_ – Jina Bolton, Lead Designer for the Salesforce Design System
|
|
31
|
+
|
|
32
|
+
Design tokens are a single source of truth when it comes to styles. They allow an organization to more easily build multiple applications – web and/or native – that feel and look the same without slowing down the development team.
|
|
33
|
+
|
|
34
|
+
## How to Use the NYPL Design Tokens
|
|
35
|
+
|
|
36
|
+
The NYPL design tokens are built into the NYPL Design System (the DS) and are offered in two formats for consumption: CSS variables and javascript data objects. To access either of these formats, the DS v0.25.2 or higher needs to be properly installed in a consuming React application.
|
|
37
|
+
|
|
38
|
+
## Using NYPL Design Tokens in CSS
|
|
39
|
+
|
|
40
|
+
If your app uses CSS or SCSS to handle styles, the DS creates standard CSS custom properties (e.g. variables) for consumption in your stylesheets. If the DS is properly installed, the CSS custom properties will be available for you to use. Nothing more needs to be done to your app.
|
|
41
|
+
|
|
42
|
+
To assist with CSS scope isolation, all of the CSS custom properties created by the DS are prefixed with "nypl." Please see the examples below.
|
|
43
|
+
|
|
44
|
+
```css
|
|
45
|
+
--nypl-colors-brand-primary
|
|
46
|
+
--nypl-colors-brand-secondary
|
|
47
|
+
--nypl-fontSizes-sm
|
|
48
|
+
--nypl-fontSizes-md
|
|
49
|
+
--nypl-fontSizes-lg
|
|
50
|
+
--nypl-fontSizes-xl
|
|
51
|
+
--nypl-space-xxs
|
|
52
|
+
--nypl-space-xs
|
|
53
|
+
--nypl-space-s
|
|
54
|
+
--nypl-space-m
|
|
55
|
+
--nypl-space-l
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The CSS custom properties are defined on the :root pseudo-class and should be implemented using standard CSS custom properties conventions.
|
|
59
|
+
|
|
60
|
+
```css
|
|
61
|
+
/* Property Declaration in the DS */
|
|
62
|
+
:root {
|
|
63
|
+
--nypl-colors-brand-primary: #c60917;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* Property Usage in Your Application */
|
|
67
|
+
.custom-button {
|
|
68
|
+
background: var(--nypl-colors-brand-primary);
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Using NYPL Design Tokens in Javascript
|
|
73
|
+
|
|
74
|
+
If you would like to use CSS-in-JS styles in your React components, the `useNYPLTheme` hook will provide you with NYPL design token values. The hook depends on the `DSProvider` component and will not work properly outside of the `DSProvider` wrapper component.
|
|
75
|
+
|
|
76
|
+
After importing and implementing the `DSProvider` wrapper component, as explained in the `DSProvider` section of the [DS Chakra UI](?path=/story/chakra-ui--page#dsprovider) document, your children components can use this hook function.
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
import { useNYPLTheme } from "@nypl/design-system-react-components";
|
|
80
|
+
const theme = useNYPLTheme();
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The theme variable will be a javascript object containing the NYPL design token style values. This will allow you to use design token values in your components through CSS-in-JS.
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
// theme
|
|
87
|
+
{
|
|
88
|
+
breakpoints: { ... },
|
|
89
|
+
colors: {
|
|
90
|
+
brand: { ... },
|
|
91
|
+
section: { ... },
|
|
92
|
+
transparent: { ... },
|
|
93
|
+
ui: { ... },
|
|
94
|
+
},
|
|
95
|
+
fontSizes: { ... },
|
|
96
|
+
fontWeights: { ... },
|
|
97
|
+
fonts: { ... },
|
|
98
|
+
radii: { ... },
|
|
99
|
+
space: { ... },
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### Using in DS Components
|
|
104
|
+
|
|
105
|
+
The general rule of thumb is that DS components and the available variants should be used with the styles and variants as they are shown in Storybook, but there may be rare times when a component does require a modification. That said, if a DS component does need an updated style, first contact the Design System and UX teams about this update.
|
|
106
|
+
|
|
107
|
+
If you receive approval to make a change in a consuming app, then you can add styles directly to the `additionalStyles` prop. For example, if the `Heading` component needs to render text in NYPL's "success primary" green color and add a bold font weight, then you can do the following:
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
const theme = useNYPLTheme();
|
|
111
|
+
|
|
112
|
+
// ...
|
|
113
|
+
return (
|
|
114
|
+
<div>
|
|
115
|
+
<Heading
|
|
116
|
+
level={2}
|
|
117
|
+
additionalStyles={{
|
|
118
|
+
color: theme.colors.ui.success.primary,
|
|
119
|
+
fontWeight: theme.fontWeights.bold,
|
|
120
|
+
}}
|
|
121
|
+
>
|
|
122
|
+
Get a Digital Library Card Today in a Few Easy Steps
|
|
123
|
+
</Heading>
|
|
124
|
+
</div>
|
|
125
|
+
);
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
IMPORTANT: At the moment, not all DS components have this prop or feature.
|
|
129
|
+
|
|
130
|
+
#### Using in HTML Components
|
|
131
|
+
|
|
132
|
+
For styling standard HTML elements, use the `style` attribute to add inline styles.
|
|
133
|
+
|
|
134
|
+
```html
|
|
135
|
+
<p style={{ color: theme.colors.ui.success.primary }}>
|
|
136
|
+
If you are 13 or older and live, work, attend school, or pay property
|
|
137
|
+
taxes in New York State, you can get a free digital library card right
|
|
138
|
+
now using this online form. Visitors to New York State can also use this
|
|
139
|
+
form to apply for a temporary card.
|
|
140
|
+
</p>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
#### Using in Styled Components
|
|
144
|
+
|
|
145
|
+
For adding theme styles to styled-objects, use the theme object as a standard javascript variable.
|
|
146
|
+
|
|
147
|
+
```tsx
|
|
148
|
+
const CustomButton = styled.button`
|
|
149
|
+
background: ${theme.colors.brand.primary};
|
|
150
|
+
`;
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## NYPL Design Token Categories
|
|
154
|
+
|
|
155
|
+
The DS design tokens are broken into the following categories:
|
|
156
|
+
|
|
157
|
+
- [breakpoints](?path=/story/documentation-style-guide-breakpoints--page)
|
|
158
|
+
- [colors](?path=/story/documentation-style-guide-colors--page)
|
|
159
|
+
- brand
|
|
160
|
+
- section
|
|
161
|
+
- transparent
|
|
162
|
+
- ui
|
|
163
|
+
- radii
|
|
164
|
+
- [spacing](?path=/story/documentation-style-guide-spacing--page)
|
|
165
|
+
- [typography](?path=/story/documentation-style-guide-typography--page)
|
|
166
|
+
- font families
|
|
167
|
+
- font sizes
|
|
168
|
+
- font weights
|
|
169
|
+
|
|
170
|
+
For details related to a specific category, please refer to the corresponding section in the Style Guide available in the DS Storybook.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import {
|
|
3
3
|
Box,
|
|
4
|
-
Tabs as ChakraTabs,
|
|
5
|
-
TabList,
|
|
6
4
|
Tab,
|
|
5
|
+
TabList,
|
|
7
6
|
TabPanels,
|
|
8
7
|
TabPanel,
|
|
8
|
+
Tabs as ChakraTabs,
|
|
9
9
|
useMultiStyleConfig,
|
|
10
10
|
} from "@chakra-ui/react";
|
|
11
11
|
|
|
@@ -63,7 +63,7 @@ const getElementsFromContentData = (data, useHash) => {
|
|
|
63
63
|
"needed, consider other navigational patterns."
|
|
64
64
|
);
|
|
65
65
|
}
|
|
66
|
-
data.
|
|
66
|
+
data.forEach((tab, index) => {
|
|
67
67
|
let tempPanel;
|
|
68
68
|
// For URL hash enabled tabs, we need to add a custom `onClick` to handle the URL hash.
|
|
69
69
|
const tempTab = (
|
|
@@ -108,7 +108,7 @@ const getElementsFromChildren = (children) => {
|
|
|
108
108
|
return {};
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
children.
|
|
111
|
+
children.forEach((child) => {
|
|
112
112
|
if (child.type === TabList || child.props.mdxType === "TabList") {
|
|
113
113
|
tabs.push(child);
|
|
114
114
|
|
|
@@ -170,7 +170,7 @@ function Tabs(props: React.PropsWithChildren<TabsProps>) {
|
|
|
170
170
|
if (windowDimensions.width > 600) {
|
|
171
171
|
goToStart();
|
|
172
172
|
}
|
|
173
|
-
}, [windowDimensions.width]);
|
|
173
|
+
}, [goToStart, windowDimensions.width]);
|
|
174
174
|
const previousButton = (
|
|
175
175
|
<Button
|
|
176
176
|
buttonType={ButtonTypes.Primary}
|
|
@@ -507,10 +507,10 @@ This is best viewed in the Storybook "Canvas" and not "Docs" section.
|
|
|
507
507
|
imageAspectRatio={ImageRatios.Square}
|
|
508
508
|
imageSize={ImageSizes.Small}
|
|
509
509
|
>
|
|
510
|
-
<CardHeading level={HeadingLevels.
|
|
510
|
+
<CardHeading level={HeadingLevels.Two} id="heading1">
|
|
511
511
|
Small Animal Image
|
|
512
512
|
</CardHeading>
|
|
513
|
-
<CardHeading level={HeadingLevels.
|
|
513
|
+
<CardHeading level={HeadingLevels.Three} id="heading2">
|
|
514
514
|
Animal info
|
|
515
515
|
</CardHeading>
|
|
516
516
|
<CardContent>
|
|
@@ -530,7 +530,7 @@ This is best viewed in the Storybook "Canvas" and not "Docs" section.
|
|
|
530
530
|
backgroundColor="#616161"
|
|
531
531
|
foregroundColor="#FFF"
|
|
532
532
|
>
|
|
533
|
-
<CardHeading id="heading1" level={
|
|
533
|
+
<CardHeading id="heading1-footer" level={HeadingLevels.Two}>
|
|
534
534
|
Footer
|
|
535
535
|
</CardHeading>
|
|
536
536
|
<CardContent>
|
|
@@ -542,25 +542,25 @@ This is best viewed in the Storybook "Canvas" and not "Docs" section.
|
|
|
542
542
|
</CardContent>
|
|
543
543
|
<CardActions>
|
|
544
544
|
<Link
|
|
545
|
-
href="javascript:void(0);"
|
|
546
545
|
attributes={{
|
|
547
546
|
style: { color: "#FFF", textDecoration: "underline" },
|
|
548
547
|
}}
|
|
548
|
+
href="#"
|
|
549
549
|
>
|
|
550
550
|
Facebook
|
|
551
551
|
</Link>
|
|
552
552
|
,<Link
|
|
553
|
-
href="javascript:void(0);"
|
|
554
553
|
attributes={{
|
|
555
554
|
style: { color: "#FFF", textDecoration: "underline" },
|
|
556
555
|
}}
|
|
556
|
+
href="#"
|
|
557
557
|
>
|
|
558
558
|
Instagram
|
|
559
559
|
</Link>,<Link
|
|
560
|
-
href="javascript:void(0);"
|
|
561
560
|
attributes={{
|
|
562
561
|
style: { color: "#FFF", textDecoration: "underline" },
|
|
563
562
|
}}
|
|
563
|
+
href="#"
|
|
564
564
|
>
|
|
565
565
|
Twitter
|
|
566
566
|
</Link>
|
|
@@ -22,6 +22,8 @@ export interface InputProps {
|
|
|
22
22
|
attributes?: { [key: string]: any };
|
|
23
23
|
/** A class name for the TextInput parent div. */
|
|
24
24
|
className?: string;
|
|
25
|
+
/** The starting value of the input field. */
|
|
26
|
+
defaultValue?: string;
|
|
25
27
|
/** Populates the HelperErrorText for the standard state */
|
|
26
28
|
helperText?: string;
|
|
27
29
|
/** ID that other components can cross reference for accessibility purposes */
|
|
@@ -37,6 +39,8 @@ export interface InputProps {
|
|
|
37
39
|
/** Provides text for a `Label` component if `showLabel` is set to true;
|
|
38
40
|
* populates an `aria-label` attribute if `showLabel` is set to false. */
|
|
39
41
|
labelText: string;
|
|
42
|
+
/** Used to reference the input element in forms. */
|
|
43
|
+
name?: string;
|
|
40
44
|
/** The action to perform on the `input`/`textarea`'s onChange function */
|
|
41
45
|
onChange?: (
|
|
42
46
|
event:
|
|
@@ -53,6 +57,8 @@ export interface InputProps {
|
|
|
53
57
|
/** Offers the ability to show the "Required"/"Optional" label onscreen or
|
|
54
58
|
* hide it. True by default. */
|
|
55
59
|
showOptReqLabel?: boolean;
|
|
60
|
+
/** The amount to increase or decrease when using the number type. */
|
|
61
|
+
step?: number;
|
|
56
62
|
/** HTML Input types as defined by MDN: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input */
|
|
57
63
|
type?: TextInputTypes;
|
|
58
64
|
/** Populates the value of the input/textarea elements */
|
|
@@ -78,6 +84,7 @@ const TextInput = React.forwardRef<TextInputRefType, InputProps>(
|
|
|
78
84
|
additionalStyles = {},
|
|
79
85
|
attributes = {},
|
|
80
86
|
className,
|
|
87
|
+
defaultValue,
|
|
81
88
|
helperText,
|
|
82
89
|
id = generateUUID(),
|
|
83
90
|
invalidText,
|
|
@@ -85,11 +92,13 @@ const TextInput = React.forwardRef<TextInputRefType, InputProps>(
|
|
|
85
92
|
isInvalid = false,
|
|
86
93
|
isRequired = false,
|
|
87
94
|
labelText,
|
|
95
|
+
name,
|
|
88
96
|
onChange,
|
|
89
97
|
placeholder,
|
|
90
98
|
showHelperInvalidText = true,
|
|
91
99
|
showLabel = true,
|
|
92
100
|
showOptReqLabel = true,
|
|
101
|
+
step = 1,
|
|
93
102
|
type = TextInputTypes.text,
|
|
94
103
|
value,
|
|
95
104
|
variantType = TextInputVariants.Default,
|
|
@@ -132,16 +141,20 @@ const TextInput = React.forwardRef<TextInputRefType, InputProps>(
|
|
|
132
141
|
|
|
133
142
|
// When the type is "hidden", the input element needs fewer attributes.
|
|
134
143
|
options = isHidden
|
|
135
|
-
? { id, "aria-hidden": isHidden, onChange, ref }
|
|
144
|
+
? { id, "aria-hidden": isHidden, name, onChange, ref }
|
|
136
145
|
: {
|
|
137
|
-
id,
|
|
138
146
|
"aria-required": isRequired,
|
|
147
|
+
defaultValue,
|
|
148
|
+
id,
|
|
139
149
|
isDisabled,
|
|
140
150
|
isRequired,
|
|
141
151
|
isInvalid,
|
|
142
152
|
placeholder,
|
|
153
|
+
name,
|
|
143
154
|
onChange,
|
|
144
155
|
ref,
|
|
156
|
+
// The `step` attribute is useful for the number type.
|
|
157
|
+
step: type === TextInputTypes.number ? step : null,
|
|
145
158
|
...attributes,
|
|
146
159
|
};
|
|
147
160
|
// For `input` and `textarea`, all attributes are the same but `input`
|
|
@@ -11,6 +11,7 @@ export enum TextInputTypes {
|
|
|
11
11
|
url = "url",
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
// Only used internally in `TextInput`.
|
|
14
15
|
export enum TextInputFormats {
|
|
15
16
|
email = "jdoe@domain.com",
|
|
16
17
|
hidden = "",
|
|
@@ -23,6 +24,7 @@ export enum TextInputFormats {
|
|
|
23
24
|
url = "https://domain.com",
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
// Only used internally in `TextInput` and `SearchBar`.
|
|
26
28
|
export enum TextInputVariants {
|
|
27
29
|
Default = "default",
|
|
28
30
|
SearchBar = "searchBar",
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
Story,
|
|
4
4
|
Canvas,
|
|
5
5
|
ArgsTable,
|
|
6
|
-
Preview,
|
|
7
6
|
Description,
|
|
8
7
|
} from "@storybook/addon-docs/blocks";
|
|
9
8
|
import { withDesign } from "storybook-addon-designs";
|
|
@@ -46,7 +45,7 @@ The `VideoPlayer` component is used to embed a `Vimeo` or `YouTube` video player
|
|
|
46
45
|
|
|
47
46
|
The `aspectRatio` prop is used to control the sizing of the space allotted for the video rendering. Ultimately, the `aspectRatio` prop should be set to match the aspect ratio of the video that is being rendered. The default aspect ratio is `16:9`.
|
|
48
47
|
|
|
49
|
-
<
|
|
48
|
+
<Canvas withToolbar>
|
|
50
49
|
<Story
|
|
51
50
|
name="VideoPlayer"
|
|
52
51
|
args={{
|
|
@@ -72,7 +71,7 @@ The `aspectRatio` prop is used to control the sizing of the space allotted for t
|
|
|
72
71
|
/>
|
|
73
72
|
)}
|
|
74
73
|
</Story>
|
|
75
|
-
</
|
|
74
|
+
</Canvas>
|
|
76
75
|
|
|
77
76
|
<ArgsTable story="VideoPlayer" />
|
|
78
77
|
|
|
@@ -87,8 +87,8 @@ wrap the elements in the `DSProvider` component.
|
|
|
87
87
|
<Canvas>
|
|
88
88
|
<DSProvider>
|
|
89
89
|
<ButtonGroup>
|
|
90
|
-
<Button
|
|
91
|
-
<Button
|
|
90
|
+
<Button isDisabled={false}>Enabled</Button>
|
|
91
|
+
<Button isDisabled>Disabled</Button>
|
|
92
92
|
</ButtonGroup>
|
|
93
93
|
</DSProvider>
|
|
94
94
|
</Canvas>
|
package/src/index.ts
CHANGED
|
@@ -16,6 +16,7 @@ export {
|
|
|
16
16
|
} from "@chakra-ui/react";
|
|
17
17
|
export { default as Accordion } from "./components/Accordion/Accordion";
|
|
18
18
|
export { default as Breadcrumbs } from "./components/Breadcrumbs/Breadcrumbs";
|
|
19
|
+
export { ColorVariants } from "./components/Breadcrumbs/BreadcrumbsTypes";
|
|
19
20
|
export { default as Button } from "./components/Button/Button";
|
|
20
21
|
export { ButtonTypes } from "./components/Button/ButtonTypes";
|
|
21
22
|
export {
|
|
@@ -32,6 +33,7 @@ export { CheckboxGroupLayoutTypes } from "./components/CheckboxGroup/CheckboxGro
|
|
|
32
33
|
export { default as DatePicker } from "./components/DatePicker/DatePicker";
|
|
33
34
|
export { DatePickerTypes } from "./components/DatePicker/DatePickerTypes";
|
|
34
35
|
export { default as DSProvider } from "./theme/provider";
|
|
36
|
+
export { default as Fieldset } from "./components/Fieldset/Fieldset";
|
|
35
37
|
export { default as Form, FormField, FormRow } from "./components/Form/Form";
|
|
36
38
|
export { FormSpacing } from "./components/Form/FormTypes";
|
|
37
39
|
export { GridGaps } from "./components/Grid/GridTypes";
|
|
@@ -46,11 +48,13 @@ export { HeroTypes } from "./components/Hero/HeroTypes";
|
|
|
46
48
|
export { default as HorizontalRule } from "./components/HorizontalRule/HorizontalRule";
|
|
47
49
|
export { default as Icon } from "./components/Icons/Icon";
|
|
48
50
|
export {
|
|
51
|
+
IconAlign,
|
|
52
|
+
IconColors,
|
|
49
53
|
IconNames,
|
|
50
|
-
LogoNames,
|
|
51
54
|
IconRotationTypes,
|
|
52
|
-
IconColors,
|
|
53
55
|
IconSizes,
|
|
56
|
+
IconTypes,
|
|
57
|
+
LogoNames,
|
|
54
58
|
} from "./components/Icons/IconTypes";
|
|
55
59
|
export { default as Image } from "./components/Image/Image";
|
|
56
60
|
export {
|
|
@@ -69,18 +73,21 @@ export { default as Modal } from "./components/Modal/Modal";
|
|
|
69
73
|
export { default as Notification } from "./components/Notification/Notification";
|
|
70
74
|
export { NotificationTypes } from "./components/Notification/NotificationTypes";
|
|
71
75
|
export { default as Pagination } from "./components/Pagination/Pagination";
|
|
76
|
+
export { default as ProgressIndicator } from "./components/ProgressIndicator/ProgressIndicator";
|
|
72
77
|
export { default as Radio } from "./components/Radio/Radio";
|
|
73
78
|
export { default as RadioGroup } from "./components/RadioGroup/RadioGroup";
|
|
74
79
|
export { RadioGroupLayoutTypes } from "./components/RadioGroup/RadioGroupLayoutTypes";
|
|
75
80
|
export { default as SearchBar } from "./components/SearchBar/SearchBar";
|
|
81
|
+
export { default as Select } from "./components/Select/Select";
|
|
76
82
|
export { default as SimpleGrid } from "./components/Grid/SimpleGrid";
|
|
77
83
|
export { default as SkeletonLoader } from "./components/SkeletonLoader/SkeletonLoader";
|
|
78
84
|
export {
|
|
79
85
|
SkeletonLoaderImageRatios,
|
|
80
86
|
SkeletonLoaderLayouts,
|
|
81
87
|
} from "./components/SkeletonLoader/SkeletonLoaderTypes";
|
|
82
|
-
export { default as
|
|
88
|
+
export { default as Slider } from "./components/Slider/Slider";
|
|
83
89
|
export { default as StatusBadge } from "./components/StatusBadge/StatusBadge";
|
|
90
|
+
export { StatusBadgeTypes } from "./components/StatusBadge/StatusBadgeTypes";
|
|
84
91
|
export {
|
|
85
92
|
Tabs,
|
|
86
93
|
TabList,
|
|
@@ -88,8 +95,6 @@ export {
|
|
|
88
95
|
TabPanels,
|
|
89
96
|
TabPanel,
|
|
90
97
|
} from "./components/Tabs/Tabs";
|
|
91
|
-
export { default as Text } from "./components/Text/Text";
|
|
92
|
-
export { TextDisplaySizes } from "./components/Text/TextTypes";
|
|
93
98
|
export {
|
|
94
99
|
TemplateAppContainer,
|
|
95
100
|
Template,
|
|
@@ -101,7 +106,8 @@ export {
|
|
|
101
106
|
TemplateContentSidebar,
|
|
102
107
|
TemplateFooter,
|
|
103
108
|
} from "./components/Template/Template";
|
|
104
|
-
|
|
109
|
+
export { default as Text } from "./components/Text/Text";
|
|
110
|
+
export { TextDisplaySizes } from "./components/Text/TextTypes";
|
|
105
111
|
export {
|
|
106
112
|
default as TextInput,
|
|
107
113
|
TextInputRefType,
|
package/src/resources.scss
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Resources to export as sass mixins
|
|
2
|
-
@import "./styles/
|
|
3
|
-
@import "./styles/
|
|
4
|
-
@import "./styles/
|
|
5
|
-
@import "./styles/
|
|
6
|
-
@import "./styles/
|
|
2
|
+
@import "./styles/base/01-breakpoints";
|
|
3
|
+
@import "./styles/base/02-mixins";
|
|
4
|
+
@import "./styles/space/space-inline";
|
|
5
|
+
@import "./styles/space/space-inset";
|
|
6
|
+
@import "./styles/space/space-stack";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Breakpoint Configuration
|
|
3
3
|
* @see https://github.com/Team-Sass/breakpoint/wiki
|
|
4
|
-
*
|
|
5
4
|
*/
|
|
6
5
|
|
|
7
6
|
// Global Breakpoints
|
|
@@ -12,17 +11,17 @@
|
|
|
12
11
|
// Sass' breakpoint() mixin doesn't work without Sass variables.
|
|
13
12
|
// CSS variables expose the breakpoint variables to consumers.
|
|
14
13
|
:root {
|
|
15
|
-
--breakpoint-small: 320px;
|
|
16
|
-
--breakpoint-medium: 600px;
|
|
17
|
-
--breakpoint-large: 960px;
|
|
18
|
-
--breakpoint-xl: 1280px;
|
|
14
|
+
--nypl-breakpoint-small: 320px;
|
|
15
|
+
--nypl-breakpoint-medium: 600px;
|
|
16
|
+
--nypl-breakpoint-large: 960px;
|
|
17
|
+
--nypl-breakpoint-xl: 1280px;
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
$breakpoint-small: 320px;
|
|
22
|
-
$breakpoint-medium: 600px;
|
|
23
|
-
$breakpoint-large: 960px;
|
|
24
|
-
$breakpoint-xl: 1280px;
|
|
20
|
+
$nypl-breakpoint-small: 320px;
|
|
21
|
+
$nypl-breakpoint-medium: 600px;
|
|
22
|
+
$nypl-breakpoint-large: 960px;
|
|
23
|
+
$nypl-breakpoint-xl: 1280px;
|
|
25
24
|
// The max-width breakpoint is used when the design should be applied at
|
|
26
25
|
// whatever the largest breakpoint is regardless of actual pixel value,
|
|
27
26
|
// e.g. removing outer margin on body wrapper.
|
|
28
|
-
$max-width: $breakpoint-xl;
|
|
27
|
+
$nypl-max-width: $nypl-breakpoint-xl;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
/// Mixin - Clearfix.
|
|
5
5
|
/// Adds clearfix based on http://bourbon.io/docs/#clearfix
|
|
6
|
-
/// use example =
|
|
6
|
+
/// use example = @include clearfix
|
|
7
7
|
|
|
8
8
|
@mixin clearfix {
|
|
9
9
|
&::after {
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
/// Outer container mixin for large screens
|
|
30
30
|
@mixin wrapper(
|
|
31
31
|
$container-max-width: $max-width,
|
|
32
|
-
$outer-container-break: $breakpoint-small,
|
|
32
|
+
$outer-container-break: $nypl-breakpoint-small,
|
|
33
33
|
$v-margin: 0,
|
|
34
34
|
$v-padding: 0,
|
|
35
|
-
$h-padding: var(--space)
|
|
35
|
+
$h-padding: var(--nypl-space-s)
|
|
36
36
|
) {
|
|
37
37
|
margin: #{$v-margin} auto;
|
|
38
38
|
max-width: #{$container-max-width};
|
|
@@ -41,12 +41,12 @@
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
.container {
|
|
44
|
-
|
|
44
|
+
padding: var(--nypl-space-s);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/// Use the breakout mixin for elements that should be edge-to-edge
|
|
48
48
|
/// Even when a parent container uses the wrapper mixin
|
|
49
|
-
@mixin breakout($v-padding: var(--space)) {
|
|
49
|
+
@mixin breakout($v-padding: var(--nypl-space-s)) {
|
|
50
50
|
margin-left: calc(-50vw + 50%);
|
|
51
51
|
margin-right: calc(-50vw + 50%);
|
|
52
52
|
}
|
|
@@ -61,6 +61,17 @@
|
|
|
61
61
|
word-wrap: normal;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
// Focus state mixin
|
|
65
|
+
@mixin focus-outline($darkBackground: false) {
|
|
66
|
+
outline: 2px solid var(--nypl-colors-ui-focus);
|
|
67
|
+
outline-offset: 2px;
|
|
68
|
+
z-index: 9999;
|
|
69
|
+
|
|
70
|
+
@if $darkBackground {
|
|
71
|
+
outline-color: var(--nypl-colors-ui-white);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
64
75
|
//Convert pixel values to rem
|
|
65
76
|
@function to-rem($size) {
|
|
66
77
|
@return $size / 16px * 1rem;
|