@nypl/design-system-react-components 0.25.1 → 0.25.5
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 +118 -1
- package/README.md +98 -50
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +4 -0
- package/dist/components/Button/Button.d.ts +13 -8
- package/dist/components/Button/ButtonTypes.d.ts +2 -1
- package/dist/components/Card/Card.d.ts +36 -52
- package/dist/components/Card/CardTypes.d.ts +0 -15
- package/dist/components/Checkbox/Checkbox.d.ts +17 -13
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +4 -2
- package/dist/components/ComponentWrapper/ComponentWrapper.d.ts +15 -0
- package/dist/components/DatePicker/DatePicker.d.ts +36 -34
- package/dist/components/Fieldset/Fieldset.d.ts +25 -0
- package/dist/components/Heading/Heading.d.ts +4 -4
- package/dist/components/HelperErrorText/HelperErrorText.d.ts +17 -14
- package/dist/components/HorizontalRule/HorizontalRule.d.ts +10 -9
- package/dist/components/Icons/Icon.d.ts +8 -0
- package/dist/components/Icons/IconSvgs.d.ts +11 -0
- package/dist/components/Icons/IconTypes.d.ts +11 -0
- package/dist/components/Image/Image.d.ts +19 -9
- package/dist/components/Image/ImageTypes.d.ts +20 -0
- package/dist/components/Link/Link.d.ts +4 -0
- package/dist/components/List/List.d.ts +19 -14
- package/dist/components/Notification/Notification.d.ts +37 -16
- package/dist/components/Pagination/Pagination.d.ts +16 -13
- package/dist/components/Pagination/Pagination.stories.d.ts +2 -0
- package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +29 -0
- package/dist/components/ProgressIndicator/ProgressIndicatorTypes.d.ts +8 -0
- package/dist/components/Radio/Radio.d.ts +2 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +4 -2
- package/dist/components/SearchBar/SearchBar.d.ts +3 -3
- package/dist/components/Select/Select.d.ts +2 -0
- package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +18 -14
- package/dist/components/Slider/Slider.d.ts +57 -0
- package/dist/components/StyleGuide/ColorCard.d.ts +12 -0
- package/dist/components/Tabs/Tabs.d.ts +1 -1
- package/dist/components/TextInput/TextInput.d.ts +12 -0
- package/dist/components/VideoPlayer/VideoPlayer.d.ts +6 -8
- package/dist/components/VideoPlayer/VideoPlayerTypes.d.ts +2 -2
- package/dist/design-system-react-components.cjs.development.js +6131 -3715
- 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 +6124 -3699
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/hooks/tests/useCarouselStyles.test.d.ts +1 -0
- package/dist/hooks/useCarouselStyles.d.ts +16 -0
- package/dist/hooks/useNYPLTheme.d.ts +54 -0
- package/dist/hooks/useWindowSize.d.ts +10 -0
- package/dist/index.d.ts +13 -8
- package/dist/resources.scss +180 -170
- package/dist/styles.css +1 -1
- package/dist/theme/components/button.d.ts +22 -8
- package/dist/theme/components/card.d.ts +168 -0
- package/dist/theme/components/checkbox.d.ts +5 -1
- package/dist/theme/components/checkboxGroup.d.ts +12 -0
- package/dist/theme/components/componentWrapper.d.ts +11 -0
- package/dist/theme/components/datePicker.d.ts +16 -0
- package/dist/theme/components/fieldset.d.ts +27 -0
- package/dist/theme/components/global.d.ts +23 -13
- package/dist/theme/components/globalMixins.d.ts +9 -1
- package/dist/theme/components/heading.d.ts +5 -0
- package/dist/theme/components/helperErrorText.d.ts +10 -0
- package/dist/theme/components/hero.d.ts +1 -0
- package/dist/theme/components/horizontalRule.d.ts +14 -0
- package/dist/theme/components/image.d.ts +31 -0
- package/dist/theme/components/label.d.ts +5 -3
- package/dist/theme/components/link.d.ts +4 -0
- package/dist/theme/components/list.d.ts +89 -0
- package/dist/theme/components/notification.d.ts +75 -0
- package/dist/theme/components/pagination.d.ts +19 -0
- package/dist/theme/components/progressIndicator.d.ts +50 -0
- package/dist/theme/components/radioGroup.d.ts +12 -0
- package/dist/theme/components/select.d.ts +11 -2
- package/dist/theme/components/skeletonLoader.d.ts +98 -0
- package/dist/theme/components/slider.d.ts +51 -0
- package/dist/theme/components/tabs.d.ts +54 -3
- package/dist/theme/components/textInput.d.ts +8 -1
- package/dist/theme/components/videoPlayer.d.ts +40 -0
- package/dist/theme/foundations/breakpoints.d.ts +8 -8
- package/dist/theme/foundations/global.d.ts +6 -1
- package/dist/theme/foundations/radii.d.ts +5 -0
- package/dist/theme/foundations/spacing.d.ts +16 -16
- package/package.json +72 -83
- package/src/__tests__/setup.ts +2 -2
- package/src/components/Accordion/Accordion.stories.mdx +39 -44
- package/src/components/Autosuggest/Autosuggest.stories.mdx +3 -3
- package/src/components/Autosuggest/Autosuggest.stories.tsx +2 -1
- package/src/components/Autosuggest/_Autosuggest.scss +5 -5
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +14 -10
- 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 +199 -1
- package/src/components/Button/Button.stories.mdx +15 -10
- package/src/components/Button/Button.test.tsx +21 -7
- package/src/components/Button/Button.tsx +22 -34
- package/src/components/Button/ButtonTypes.tsx +1 -0
- package/src/components/Button/__snapshots__/Button.test.tsx.snap +41 -10
- package/src/components/Card/Card.stories.mdx +296 -259
- package/src/components/Card/Card.test.tsx +156 -84
- package/src/components/Card/Card.tsx +195 -145
- package/src/components/Card/CardTypes.tsx +0 -17
- package/src/components/Card/__snapshots__/Card.test.tsx.snap +410 -0
- package/src/components/CardEdition/CardEdition.stories.tsx +15 -47
- package/src/components/CardEdition/_CardEdition.scss +22 -23
- package/src/components/Chakra/Box.stories.mdx +15 -16
- package/src/components/Chakra/Center.stories.mdx +31 -16
- package/src/components/Chakra/Grid.stories.mdx +28 -15
- package/src/components/Chakra/Stack.stories.mdx +35 -18
- package/src/components/Checkbox/Checkbox.stories.mdx +33 -11
- package/src/components/Checkbox/Checkbox.test.tsx +47 -2
- package/src/components/Checkbox/Checkbox.tsx +39 -33
- package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +90 -2
- package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +82 -2
- package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +29 -2
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +22 -18
- package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +47 -81
- package/src/components/ComponentWrapper/ComponentWrapper.tsx +63 -0
- package/src/components/DatePicker/DatePicker.stories.mdx +163 -62
- package/src/components/DatePicker/DatePicker.test.tsx +264 -64
- package/src/components/DatePicker/DatePicker.tsx +159 -128
- package/src/components/DatePicker/_DatePicker.scss +33 -67
- package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +818 -0
- package/src/components/Fieldset/Fieldset.stories.mdx +55 -0
- package/src/components/Fieldset/Fieldset.test.tsx +125 -0
- package/src/components/Fieldset/Fieldset.tsx +52 -0
- package/src/components/Fieldset/__snapshots__/Fieldset.test.tsx.snap +68 -0
- package/src/components/Form/Form.stories.mdx +24 -6
- package/src/components/Form/Form.test.tsx +1 -1
- package/src/components/Form/Form.tsx +1 -0
- package/src/components/Grid/SimpleGrid.stories.mdx +32 -39
- package/src/components/Grid/SimpleGrid.test.tsx +4 -4
- package/src/components/Heading/Heading.stories.mdx +3 -4
- package/src/components/Heading/Heading.tsx +5 -5
- package/src/components/HelperErrorText/HelperErrorText.stories.mdx +124 -0
- package/src/components/HelperErrorText/HelperErrorText.test.tsx +39 -44
- package/src/components/HelperErrorText/HelperErrorText.tsx +37 -39
- package/src/components/HelperErrorText/__snapshots__/HelperErrorText.test.tsx.snap +25 -0
- package/src/components/Hero/Hero.stories.mdx +12 -2
- package/src/components/Hero/Hero.tsx +1 -1
- package/src/components/Hero/HeroTypes.tsx +1 -0
- package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +7 -7
- package/src/components/HorizontalRule/HorizontalRule.stories.mdx +8 -6
- package/src/components/HorizontalRule/HorizontalRule.test.tsx +33 -28
- package/src/components/HorizontalRule/HorizontalRule.tsx +27 -29
- package/src/components/HorizontalRule/__snapshots__/HorizontalRule.test.tsx.snap +27 -9
- package/src/components/Icons/Icon.stories.mdx +12 -4
- package/src/components/Icons/Icon.test.tsx +18 -0
- package/src/components/Icons/Icon.tsx +16 -1
- package/src/components/Icons/IconSvgs.tsx +22 -0
- package/src/components/Icons/IconTypes.tsx +11 -0
- package/src/components/Image/Image.stories.mdx +220 -0
- package/src/components/Image/Image.test.tsx +131 -29
- package/src/components/Image/Image.tsx +84 -56
- package/src/components/Image/ImageTypes.ts +22 -0
- package/src/components/Image/__snapshots__/Image.test.tsx.snap +190 -0
- package/src/components/Input/Input.stories.tsx +23 -67
- package/src/components/Input/Input.test.tsx +4 -4
- package/src/components/Input/_Input.scss +23 -14
- package/src/components/Link/Link.tsx +4 -1
- package/src/components/List/List.stories.mdx +124 -49
- package/src/components/List/List.test.tsx +142 -63
- package/src/components/List/List.tsx +89 -93
- package/src/components/List/__snapshots__/List.test.tsx.snap +109 -0
- package/src/components/Modal/Modal.stories.mdx +3 -3
- package/src/components/Modal/_Modal.scss +2 -2
- package/src/components/Notification/Notification.stories.mdx +109 -112
- package/src/components/Notification/Notification.test.tsx +99 -110
- package/src/components/Notification/Notification.tsx +156 -159
- package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +159 -8
- package/src/components/Pagination/Pagination.stories.mdx +26 -27
- package/src/components/Pagination/Pagination.stories.tsx +11 -16
- package/src/components/Pagination/Pagination.test.tsx +276 -146
- package/src/components/Pagination/Pagination.tsx +174 -154
- package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +285 -0
- 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/Radio.test.tsx +20 -4
- package/src/components/Radio/Radio.tsx +6 -3
- package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +3 -0
- package/src/components/RadioGroup/RadioGroup.stories.mdx +3 -4
- package/src/components/RadioGroup/RadioGroup.test.tsx +24 -1
- package/src/components/RadioGroup/RadioGroup.tsx +19 -19
- package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +42 -72
- package/src/components/SearchBar/SearchBar.Test.tsx +20 -1
- package/src/components/SearchBar/SearchBar.stories.mdx +113 -8
- package/src/components/SearchBar/SearchBar.tsx +20 -10
- package/src/components/Select/Select.test.tsx +12 -0
- package/src/components/Select/Select.tsx +5 -2
- package/src/components/Select/SelectTypes.tsx +1 -0
- package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +28 -59
- package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +97 -177
- package/src/components/SkeletonLoader/SkeletonLoader.tsx +74 -71
- package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +739 -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 +34 -10
- package/src/components/StyleGuide/Buttons.stories.mdx +89 -73
- package/src/components/StyleGuide/ColorCard.tsx +46 -0
- package/src/components/StyleGuide/Colors.stories.mdx +171 -311
- package/src/components/StyleGuide/DesignTokens.stories.mdx +170 -0
- package/src/components/StyleGuide/Forms.stories.mdx +9 -7
- package/src/components/StyleGuide/Iconography.stories.mdx +85 -91
- package/src/components/StyleGuide/Spacing.stories.mdx +31 -23
- package/src/components/StyleGuide/Typography.stories.mdx +202 -189
- package/src/components/StyleGuide/UIDocCard.tsx +1 -1
- package/src/components/Tabs/Tabs.stories.mdx +73 -11
- package/src/components/Tabs/Tabs.tsx +87 -64
- package/src/components/Template/Template.stories.mdx +25 -27
- package/src/components/TextInput/TextInput.stories.mdx +1 -1
- package/src/components/TextInput/TextInput.test.tsx +22 -2
- package/src/components/TextInput/TextInput.tsx +28 -8
- package/src/components/TextInput/TextInputTypes.tsx +2 -0
- package/src/components/VideoPlayer/VideoPlayer.stories.mdx +17 -4
- package/src/components/VideoPlayer/VideoPlayer.test.tsx +54 -53
- package/src/components/VideoPlayer/VideoPlayer.tsx +50 -51
- package/src/components/VideoPlayer/VideoPlayerTypes.tsx +2 -2
- package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +91 -0
- package/src/docs/Chakra.stories.mdx +244 -63
- package/src/docs/Intro.stories.mdx +5 -2
- package/src/hooks/tests/useCarouselStyles.test.ts +140 -0
- package/src/hooks/tests/useNYPLTheme.test.tsx +36 -0
- package/src/hooks/useCarouselStyles.ts +34 -0
- package/src/hooks/useNYPLTheme.ts +67 -0
- package/src/hooks/useWindowSize.ts +40 -0
- package/src/index.ts +22 -19
- 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 -60
- package/src/theme/components/button.ts +21 -15
- package/src/theme/components/card.ts +174 -0
- package/src/theme/components/checkbox.ts +8 -3
- package/src/theme/components/checkboxGroup.ts +8 -0
- package/src/theme/components/componentWrapper.ts +10 -0
- package/src/theme/components/datePicker.ts +17 -0
- package/src/theme/components/fieldset.ts +18 -0
- package/src/theme/components/global.ts +26 -15
- package/src/theme/components/globalMixins.ts +9 -1
- package/src/theme/components/heading.ts +10 -5
- package/src/theme/components/helperErrorText.ts +9 -0
- package/src/theme/components/hero.ts +4 -3
- package/src/theme/components/horizontalRule.ts +13 -0
- package/src/theme/components/icon.ts +9 -9
- package/src/theme/components/image.ts +116 -0
- package/src/theme/components/label.ts +3 -10
- package/src/theme/components/link.ts +5 -1
- package/src/theme/components/list.ts +73 -0
- package/src/theme/components/notification.ts +93 -0
- package/src/theme/components/pagination.ts +20 -0
- package/src/theme/components/progressIndicator.ts +62 -0
- package/src/theme/components/radio.ts +2 -2
- package/src/theme/components/radioGroup.ts +8 -0
- package/src/theme/components/select.ts +6 -3
- package/src/theme/components/skeletonLoader.ts +107 -0
- package/src/theme/components/slider.ts +79 -0
- package/src/theme/components/statusBadge.ts +1 -2
- package/src/theme/components/tabs.ts +49 -19
- package/src/theme/components/template.ts +8 -8
- package/src/theme/components/textInput.ts +5 -4
- package/src/theme/components/videoPlayer.ts +49 -0
- package/src/theme/foundations/breakpoints.ts +8 -8
- package/src/theme/foundations/global.ts +6 -1
- package/src/theme/foundations/radii.ts +6 -0
- package/src/theme/foundations/spacing.ts +24 -24
- package/src/theme/index.ts +41 -10
- package/src/utils/componentCategories.ts +4 -3
- package/dist/components/HelperErrorText/HelperErrorText.stories.d.ts +0 -16
- package/dist/components/Image/Image.stories.d.ts +0 -18
- package/dist/components/List/List.stories.d.ts +0 -7
- package/dist/theme/components/customCheckboxGroup.d.ts +0 -18
- package/dist/theme/components/customRadioGroup.d.ts +0 -18
- package/src/components/Button/_Button.scss +0 -32
- package/src/components/Card/_Card.scss +0 -308
- package/src/components/HelperErrorText/HelperErrorText.stories.tsx +0 -48
- package/src/components/HelperErrorText/_HelperErrorText.scss +0 -9
- package/src/components/HorizontalRule/_HorizontalRule.scss +0 -15
- package/src/components/Image/Image.stories.tsx +0 -54
- package/src/components/Image/_Image.scss +0 -38
- package/src/components/List/List.stories.tsx +0 -139
- package/src/components/List/_List.scss +0 -76
- package/src/components/Notification/_Notification.scss +0 -110
- package/src/components/Pagination/_Pagination.scss +0 -40
- package/src/components/SkeletonLoader/_SkeletonLoader.scss +0 -142
- package/src/components/VideoPlayer/_VideoPlayer.scss +0 -38
- 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 -78
- package/src/styles/base/_typography.scss +0 -11
- package/src/theme/components/customCheckboxGroup.ts +0 -12
- package/src/theme/components/customRadioGroup.ts +0 -12
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
|
|
10
|
+
import Fieldset from "./Fieldset";
|
|
11
|
+
import { getCategory } from "../../utils/componentCategories";
|
|
12
|
+
import DSProvider from "../../theme/provider";
|
|
13
|
+
|
|
14
|
+
<Meta
|
|
15
|
+
title={getCategory("Fieldset")}
|
|
16
|
+
component={Fieldset}
|
|
17
|
+
decorators={[withDesign]}
|
|
18
|
+
parameters={{
|
|
19
|
+
jest: ["Fieldset.test.tsx"],
|
|
20
|
+
}}
|
|
21
|
+
argTypes={{
|
|
22
|
+
children: { table: { disable: true } },
|
|
23
|
+
className: { table: { disable: true } },
|
|
24
|
+
id: { table: { disable: true } },
|
|
25
|
+
}}
|
|
26
|
+
/>
|
|
27
|
+
|
|
28
|
+
# Fieldset
|
|
29
|
+
|
|
30
|
+
| Component Version | DS Version |
|
|
31
|
+
| ----------------- | ---------- |
|
|
32
|
+
| Added | `0.25.3` |
|
|
33
|
+
| Latest | `0.25.3` |
|
|
34
|
+
|
|
35
|
+
<Description of={Fieldset} />
|
|
36
|
+
|
|
37
|
+
<Canvas withToolbar>
|
|
38
|
+
<Story
|
|
39
|
+
name="Basic"
|
|
40
|
+
args={{
|
|
41
|
+
isLegendHidden: false,
|
|
42
|
+
isRequired: false,
|
|
43
|
+
legendText: "This is the legend text",
|
|
44
|
+
optReqFlag: true,
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
{(args) => (
|
|
48
|
+
<Fieldset {...args}>
|
|
49
|
+
<p>Text children in the Fieldset component.</p>
|
|
50
|
+
</Fieldset>
|
|
51
|
+
)}
|
|
52
|
+
</Story>
|
|
53
|
+
</Canvas>
|
|
54
|
+
|
|
55
|
+
<ArgsTable story="Basic" />
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import { axe } from "jest-axe";
|
|
4
|
+
import renderer from "react-test-renderer";
|
|
5
|
+
|
|
6
|
+
import Fieldset from "./Fieldset";
|
|
7
|
+
|
|
8
|
+
describe("Fieldset Accessibility", () => {
|
|
9
|
+
it("passes axe accessibility", async () => {
|
|
10
|
+
const { container } = render(
|
|
11
|
+
<Fieldset legendText="Legend Text">
|
|
12
|
+
<p>Some other fields</p>
|
|
13
|
+
</Fieldset>
|
|
14
|
+
);
|
|
15
|
+
expect(await axe(container)).toHaveNoViolations();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("passes axe accessibility with the legend hidden", async () => {
|
|
19
|
+
const { container } = render(
|
|
20
|
+
<Fieldset legendText="Legend Text" isLegendHidden>
|
|
21
|
+
<p>Some other fields</p>
|
|
22
|
+
</Fieldset>
|
|
23
|
+
);
|
|
24
|
+
expect(await axe(container)).toHaveNoViolations();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe("Fieldset", () => {
|
|
29
|
+
it("renders text in a legend and fieldset along with its children", () => {
|
|
30
|
+
render(
|
|
31
|
+
<Fieldset legendText="Legend Text">
|
|
32
|
+
<p>Some other fields</p>
|
|
33
|
+
</Fieldset>
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
expect(screen.getByRole("group")).toBeInTheDocument();
|
|
37
|
+
// `legend` has no HTML role
|
|
38
|
+
expect(screen.getByText(/Legend Text/i)).toBeInTheDocument();
|
|
39
|
+
expect(screen.getByText("Some other fields")).toBeInTheDocument();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("renders 'Optional' text by default in the legend", () => {
|
|
43
|
+
render(
|
|
44
|
+
<Fieldset legendText="Legend Text">
|
|
45
|
+
<p>Some other fields</p>
|
|
46
|
+
</Fieldset>
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
expect(screen.getByText(/Optional/i)).toBeInTheDocument();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("renders 'Required' text in the legend", () => {
|
|
53
|
+
render(
|
|
54
|
+
<Fieldset legendText="Legend Text" isRequired>
|
|
55
|
+
<p>Some other fields</p>
|
|
56
|
+
</Fieldset>
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
expect(screen.getByText(/Required/i)).toBeInTheDocument();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("can hide the 'Required'/'Optional' text in the legend but still show the main text", () => {
|
|
63
|
+
const { rerender } = render(
|
|
64
|
+
<Fieldset legendText="Legend Text" isRequired>
|
|
65
|
+
<p>Some other fields</p>
|
|
66
|
+
</Fieldset>
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
expect(screen.getByText(/Required/i)).toBeInTheDocument();
|
|
70
|
+
|
|
71
|
+
rerender(
|
|
72
|
+
<Fieldset legendText="Legend Text" optReqFlag={false}>
|
|
73
|
+
<p>Some other fields</p>
|
|
74
|
+
</Fieldset>
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
expect(screen.getByText(/Legend Text/i)).toBeInTheDocument();
|
|
78
|
+
expect(screen.queryByText(/Optional/i)).not.toBeInTheDocument();
|
|
79
|
+
|
|
80
|
+
rerender(
|
|
81
|
+
<Fieldset legendText="Legend Text" isRequired optReqFlag={false}>
|
|
82
|
+
<p>Some other fields</p>
|
|
83
|
+
</Fieldset>
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
expect(screen.getByText(/Legend Text/i)).toBeInTheDocument();
|
|
87
|
+
expect(screen.queryByText(/Required/i)).not.toBeInTheDocument();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("renders the UI snapshot correctly", () => {
|
|
91
|
+
const basic = renderer
|
|
92
|
+
.create(
|
|
93
|
+
<Fieldset legendText="Legend Text">
|
|
94
|
+
<p>Some other fields</p>
|
|
95
|
+
</Fieldset>
|
|
96
|
+
)
|
|
97
|
+
.toJSON();
|
|
98
|
+
const required = renderer
|
|
99
|
+
.create(
|
|
100
|
+
<Fieldset legendText="Legend Text" isRequired>
|
|
101
|
+
<p>Some other fields</p>
|
|
102
|
+
</Fieldset>
|
|
103
|
+
)
|
|
104
|
+
.toJSON();
|
|
105
|
+
const hiddenHelperText = renderer
|
|
106
|
+
.create(
|
|
107
|
+
<Fieldset legendText="Legend Text" isRequired optReqFlag={false}>
|
|
108
|
+
<p>Some other fields</p>
|
|
109
|
+
</Fieldset>
|
|
110
|
+
)
|
|
111
|
+
.toJSON();
|
|
112
|
+
const hiddenLegend = renderer
|
|
113
|
+
.create(
|
|
114
|
+
<Fieldset legendText="Legend Text" isLegendHidden>
|
|
115
|
+
<p>Some other fields</p>
|
|
116
|
+
</Fieldset>
|
|
117
|
+
)
|
|
118
|
+
.toJSON();
|
|
119
|
+
|
|
120
|
+
expect(basic).toMatchSnapshot();
|
|
121
|
+
expect(required).toMatchSnapshot();
|
|
122
|
+
expect(hiddenHelperText).toMatchSnapshot();
|
|
123
|
+
expect(hiddenLegend).toMatchSnapshot();
|
|
124
|
+
});
|
|
125
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Box, useMultiStyleConfig } from "@chakra-ui/react";
|
|
3
|
+
|
|
4
|
+
interface FieldsetProps {
|
|
5
|
+
/** Children to render. Typically form-related components are used. */
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
/** Additional class name to add. */
|
|
8
|
+
className?: string;
|
|
9
|
+
/** ID that other components can cross reference for accessibility purposes */
|
|
10
|
+
id?: string;
|
|
11
|
+
/** Flag to show or hide the text in the `legend` element. False by default. */
|
|
12
|
+
isLegendHidden?: boolean;
|
|
13
|
+
/** Flag to render "Required" or "Optional" in the `legend`.
|
|
14
|
+
* False/"Optional" by default. */
|
|
15
|
+
isRequired?: boolean;
|
|
16
|
+
/** Text to display in the `legend` element. */
|
|
17
|
+
legendText?: string;
|
|
18
|
+
/** Flag to show or hide the "Required"/"Optional" text in the `legend`.
|
|
19
|
+
* True by default. */
|
|
20
|
+
optReqFlag?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A wrapper component that renders a `fieldset` element along with a `legend`
|
|
25
|
+
* element as its first child. Commonly used to wrap form components.
|
|
26
|
+
*/
|
|
27
|
+
const Fieldset: React.FC<FieldsetProps> = ({
|
|
28
|
+
children,
|
|
29
|
+
className,
|
|
30
|
+
id,
|
|
31
|
+
isLegendHidden = false,
|
|
32
|
+
isRequired = false,
|
|
33
|
+
legendText,
|
|
34
|
+
optReqFlag = true,
|
|
35
|
+
}) => {
|
|
36
|
+
const styles = useMultiStyleConfig("Fieldset", { isLegendHidden });
|
|
37
|
+
return (
|
|
38
|
+
<Box as="fieldset" id={id} __css={styles} className={className}>
|
|
39
|
+
<legend>
|
|
40
|
+
{legendText}
|
|
41
|
+
{optReqFlag && (
|
|
42
|
+
<Box __css={styles.helper}>
|
|
43
|
+
{isRequired ? "Required" : "Optional"}
|
|
44
|
+
</Box>
|
|
45
|
+
)}
|
|
46
|
+
</legend>
|
|
47
|
+
{children}
|
|
48
|
+
</Box>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default Fieldset;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Fieldset renders the UI snapshot correctly 1`] = `
|
|
4
|
+
<fieldset
|
|
5
|
+
className="css-0"
|
|
6
|
+
>
|
|
7
|
+
<legend>
|
|
8
|
+
Legend Text
|
|
9
|
+
<div
|
|
10
|
+
className="css-0"
|
|
11
|
+
>
|
|
12
|
+
Optional
|
|
13
|
+
</div>
|
|
14
|
+
</legend>
|
|
15
|
+
<p>
|
|
16
|
+
Some other fields
|
|
17
|
+
</p>
|
|
18
|
+
</fieldset>
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
exports[`Fieldset renders the UI snapshot correctly 2`] = `
|
|
22
|
+
<fieldset
|
|
23
|
+
className="css-0"
|
|
24
|
+
>
|
|
25
|
+
<legend>
|
|
26
|
+
Legend Text
|
|
27
|
+
<div
|
|
28
|
+
className="css-0"
|
|
29
|
+
>
|
|
30
|
+
Required
|
|
31
|
+
</div>
|
|
32
|
+
</legend>
|
|
33
|
+
<p>
|
|
34
|
+
Some other fields
|
|
35
|
+
</p>
|
|
36
|
+
</fieldset>
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
exports[`Fieldset renders the UI snapshot correctly 3`] = `
|
|
40
|
+
<fieldset
|
|
41
|
+
className="css-0"
|
|
42
|
+
>
|
|
43
|
+
<legend>
|
|
44
|
+
Legend Text
|
|
45
|
+
</legend>
|
|
46
|
+
<p>
|
|
47
|
+
Some other fields
|
|
48
|
+
</p>
|
|
49
|
+
</fieldset>
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
exports[`Fieldset renders the UI snapshot correctly 4`] = `
|
|
53
|
+
<fieldset
|
|
54
|
+
className="css-0"
|
|
55
|
+
>
|
|
56
|
+
<legend>
|
|
57
|
+
Legend Text
|
|
58
|
+
<div
|
|
59
|
+
className="css-0"
|
|
60
|
+
>
|
|
61
|
+
Optional
|
|
62
|
+
</div>
|
|
63
|
+
</legend>
|
|
64
|
+
<p>
|
|
65
|
+
Some other fields
|
|
66
|
+
</p>
|
|
67
|
+
</fieldset>
|
|
68
|
+
`;
|
|
@@ -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";
|
|
@@ -22,6 +21,8 @@ import Select from "../Select/Select";
|
|
|
22
21
|
import Heading from "../Heading/Heading";
|
|
23
22
|
import { HeadingLevels } from "../Heading/HeadingTypes";
|
|
24
23
|
import HorizontalRule from "../HorizontalRule/HorizontalRule";
|
|
24
|
+
import DatePicker from "../DatePicker/DatePicker";
|
|
25
|
+
import { DatePickerTypes } from "../DatePicker/DatePickerTypes";
|
|
25
26
|
import { action } from "@storybook/addon-actions";
|
|
26
27
|
|
|
27
28
|
import SimpleGrid from "../Grid/SimpleGrid";
|
|
@@ -55,7 +56,7 @@ The `Form` component renders a standard `<form>` element and should be used to h
|
|
|
55
56
|
|
|
56
57
|
`FormRow` should be used as a parent of multiple `FormField` components when you need to render multiple input components in a horizontal row.
|
|
57
58
|
|
|
58
|
-
<
|
|
59
|
+
<Canvas withToolbar>
|
|
59
60
|
<Story
|
|
60
61
|
name="Form"
|
|
61
62
|
args={{
|
|
@@ -89,6 +90,23 @@ The `Form` component renders a standard `<form>` element and should be used to h
|
|
|
89
90
|
isRequired
|
|
90
91
|
/>
|
|
91
92
|
</FormField>
|
|
93
|
+
<FormField>
|
|
94
|
+
<DatePicker
|
|
95
|
+
id="date-range"
|
|
96
|
+
dateType={DatePickerTypes.Full}
|
|
97
|
+
dateFormat="yyyy-MM-dd"
|
|
98
|
+
dateRange={true}
|
|
99
|
+
minDate="1/1/2021"
|
|
100
|
+
maxDate="1/1/2022"
|
|
101
|
+
labelText="Select the date range you want to visit NYPL"
|
|
102
|
+
nameFrom="visit-dates"
|
|
103
|
+
helperTextFrom="From this date."
|
|
104
|
+
helperTextTo="To this date."
|
|
105
|
+
helperText="Select a valid date range."
|
|
106
|
+
invalidText="Please select a valid date range."
|
|
107
|
+
showLabel={false}
|
|
108
|
+
/>
|
|
109
|
+
</FormField>
|
|
92
110
|
</FormRow>
|
|
93
111
|
<FormField>
|
|
94
112
|
<TextInput
|
|
@@ -168,7 +186,7 @@ The `Form` component renders a standard `<form>` element and should be used to h
|
|
|
168
186
|
</Form>
|
|
169
187
|
)}
|
|
170
188
|
</Story>
|
|
171
|
-
</
|
|
189
|
+
</Canvas>
|
|
172
190
|
|
|
173
191
|
<ArgsTable story="Form" />
|
|
174
192
|
|
|
@@ -229,13 +247,13 @@ for (const formSpacing in FormSpacing) {
|
|
|
229
247
|
}
|
|
230
248
|
export const getForms = (list) => <ul style={{ listStyle: "none" }}>{list}</ul>;
|
|
231
249
|
|
|
232
|
-
By default, the `Form` component will handle the NYPL spacing around form input elements. The default spacing value is `large`, which corresponds to the CSS variable `--space-l` (2rem / 32px).
|
|
250
|
+
By default, the `Form` component will handle the NYPL spacing around form input elements. The default spacing value is `large`, which corresponds to the CSS variable `--nypl-space-l` (2rem / 32px).
|
|
233
251
|
|
|
234
252
|
**IMPORTANT:** The default spacing should not be overwritten without a very good reason.
|
|
235
253
|
|
|
236
254
|
Below are the spacing variants available with the `FormSpacing` enum.
|
|
237
255
|
|
|
238
|
-
<
|
|
256
|
+
<Canvas>
|
|
239
257
|
<Story
|
|
240
258
|
name="Spacing Variants"
|
|
241
259
|
args={{
|
|
@@ -244,7 +262,7 @@ Below are the spacing variants available with the `FormSpacing` enum.
|
|
|
244
262
|
>
|
|
245
263
|
{getForms(sizes)}
|
|
246
264
|
</Story>
|
|
247
|
-
</
|
|
265
|
+
</Canvas>
|
|
248
266
|
|
|
249
267
|
## Example Code
|
|
250
268
|
|
|
@@ -113,7 +113,7 @@ describe("Form", () => {
|
|
|
113
113
|
// const formRow = form.firstChild;
|
|
114
114
|
// expect(form).toBeInTheDocument();
|
|
115
115
|
// expect(formRow).toHaveStyle({
|
|
116
|
-
// "grid-gap": "var(--
|
|
116
|
+
// "grid-gap": "var(--nypl-space-xs)",
|
|
117
117
|
// });
|
|
118
118
|
// });
|
|
119
119
|
});
|
|
@@ -33,6 +33,7 @@ export function FormRow(props: React.PropsWithChildren<FormChildProps>) {
|
|
|
33
33
|
const alteredChildren = React.Children.map(
|
|
34
34
|
children,
|
|
35
35
|
(child: React.ReactElement, i) => {
|
|
36
|
+
if (!child) return null;
|
|
36
37
|
return React.cloneElement(child, { id: `${id}-grandchild${i}` });
|
|
37
38
|
}
|
|
38
39
|
);
|
|
@@ -8,17 +8,8 @@ import {
|
|
|
8
8
|
import { withDesign } from "storybook-addon-designs";
|
|
9
9
|
|
|
10
10
|
import SimpleGrid from "./SimpleGrid";
|
|
11
|
-
import Card, {
|
|
12
|
-
|
|
13
|
-
CardHeading,
|
|
14
|
-
CardContent,
|
|
15
|
-
CardActions,
|
|
16
|
-
} from "../Card/Card";
|
|
17
|
-
import {
|
|
18
|
-
CardImageRatios,
|
|
19
|
-
CardImageSizes,
|
|
20
|
-
CardLayouts,
|
|
21
|
-
} from "../Card/CardTypes";
|
|
11
|
+
import Card, { CardHeading, CardContent, CardActions } from "../Card/Card";
|
|
12
|
+
import { CardLayouts } from "../Card/CardTypes";
|
|
22
13
|
import { HeadingDisplaySizes, HeadingLevels } from "../Heading/HeadingTypes";
|
|
23
14
|
import Icon from "../Icons/Icon";
|
|
24
15
|
import {
|
|
@@ -28,6 +19,7 @@ import {
|
|
|
28
19
|
IconRotationTypes,
|
|
29
20
|
} from "../Icons/IconTypes";
|
|
30
21
|
import Image from "../Image/Image";
|
|
22
|
+
import { ImageRatios } from "../Image/ImageTypes";
|
|
31
23
|
|
|
32
24
|
import { getCategory } from "../../utils/componentCategories";
|
|
33
25
|
import DSProvider from "../../theme/provider";
|
|
@@ -86,9 +78,9 @@ The NYPL standards for the items per row in a grid is `3` for desktop, `2` for t
|
|
|
86
78
|
{(args) => (
|
|
87
79
|
<SimpleGrid {...args}>
|
|
88
80
|
<Card
|
|
89
|
-
imageSrc="https://placeimg.com/
|
|
81
|
+
imageSrc="https://placeimg.com/400/220/animals"
|
|
90
82
|
imageAlt="Alt text"
|
|
91
|
-
imageAspectRatio={
|
|
83
|
+
imageAspectRatio={ImageRatios.TwoByOne}
|
|
92
84
|
>
|
|
93
85
|
<CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
|
|
94
86
|
<CardContent>
|
|
@@ -99,7 +91,7 @@ The NYPL standards for the items per row in a grid is `3` for desktop, `2` for t
|
|
|
99
91
|
<Card
|
|
100
92
|
imageSrc="https://placeimg.com/400/220/animals"
|
|
101
93
|
imageAlt="Alt text"
|
|
102
|
-
imageAspectRatio={
|
|
94
|
+
imageAspectRatio={ImageRatios.TwoByOne}
|
|
103
95
|
>
|
|
104
96
|
<CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
|
|
105
97
|
<CardContent>
|
|
@@ -110,7 +102,7 @@ The NYPL standards for the items per row in a grid is `3` for desktop, `2` for t
|
|
|
110
102
|
<Card
|
|
111
103
|
imageSrc="https://placeimg.com/400/240/animals"
|
|
112
104
|
imageAlt="Alt text"
|
|
113
|
-
imageAspectRatio={
|
|
105
|
+
imageAspectRatio={ImageRatios.TwoByOne}
|
|
114
106
|
>
|
|
115
107
|
<CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
|
|
116
108
|
<CardContent>
|
|
@@ -121,7 +113,7 @@ The NYPL standards for the items per row in a grid is `3` for desktop, `2` for t
|
|
|
121
113
|
<Card
|
|
122
114
|
imageSrc="https://placeimg.com/400/260/animals"
|
|
123
115
|
imageAlt="Alt text"
|
|
124
|
-
imageAspectRatio={
|
|
116
|
+
imageAspectRatio={ImageRatios.TwoByOne}
|
|
125
117
|
>
|
|
126
118
|
<CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
|
|
127
119
|
<CardContent>
|
|
@@ -132,7 +124,7 @@ The NYPL standards for the items per row in a grid is `3` for desktop, `2` for t
|
|
|
132
124
|
<Card
|
|
133
125
|
imageSrc="https://placeimg.com/400/320/animals"
|
|
134
126
|
imageAlt="Alt text"
|
|
135
|
-
imageAspectRatio={
|
|
127
|
+
imageAspectRatio={ImageRatios.TwoByOne}
|
|
136
128
|
>
|
|
137
129
|
<CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
|
|
138
130
|
<CardContent>
|
|
@@ -143,7 +135,7 @@ The NYPL standards for the items per row in a grid is `3` for desktop, `2` for t
|
|
|
143
135
|
<Card
|
|
144
136
|
imageSrc="https://placeimg.com/400/300/animals"
|
|
145
137
|
imageAlt="Alt text"
|
|
146
|
-
imageAspectRatio={
|
|
138
|
+
imageAspectRatio={ImageRatios.TwoByOne}
|
|
147
139
|
>
|
|
148
140
|
<CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
|
|
149
141
|
<CardContent>
|
|
@@ -169,6 +161,7 @@ for (const icon in IconNames) {
|
|
|
169
161
|
const iname = `Example icon: ${IconNames[icon]}`;
|
|
170
162
|
const iconRender = (
|
|
171
163
|
<Icon
|
|
164
|
+
key={icon}
|
|
172
165
|
name={IconNames[icon]}
|
|
173
166
|
size={IconSizes.ExtraExtraExtraLarge}
|
|
174
167
|
titleText={iname}
|
|
@@ -190,24 +183,24 @@ This example is rendering square `Image` components with the `columns` prop set
|
|
|
190
183
|
<Canvas>
|
|
191
184
|
<DSProvider>
|
|
192
185
|
<SimpleGrid columns={6}>
|
|
193
|
-
<Image src="https://placeimg.com/300/300/animals?x=1" />
|
|
194
|
-
<Image src="https://placeimg.com/300/300/animals?x=2" />
|
|
195
|
-
<Image src="https://placeimg.com/300/300/animals?x=3" />
|
|
196
|
-
<Image src="https://placeimg.com/300/300/animals?x=4" />
|
|
197
|
-
<Image src="https://placeimg.com/300/300/animals?x=5" />
|
|
198
|
-
<Image src="https://placeimg.com/300/300/animals?x=6" />
|
|
199
|
-
<Image src="https://placeimg.com/300/300/animals?x=7" />
|
|
200
|
-
<Image src="https://placeimg.com/300/300/animals?x=8" />
|
|
201
|
-
<Image src="https://placeimg.com/300/300/animals?x=9" />
|
|
202
|
-
<Image src="https://placeimg.com/300/300/animals?x=10" />
|
|
203
|
-
<Image src="https://placeimg.com/300/300/animals?x=11" />
|
|
204
|
-
<Image src="https://placeimg.com/300/300/animals?x=12" />
|
|
205
|
-
<Image src="https://placeimg.com/300/300/animals?x=13" />
|
|
206
|
-
<Image src="https://placeimg.com/300/300/animals?x=14" />
|
|
207
|
-
<Image src="https://placeimg.com/300/300/animals?x=15" />
|
|
208
|
-
<Image src="https://placeimg.com/300/300/animals?x=16" />
|
|
209
|
-
<Image src="https://placeimg.com/300/300/animals?x=17" />
|
|
210
|
-
<Image src="https://placeimg.com/300/300/animals?x=18" />
|
|
186
|
+
<Image src="https://placeimg.com/300/300/animals?x=1" alt="" />
|
|
187
|
+
<Image src="https://placeimg.com/300/300/animals?x=2" alt="" />
|
|
188
|
+
<Image src="https://placeimg.com/300/300/animals?x=3" alt="" />
|
|
189
|
+
<Image src="https://placeimg.com/300/300/animals?x=4" alt="" />
|
|
190
|
+
<Image src="https://placeimg.com/300/300/animals?x=5" alt="" />
|
|
191
|
+
<Image src="https://placeimg.com/300/300/animals?x=6" alt="" />
|
|
192
|
+
<Image src="https://placeimg.com/300/300/animals?x=7" alt="" />
|
|
193
|
+
<Image src="https://placeimg.com/300/300/animals?x=8" alt="" />
|
|
194
|
+
<Image src="https://placeimg.com/300/300/animals?x=9" alt="" />
|
|
195
|
+
<Image src="https://placeimg.com/300/300/animals?x=10" alt="" />
|
|
196
|
+
<Image src="https://placeimg.com/300/300/animals?x=11" alt="" />
|
|
197
|
+
<Image src="https://placeimg.com/300/300/animals?x=12" alt="" />
|
|
198
|
+
<Image src="https://placeimg.com/300/300/animals?x=13" alt="" />
|
|
199
|
+
<Image src="https://placeimg.com/300/300/animals?x=14" alt="" />
|
|
200
|
+
<Image src="https://placeimg.com/300/300/animals?x=15" alt="" />
|
|
201
|
+
<Image src="https://placeimg.com/300/300/animals?x=16" alt="" />
|
|
202
|
+
<Image src="https://placeimg.com/300/300/animals?x=17" alt="" />
|
|
203
|
+
<Image src="https://placeimg.com/300/300/animals?x=18" alt="" />
|
|
211
204
|
</SimpleGrid>
|
|
212
205
|
</DSProvider>
|
|
213
206
|
</Canvas>
|
|
@@ -225,7 +218,7 @@ This example is rendering horizontal `Card` components with the `columns` prop s
|
|
|
225
218
|
center
|
|
226
219
|
imageSrc="https://placeimg.com/400/200/animals"
|
|
227
220
|
imageAlt="Alt text"
|
|
228
|
-
imageAspectRatio={
|
|
221
|
+
imageAspectRatio={ImageRatios.FourByThree}
|
|
229
222
|
>
|
|
230
223
|
<CardHeading level={HeadingLevels.Four} id="heading1">
|
|
231
224
|
Card Heading
|
|
@@ -242,7 +235,7 @@ This example is rendering horizontal `Card` components with the `columns` prop s
|
|
|
242
235
|
center
|
|
243
236
|
imageSrc="https://placeimg.com/410/210/animals"
|
|
244
237
|
imageAlt="Alt text"
|
|
245
|
-
imageAspectRatio={
|
|
238
|
+
imageAspectRatio={ImageRatios.FourByThree}
|
|
246
239
|
>
|
|
247
240
|
<CardHeading level={HeadingLevels.Four} id="heading2">
|
|
248
241
|
Card Heading
|
|
@@ -259,7 +252,7 @@ This example is rendering horizontal `Card` components with the `columns` prop s
|
|
|
259
252
|
center
|
|
260
253
|
imageSrc="https://placeimg.com/320/320/animals"
|
|
261
254
|
imageAlt="Alt text"
|
|
262
|
-
imageAspectRatio={
|
|
255
|
+
imageAspectRatio={ImageRatios.FourByThree}
|
|
263
256
|
>
|
|
264
257
|
<CardHeading level={HeadingLevels.Four} id="heading3">
|
|
265
258
|
Card Heading
|
|
@@ -5,7 +5,7 @@ import renderer from "react-test-renderer";
|
|
|
5
5
|
|
|
6
6
|
import SimpleGrid from "./SimpleGrid";
|
|
7
7
|
import Card, { CardHeading, CardContent } from "../Card/Card";
|
|
8
|
-
import {
|
|
8
|
+
import { ImageRatios } from "../Image/ImageTypes";
|
|
9
9
|
import { HeadingLevels } from "../Heading/HeadingTypes";
|
|
10
10
|
|
|
11
11
|
describe("Grid Accessibility", () => {
|
|
@@ -15,7 +15,7 @@ describe("Grid Accessibility", () => {
|
|
|
15
15
|
<Card
|
|
16
16
|
imageSrc="https://placeimg.com/500/200/animals"
|
|
17
17
|
imageAlt="Alt text"
|
|
18
|
-
imageAspectRatio={
|
|
18
|
+
imageAspectRatio={ImageRatios.TwoByOne}
|
|
19
19
|
>
|
|
20
20
|
<CardHeading level={HeadingLevels.Two}>Card Heading</CardHeading>
|
|
21
21
|
<CardContent>
|
|
@@ -26,7 +26,7 @@ describe("Grid Accessibility", () => {
|
|
|
26
26
|
<Card
|
|
27
27
|
imageSrc="https://placeimg.com/400/220/animals"
|
|
28
28
|
imageAlt="Alt text"
|
|
29
|
-
imageAspectRatio={
|
|
29
|
+
imageAspectRatio={ImageRatios.TwoByOne}
|
|
30
30
|
>
|
|
31
31
|
<CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
|
|
32
32
|
<CardContent>
|
|
@@ -37,7 +37,7 @@ describe("Grid Accessibility", () => {
|
|
|
37
37
|
<Card
|
|
38
38
|
imageSrc="https://placeimg.com/400/240/animals"
|
|
39
39
|
imageAlt="Alt text"
|
|
40
|
-
imageAspectRatio={
|
|
40
|
+
imageAspectRatio={ImageRatios.TwoByOne}
|
|
41
41
|
>
|
|
42
42
|
<CardHeading level={HeadingLevels.Three}>Card Heading</CardHeading>
|
|
43
43
|
<CardContent>
|
|
@@ -25,10 +25,9 @@ import { getCategory } from "../../utils/componentCategories";
|
|
|
25
25
|
jest: ["Heading.test.tsx"],
|
|
26
26
|
}}
|
|
27
27
|
argTypes={{
|
|
28
|
-
|
|
28
|
+
additionalStyles: { table: { disable: true } },
|
|
29
29
|
className: { table: { disable: true } },
|
|
30
|
-
|
|
31
|
-
sx: { table: { disable: true } },
|
|
30
|
+
id: { table: { disable: true } },
|
|
32
31
|
}}
|
|
33
32
|
/>
|
|
34
33
|
|
|
@@ -37,7 +36,7 @@ import { getCategory } from "../../utils/componentCategories";
|
|
|
37
36
|
| Component Version | DS Version |
|
|
38
37
|
| ----------------- | ---------- |
|
|
39
38
|
| Added | `0.0.4` |
|
|
40
|
-
| Latest | `0.25.
|
|
39
|
+
| Latest | `0.25.2` |
|
|
41
40
|
|
|
42
41
|
<Description of={Heading} />
|
|
43
42
|
|
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
import { HeadingDisplaySizes, HeadingLevels } from "./HeadingTypes";
|
|
11
11
|
|
|
12
12
|
export interface HeadingProps {
|
|
13
|
+
/** Optionally pass in additional Chakra-based styles. */
|
|
14
|
+
additionalStyles?: { [key: string]: any };
|
|
13
15
|
/** Optional className that appears in addition to `heading` */
|
|
14
16
|
className?: string;
|
|
15
17
|
/** Optional size used to override the default styles of the semantic HTML `<h>` elements */
|
|
@@ -18,8 +20,6 @@ export interface HeadingProps {
|
|
|
18
20
|
id?: string;
|
|
19
21
|
/** Optional number 1-6 used to create the `<h*>` tag; if prop is not passed, `Heading` will default to `<h2>` */
|
|
20
22
|
level?: HeadingLevels;
|
|
21
|
-
/** Optionally pass in additional Chakra-based styles. */
|
|
22
|
-
sx?: { [key: string]: any };
|
|
23
23
|
/** Inner text of the `<h*>` element */
|
|
24
24
|
text?: string;
|
|
25
25
|
/** Optional URL that header points to; when `url` prop is passed to `Heading`, a child `<a>` element is created and the heading text becomes an active link */
|
|
@@ -43,11 +43,11 @@ const getVariant = (displaySize) => variantMap[displaySize] || null;
|
|
|
43
43
|
|
|
44
44
|
function Heading(props: React.PropsWithChildren<HeadingProps>) {
|
|
45
45
|
const {
|
|
46
|
+
additionalStyles = {},
|
|
46
47
|
className,
|
|
47
48
|
displaySize,
|
|
48
49
|
id,
|
|
49
50
|
level = HeadingLevels.Two,
|
|
50
|
-
sx = {},
|
|
51
51
|
text,
|
|
52
52
|
url,
|
|
53
53
|
urlClass,
|
|
@@ -55,8 +55,8 @@ function Heading(props: React.PropsWithChildren<HeadingProps>) {
|
|
|
55
55
|
const variant = displaySize ? getVariant(displaySize) : `h${level}`;
|
|
56
56
|
const styles = useStyleConfig("Heading", { variant });
|
|
57
57
|
// Combine native base styles with any additional styles.
|
|
58
|
-
// This is used
|
|
59
|
-
const finalStyles = { ...styles, ...
|
|
58
|
+
// This is used in the `Hero` and `Notification` components.
|
|
59
|
+
const finalStyles = { ...styles, ...additionalStyles };
|
|
60
60
|
const asHeading: any = `h${level}`;
|
|
61
61
|
|
|
62
62
|
if (level < 1 || level > 6) {
|