@nypl/design-system-react-components 0.25.12 → 0.26.1
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 +131 -1
- package/README.md +10 -10
- package/dist/components/Accordion/Accordion.d.ts +6 -4
- package/dist/components/Accordion/AccordionTypes.d.ts +5 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +4 -4
- package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +1 -1
- package/dist/components/Button/Button.d.ts +2 -2
- package/dist/components/Card/Card.d.ts +22 -29
- package/dist/components/Checkbox/Checkbox.d.ts +3 -3
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +9 -6
- package/dist/components/ComponentWrapper/ComponentWrapper.d.ts +1 -1
- package/dist/components/DatePicker/DatePicker.d.ts +5 -6
- package/dist/components/Fieldset/Fieldset.d.ts +5 -6
- package/dist/components/Form/Form.d.ts +6 -6
- package/dist/components/Grid/GridTypes.d.ts +7 -7
- package/dist/components/Grid/SimpleGrid.d.ts +1 -1
- package/dist/components/Heading/Heading.d.ts +5 -5
- package/dist/components/Heading/HeadingTypes.d.ts +1 -1
- package/dist/components/HelperErrorText/HelperErrorText.d.ts +9 -8
- package/dist/components/Hero/Hero.d.ts +9 -5
- package/dist/components/HorizontalRule/HorizontalRule.d.ts +2 -10
- package/dist/components/Icons/Icon.d.ts +2 -1
- package/dist/components/Icons/IconTypes.d.ts +1 -0
- package/dist/components/Image/Image.d.ts +27 -9
- package/dist/components/Image/ImageTypes.d.ts +4 -4
- package/dist/components/Label/Label.d.ts +7 -4
- package/dist/components/Link/Link.d.ts +1 -1
- package/dist/components/List/List.d.ts +11 -11
- package/dist/components/List/ListTypes.d.ts +1 -1
- package/dist/components/Logo/Logo.d.ts +2 -1
- package/dist/components/Logo/LogoSvgs.d.ts +2 -0
- package/dist/components/Logo/LogoTypes.d.ts +4 -2
- package/dist/components/Notification/Notification.d.ts +7 -7
- package/dist/components/Pagination/Pagination.d.ts +2 -2
- package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +3 -3
- package/dist/components/Radio/Radio.d.ts +5 -7
- package/dist/components/RadioGroup/RadioGroup.d.ts +16 -8
- package/dist/components/SearchBar/SearchBar.d.ts +4 -4
- package/dist/components/Select/Select.d.ts +12 -8
- package/dist/components/Select/SelectTypes.d.ts +4 -0
- package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +8 -6
- package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +0 -4
- package/dist/components/Slider/Slider.d.ts +6 -4
- package/dist/components/StatusBadge/StatusBadge.d.ts +5 -1
- package/dist/components/StructuredContent/StructuredContent.d.ts +10 -23
- package/dist/components/Table/Table.d.ts +1 -1
- package/dist/components/Tabs/Tabs.d.ts +7 -6
- package/dist/components/Template/Template.d.ts +17 -8
- package/dist/components/Text/Text.d.ts +4 -4
- package/dist/components/Text/TextTypes.d.ts +1 -1
- package/dist/components/TextInput/TextInput.d.ts +7 -7
- package/dist/components/Toggle/Toggle.d.ts +8 -10
- package/dist/components/Toggle/{ToggleSizes.d.ts → ToggleTypes.d.ts} +1 -1
- package/dist/components/VideoPlayer/VideoPlayer.d.ts +2 -1
- package/dist/design-system-react-components.cjs.development.js +2075 -1468
- 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 +2086 -1483
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/helpers/enums.d.ts +4 -0
- package/dist/hooks/useCarouselStyles.d.ts +3 -2
- package/dist/hooks/useNYPLTheme.d.ts +12 -0
- package/dist/index.d.ts +11 -9
- package/dist/styles.css +1 -1
- package/dist/theme/components/accordion.d.ts +7 -12
- package/dist/theme/components/breadcrumb.d.ts +3 -0
- package/dist/theme/components/button.d.ts +10 -2
- package/dist/theme/components/card.d.ts +44 -24
- package/dist/theme/components/checkbox.d.ts +6 -4
- package/dist/theme/components/checkboxGroup.d.ts +4 -2
- package/dist/theme/components/componentWrapper.d.ts +2 -2
- package/dist/theme/components/customTable.d.ts +84 -1
- package/dist/theme/components/fieldset.d.ts +4 -14
- package/dist/theme/components/global.d.ts +25 -18
- package/dist/theme/components/heading.d.ts +53 -0
- package/dist/theme/components/helperErrorText.d.ts +1 -0
- package/dist/theme/components/hero.d.ts +21 -15
- package/dist/theme/components/image.d.ts +1 -1
- package/dist/theme/components/label.d.ts +9 -10
- package/dist/theme/components/list.d.ts +99 -9
- package/dist/theme/components/notification.d.ts +4 -4
- package/dist/theme/components/pagination.d.ts +2 -5
- package/dist/theme/components/radio.d.ts +7 -4
- package/dist/theme/components/radioGroup.d.ts +4 -2
- package/dist/theme/components/select.d.ts +37 -5
- package/dist/theme/components/skeletonLoader.d.ts +2 -2
- package/dist/theme/components/slider.d.ts +6 -3
- package/dist/theme/components/structuredContent.d.ts +197 -0
- package/dist/theme/components/textInput.d.ts +18 -6
- package/dist/theme/components/toggle.d.ts +20 -5
- package/dist/theme/foundations/global.d.ts +2 -0
- package/dist/theme/foundations/radii.d.ts +1 -0
- package/dist/theme/foundations/spacing.d.ts +46 -43
- package/package.json +5 -6
- package/src/components/AccessibilityGuide/SkipNavigation.stories.mdx +34 -0
- package/src/components/Accordion/Accordion.stories.mdx +150 -66
- package/src/components/Accordion/Accordion.test.tsx +65 -17
- package/src/components/Accordion/Accordion.tsx +61 -27
- package/src/components/Accordion/AccordionTypes.tsx +5 -0
- package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +505 -14
- package/src/components/Autosuggest/Autosuggest.stories.mdx +4 -3
- package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +37 -19
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +57 -36
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +14 -13
- package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +1 -1
- package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +211 -12
- package/src/components/Button/Button.stories.mdx +87 -23
- package/src/components/Button/Button.test.tsx +25 -0
- package/src/components/Button/Button.tsx +18 -7
- package/src/components/Button/__snapshots__/Button.test.tsx.snap +27 -7
- package/src/components/Card/Card.stories.mdx +493 -329
- package/src/components/Card/Card.test.tsx +138 -18
- package/src/components/Card/Card.tsx +151 -85
- package/src/components/Card/__snapshots__/Card.test.tsx.snap +221 -101
- package/src/components/Chakra/Center.stories.mdx +2 -2
- package/src/components/Chakra/Grid.stories.mdx +4 -4
- package/src/components/Checkbox/Checkbox.stories.mdx +73 -9
- package/src/components/Checkbox/Checkbox.test.tsx +89 -10
- package/src/components/Checkbox/Checkbox.tsx +26 -16
- package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +209 -6
- package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +135 -23
- package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +216 -90
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +39 -26
- package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +493 -89
- package/src/components/ComponentWrapper/ComponentWrapper.test.tsx +12 -0
- package/src/components/ComponentWrapper/ComponentWrapper.tsx +39 -41
- package/src/components/ComponentWrapper/__snapshots__/ComponentWrapper.test.tsx.snap +47 -34
- package/src/components/DatePicker/DatePicker.stories.mdx +63 -27
- package/src/components/DatePicker/DatePicker.test.tsx +94 -15
- package/src/components/DatePicker/DatePicker.tsx +67 -58
- package/src/components/DatePicker/_DatePicker.scss +71 -13
- package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +250 -206
- package/src/components/Fieldset/Fieldset.stories.mdx +33 -3
- package/src/components/Fieldset/Fieldset.test.tsx +58 -28
- package/src/components/Fieldset/Fieldset.tsx +35 -30
- package/src/components/Fieldset/__snapshots__/Fieldset.test.tsx.snap +40 -19
- package/src/components/Form/Form.stories.mdx +118 -47
- package/src/components/Form/Form.test.tsx +59 -16
- package/src/components/Form/Form.tsx +89 -65
- package/src/components/Form/__snapshots__/Form.test.tsx.snap +83 -5
- package/src/components/Grid/GridTypes.tsx +7 -7
- package/src/components/Grid/SimpleGrid.stories.mdx +87 -41
- package/src/components/Grid/SimpleGrid.test.tsx +24 -9
- package/src/components/Grid/SimpleGrid.tsx +29 -20
- package/src/components/Grid/__snapshots__/SimpleGrid.test.tsx.snap +16 -1
- package/src/components/Heading/Heading.stories.mdx +56 -25
- package/src/components/Heading/Heading.test.tsx +17 -7
- package/src/components/Heading/Heading.tsx +60 -58
- package/src/components/Heading/HeadingTypes.tsx +1 -1
- package/src/components/Heading/__snapshots__/Heading.test.tsx.snap +27 -8
- package/src/components/HelperErrorText/HelperErrorText.stories.mdx +64 -42
- package/src/components/HelperErrorText/HelperErrorText.test.tsx +15 -0
- package/src/components/HelperErrorText/HelperErrorText.tsx +40 -35
- package/src/components/HelperErrorText/__snapshots__/HelperErrorText.test.tsx.snap +35 -4
- package/src/components/Hero/Hero.stories.mdx +143 -113
- package/src/components/Hero/Hero.test.tsx +146 -58
- package/src/components/Hero/Hero.tsx +144 -112
- package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +89 -17
- package/src/components/HorizontalRule/HorizontalRule.stories.mdx +26 -4
- package/src/components/HorizontalRule/HorizontalRule.test.tsx +9 -17
- package/src/components/HorizontalRule/HorizontalRule.tsx +9 -25
- package/src/components/HorizontalRule/__snapshots__/HorizontalRule.test.tsx.snap +18 -5
- package/src/components/Icons/Icon.stories.mdx +80 -23
- package/src/components/Icons/Icon.test.tsx +51 -2
- package/src/components/Icons/Icon.tsx +93 -71
- package/src/components/Icons/IconTypes.tsx +1 -0
- package/src/components/Icons/__snapshots__/Icon.test.tsx.snap +129 -0
- package/src/components/Image/Image.stories.mdx +160 -71
- package/src/components/Image/Image.test.tsx +40 -48
- package/src/components/Image/Image.tsx +80 -48
- package/src/components/Image/ImageTypes.ts +4 -4
- package/src/components/Image/__snapshots__/Image.test.tsx.snap +84 -21
- package/src/components/Label/Label.stories.mdx +42 -20
- package/src/components/Label/Label.test.tsx +42 -17
- package/src/components/Label/Label.tsx +22 -13
- package/src/components/Label/__snapshots__/Label.test.tsx.snap +19 -15
- package/src/components/Link/Link.stories.mdx +25 -1
- package/src/components/Link/Link.test.tsx +21 -0
- package/src/components/Link/Link.tsx +16 -9
- package/src/components/Link/__snapshots__/Link.test.tsx.snap +37 -11
- package/src/components/List/List.stories.mdx +75 -40
- package/src/components/List/List.test.tsx +73 -22
- package/src/components/List/List.tsx +44 -28
- package/src/components/List/ListTypes.tsx +1 -1
- package/src/components/List/__snapshots__/List.test.tsx.snap +110 -8
- package/src/components/Logo/Logo.stories.mdx +40 -16
- package/src/components/Logo/Logo.test.tsx +29 -2
- package/src/components/Logo/Logo.tsx +28 -11
- package/src/components/Logo/LogoSvgs.tsx +4 -0
- package/src/components/Logo/LogoTypes.tsx +3 -1
- package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +73 -2
- package/src/components/Modal/Modal.stories.mdx +13 -0
- package/src/components/Notification/Notification.stories.mdx +29 -5
- package/src/components/Notification/Notification.test.tsx +23 -0
- package/src/components/Notification/Notification.tsx +53 -51
- package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +158 -29
- package/src/components/Pagination/Pagination.stories.mdx +27 -6
- package/src/components/Pagination/Pagination.test.tsx +55 -2
- package/src/components/Pagination/Pagination.tsx +12 -9
- package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +244 -27
- package/src/components/Placeholder/Placeholder.tsx +3 -1
- package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +76 -10
- package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +87 -13
- package/src/components/ProgressIndicator/ProgressIndicator.tsx +20 -10
- package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +101 -14
- package/src/components/Radio/Radio.stories.mdx +75 -11
- package/src/components/Radio/Radio.test.tsx +83 -9
- package/src/components/Radio/Radio.tsx +70 -62
- package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +163 -5
- package/src/components/RadioGroup/RadioGroup.stories.mdx +293 -94
- package/src/components/RadioGroup/RadioGroup.test.tsx +193 -68
- package/src/components/RadioGroup/RadioGroup.tsx +110 -101
- package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +1258 -902
- package/src/components/SearchBar/SearchBar.stories.mdx +101 -36
- package/src/components/SearchBar/{SearchBar.Test.tsx → SearchBar.test.tsx} +46 -4
- package/src/components/SearchBar/SearchBar.tsx +20 -11
- package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +1039 -0
- package/src/components/Select/Select.stories.mdx +151 -62
- package/src/components/Select/Select.test.tsx +56 -44
- package/src/components/Select/Select.tsx +125 -104
- package/src/components/Select/SelectTypes.tsx +5 -0
- package/src/components/Select/__snapshots__/Select.test.tsx.snap +749 -409
- package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +53 -23
- package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +14 -8
- package/src/components/SkeletonLoader/SkeletonLoader.tsx +80 -78
- package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +0 -5
- package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +169 -10
- package/src/components/Slider/Slider.stories.mdx +123 -41
- package/src/components/Slider/Slider.test.tsx +65 -17
- package/src/components/Slider/Slider.tsx +30 -23
- package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +403 -226
- package/src/components/StatusBadge/StatusBadge.stories.mdx +19 -1
- package/src/components/StatusBadge/StatusBadge.test.tsx +19 -1
- package/src/components/StatusBadge/StatusBadge.tsx +25 -20
- package/src/components/StatusBadge/__snapshots__/StatusBadge.test.tsx.snap +22 -3
- package/src/components/StructuredContent/StructuredContent.stories.mdx +229 -61
- package/src/components/StructuredContent/StructuredContent.test.tsx +162 -101
- package/src/components/StructuredContent/StructuredContent.tsx +98 -103
- package/src/components/StructuredContent/__snapshots__/StructuredContent.test.tsx.snap +102 -17
- package/src/components/StyleGuide/Bidirectionality.stories.mdx +5 -5
- package/src/components/StyleGuide/Breakpoints.stories.mdx +6 -6
- package/src/components/StyleGuide/Buttons.stories.mdx +2 -12
- package/src/components/StyleGuide/ColorCard.tsx +4 -4
- package/src/components/StyleGuide/Colors.stories.mdx +1 -2
- package/src/components/StyleGuide/DesignTokens.stories.mdx +56 -26
- package/src/components/StyleGuide/Forms.stories.mdx +27 -12
- package/src/components/StyleGuide/Iconography.stories.mdx +2 -12
- package/src/components/StyleGuide/Spacing.stories.mdx +80 -41
- package/src/components/StyleGuide/Typography.stories.mdx +47 -33
- package/src/components/Table/Table.stories.mdx +38 -11
- package/src/components/Table/Table.test.tsx +16 -1
- package/src/components/Table/Table.tsx +10 -8
- package/src/components/Table/__snapshots__/Table.test.tsx.snap +408 -5
- package/src/components/Tabs/Tabs.stories.mdx +59 -10
- package/src/components/Tabs/Tabs.test.tsx +29 -11
- package/src/components/Tabs/Tabs.tsx +28 -21
- package/src/components/Tabs/__snapshots__/Tabs.test.tsx.snap +394 -5
- package/src/components/Template/Template.stories.mdx +73 -32
- package/src/components/Template/Template.test.tsx +68 -5
- package/src/components/Template/Template.tsx +89 -71
- package/src/components/Template/__snapshots__/Template.test.tsx.snap +195 -22
- package/src/components/Text/Text.stories.mdx +32 -15
- package/src/components/Text/Text.test.tsx +14 -11
- package/src/components/Text/Text.tsx +13 -16
- package/src/components/Text/TextTypes.tsx +1 -1
- package/src/components/Text/__snapshots__/Text.test.tsx.snap +21 -4
- package/src/components/TextInput/TextInput.stories.mdx +73 -27
- package/src/components/TextInput/TextInput.test.tsx +65 -50
- package/src/components/TextInput/TextInput.tsx +123 -115
- package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +96 -73
- package/src/components/Toggle/Toggle.stories.mdx +74 -26
- package/src/components/Toggle/Toggle.test.tsx +41 -10
- package/src/components/Toggle/Toggle.tsx +29 -26
- package/src/components/Toggle/{ToggleSizes.tsx → ToggleTypes.tsx} +1 -1
- package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +191 -4
- package/src/components/VideoPlayer/VideoPlayer.stories.mdx +52 -4
- package/src/components/VideoPlayer/VideoPlayer.test.tsx +41 -6
- package/src/components/VideoPlayer/VideoPlayer.tsx +134 -120
- package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +81 -39
- package/src/docs/Chakra.stories.mdx +50 -9
- package/src/docs/Welcome.stories.mdx +168 -0
- package/src/{components/Card/CardTypes.tsx → helpers/enums.ts} +2 -2
- package/src/hooks/tests/useNYPLTheme.test.tsx +1 -1
- package/src/hooks/useCarouselStyles.stories.mdx +30 -0
- package/src/hooks/useCarouselStyles.ts +3 -2
- package/src/hooks/useNYPLTheme.stories.mdx +101 -0
- package/src/hooks/useNYPLTheme.ts +31 -7
- package/src/hooks/useWindowSize.stories.mdx +23 -0
- package/src/index.ts +11 -15
- package/src/styles/base/_place-holder.scss +1 -1
- package/src/theme/components/accordion.ts +7 -12
- package/src/theme/components/breadcrumb.ts +3 -0
- package/src/theme/components/button.ts +15 -7
- package/src/theme/components/card.ts +56 -36
- package/src/theme/components/checkbox.ts +10 -8
- package/src/theme/components/checkboxGroup.ts +4 -2
- package/src/theme/components/componentWrapper.ts +2 -2
- package/src/theme/components/customTable.ts +39 -31
- package/src/theme/components/fieldset.ts +1 -2
- package/src/theme/components/global.ts +29 -23
- package/src/theme/components/heading.ts +1 -1
- package/src/theme/components/helperErrorText.ts +1 -0
- package/src/theme/components/hero.ts +14 -16
- package/src/theme/components/icon.ts +5 -2
- package/src/theme/components/image.ts +1 -1
- package/src/theme/components/label.ts +4 -3
- package/src/theme/components/list.ts +73 -66
- package/src/theme/components/notification.ts +7 -7
- package/src/theme/components/pagination.ts +2 -5
- package/src/theme/components/progressIndicator.ts +3 -3
- package/src/theme/components/radio.ts +9 -9
- package/src/theme/components/radioGroup.ts +4 -2
- package/src/theme/components/select.ts +35 -16
- package/src/theme/components/skeletonLoader.ts +3 -3
- package/src/theme/components/slider.ts +8 -7
- package/src/theme/components/statusBadge.ts +2 -2
- package/src/theme/components/structuredContent.ts +66 -1
- package/src/theme/components/tabs.ts +2 -2
- package/src/theme/components/template.ts +9 -9
- package/src/theme/components/textInput.ts +13 -12
- package/src/theme/components/toggle.ts +43 -13
- package/src/theme/components/videoPlayer.ts +1 -1
- package/src/theme/foundations/colors.ts +1 -1
- package/src/theme/foundations/radii.ts +1 -0
- package/src/theme/foundations/spacing.ts +70 -22
- package/src/theme/foundations/typography.ts +2 -2
- package/src/utils/componentCategories.ts +28 -21
- package/dist/components/Card/CardTypes.d.ts +0 -4
- package/dist/components/CheckboxGroup/CheckboxGroupLayoutTypes.d.ts +0 -4
- package/dist/components/RadioGroup/RadioGroupLayoutTypes.d.ts +0 -4
- package/dist/components/SearchBar/SearchBar.Test.d.ts +0 -1
- package/dist/helpers/generateUUID.d.ts +0 -1
- package/src/components/CheckboxGroup/CheckboxGroupLayoutTypes.tsx +0 -4
- package/src/components/RadioGroup/RadioGroupLayoutTypes.tsx +0 -4
- package/src/docs/Intro.stories.mdx +0 -53
- package/src/helpers/generateUUID.tsx +0 -5
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Meta } from "@storybook/addon-docs";
|
|
2
|
-
import { withDesign } from "storybook-addon-designs";
|
|
3
2
|
|
|
4
3
|
import Card from "../Card/Card";
|
|
5
4
|
import List from "../List/List";
|
|
@@ -7,66 +6,106 @@ import { ListTypes } from "../List/ListTypes";
|
|
|
7
6
|
import { getCategory } from "../../utils/componentCategories";
|
|
8
7
|
import DSProvider from "../../theme/provider";
|
|
9
8
|
|
|
10
|
-
<Meta
|
|
11
|
-
title={getCategory("Spacing")}
|
|
12
|
-
decorators={[withDesign]}
|
|
13
|
-
parameters={{
|
|
14
|
-
design: {
|
|
15
|
-
type: "figma",
|
|
16
|
-
url: "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Master?node-id=17249%3A13",
|
|
17
|
-
},
|
|
18
|
-
}}
|
|
19
|
-
/>
|
|
9
|
+
<Meta title={getCategory("Spacing")} />
|
|
20
10
|
|
|
21
11
|
# Spacing
|
|
22
12
|
|
|
23
|
-
| Table of Contents
|
|
24
|
-
|
|
|
25
|
-
| 1. [General Information](#general-information)
|
|
26
|
-
| 2. [
|
|
27
|
-
| 3. [Section Spacing](#section-spacing)
|
|
28
|
-
| 4. [Grid Spacing](#grid-spacing)
|
|
29
|
-
| 5. [
|
|
30
|
-
| 6. [
|
|
31
|
-
| 7. [Figma Reference](#figma-reference)
|
|
13
|
+
| Table of Contents |
|
|
14
|
+
| ---------------------------------------------------- |
|
|
15
|
+
| 1. [General Information](#general-information) |
|
|
16
|
+
| 2. [Default Spacing Values](#default-spacing-values) |
|
|
17
|
+
| 3. [Page Section Spacing](#page-section-spacing) |
|
|
18
|
+
| 4. [Grid Spacing](#grid-spacing) |
|
|
19
|
+
| 5. [Form Spacing](#form-spacing) |
|
|
20
|
+
| 6. [Tabular Data Spacing](#tabular-data-spacing) |
|
|
21
|
+
| 7. [Figma Reference](#figma-reference) |
|
|
32
22
|
|
|
33
23
|
## General Information
|
|
34
24
|
|
|
35
|
-
The DS spacing values are based on a root
|
|
25
|
+
The Reservoir Design System (DS) spacing values are based on a root unit
|
|
26
|
+
of `16px` (`1rem` = `16px`).
|
|
36
27
|
|
|
37
|
-
##
|
|
28
|
+
## Default Spacing Values
|
|
38
29
|
|
|
39
30
|
<DSProvider>
|
|
40
|
-
The following
|
|
41
|
-
|
|
42
|
-
|
|
|
43
|
-
| ------------------- | -------------- | ---------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
44
|
-
| `--nypl-space-
|
|
45
|
-
| `--nypl-space-
|
|
46
|
-
| `--nypl-space-
|
|
47
|
-
| `--nypl-space-
|
|
48
|
-
| `--nypl-space-
|
|
49
|
-
| `--nypl-space-
|
|
50
|
-
| `--nypl-space-
|
|
51
|
-
| `--nypl-space-
|
|
31
|
+
The following default spacing values are available through the DS.
|
|
32
|
+
|
|
33
|
+
| JS Theme Object | CSS Variable | REM Equivalent | Pixel Equivalent | Visual Reference |
|
|
34
|
+
| --------------- | ------------------- | -------------- | ---------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
35
|
+
| `xxxs` | `--nypl-space-xxxs` | `0.125rem` | `2px` | <div style={{ width: "var(--nypl-space-xxxs)", backgroundColor: "var(--nypl-colors-ui-focus)" }}> </div> |
|
|
36
|
+
| `xxs` | `--nypl-space-xxs` | `0.25rem` | `4px` | <div style={{ width: "var(--nypl-space-xxs)", backgroundColor: "var(--nypl-colors-ui-focus)" }}> </div> |
|
|
37
|
+
| `xs` | `--nypl-space-xs` | `0.5rem` | `8px` | <div style={{ width: "var(--nypl-space-xs)", backgroundColor: "var(--nypl-colors-ui-focus)" }}> </div> |
|
|
38
|
+
| `s` | `--nypl-space-s` | `1rem` | `16px` | <div style={{ width: "var(--nypl-space-s)", backgroundColor: "var(--nypl-colors-ui-focus)" }}> </div> |
|
|
39
|
+
| `m` | `--nypl-space-m` | `1.5rem` | `24px` | <div style={{ width: "var(--nypl-space-m)", backgroundColor: "var(--nypl-colors-ui-focus)" }}> </div> |
|
|
40
|
+
| `l` | `--nypl-space-l` | `2rem` | `32px` | <div style={{ width: "var(--nypl-space-l)", backgroundColor: "var(--nypl-colors-ui-focus)" }}> </div> |
|
|
41
|
+
| `xl` | `--nypl-space-xl` | `3rem` | `48px` | <div style={{ width: "var(--nypl-space-xl)", backgroundColor: "var(--nypl-colors-ui-focus)" }}> </div> |
|
|
42
|
+
| `xxl` | `--nypl-space-xxl` | `4rem` | `64px` | <div style={{ width: "var(--nypl-space-xxl)", backgroundColor: "var(--nypl-colors-ui-focus)" }}> </div> |
|
|
43
|
+
| `xxxl` | `--nypl-space-xxxl` | `6rem` | `96px` | <div style={{ width: "var(--nypl-space-xxxl)", backgroundColor: "var(--nypl-colors-ui-focus)" }}> </div> |
|
|
52
44
|
|
|
53
45
|
</DSProvider>
|
|
54
46
|
|
|
55
|
-
## Section Spacing
|
|
47
|
+
## Page Section Spacing
|
|
56
48
|
|
|
57
|
-
In consuming apps, the major page sections should be separated vertically by
|
|
49
|
+
In consuming apps, the major page sections should be separated vertically by
|
|
50
|
+
`2rem`. This includes the space after the page global `header` and the space
|
|
51
|
+
before the global `footer`. Similarly, the major page sections should be
|
|
52
|
+
separated horizontally by `2rem`.
|
|
58
53
|
|
|
59
|
-
|
|
54
|
+
| | Value | JS Theme Object | CSS Variable |
|
|
55
|
+
| ---------------------- | ------ | --------------- | ---------------------------- |
|
|
56
|
+
| **Vertical Spacing** | `2rem` | `page.vstack` | `--nypl-spacing-page-vstack` |
|
|
57
|
+
| **Horizontal Spacing** | `2rem` | `page.hstack` | `--nypl-spacing-page-hstack` |
|
|
60
58
|
|
|
61
|
-
|
|
59
|
+
## Grid Spacing
|
|
62
60
|
|
|
63
|
-
|
|
61
|
+
When elements are displayed in a grid (i.e. Cards, Images, etc.), the space
|
|
62
|
+
between elements, both horizontal and vertical, should be `2rem`.
|
|
64
63
|
|
|
65
|
-
|
|
64
|
+
| | Value | JS Theme Object | CSS Variable |
|
|
65
|
+
| --------------- | ------ | --------------- | ----------------------------- |
|
|
66
|
+
| **Default Gap** | `2rem` | `grid.default` | `--nypl-spacing-grid-default` |
|
|
66
67
|
|
|
67
68
|
## Form Spacing
|
|
68
69
|
|
|
69
|
-
Form input components should have a `2rem`
|
|
70
|
+
Form input components should have a `2rem` space between each form input
|
|
71
|
+
component. This includes both vertical (column) and horizontal (row) stacking.
|
|
72
|
+
The DS [Form](https://nypl.github.io/nypl-design-system/storybook-static/?path=/docs/components-form-elements-form--form-with-controls)
|
|
73
|
+
component has correct spacing incorporated into its UI structure and should
|
|
74
|
+
always be used when building forms. Please note that the spacing in the `Form`
|
|
75
|
+
component is identical to the spacing in the `Grid` component.
|
|
76
|
+
|
|
77
|
+
When `Checkbox` and `Radio` components are grouped together, the components
|
|
78
|
+
should have a `1rem` space between components for vertical (column) stacking
|
|
79
|
+
and a `2rem` space between components for horizontal (row) stacking. The DS
|
|
80
|
+
`CheckboxGroup` and `RadioGroup` components have the correct spacing built
|
|
81
|
+
|
|
82
|
+
in and should be used respectively when multiple `Checkbox` or `radio`
|
|
83
|
+
components are being used together.
|
|
84
|
+
|
|
85
|
+
When `Button` components are grouped together, the `Button` components should
|
|
86
|
+
have a `0.5rem` space between component. This includes both vertical (column)
|
|
87
|
+
and horizontal (row) stacking. The DS `ButtonGroup` component has the correct
|
|
88
|
+
spacing built in and should be used when multiple `Button` components are being
|
|
89
|
+
used together.
|
|
90
|
+
|
|
91
|
+
| | Value | JS Theme Object | CSS Variable |
|
|
92
|
+
| -------------------------------------- | -------- | ---------------------------- | ------------------------------------------- |
|
|
93
|
+
| **Default Form Gap** | `2rem` | `grid.default` | `--nypl-spacing-grid-default` |
|
|
94
|
+
| **Input Group Default Row Spacing** | `2rem` | `input.group.default.hstack` | `--nypl-spacing-input-group-default-hstack` |
|
|
95
|
+
| **Input Group Default Column Spacing** | `1rem` | `input.group.default.vstack` | `--nypl-spacing-input-group-default-vstack` |
|
|
96
|
+
| **Button Group Row Spacing** | `0.5rem` | `input.group.button.hstack` | `--nypl-spacing-input-group-button-hstack` |
|
|
97
|
+
| **Button Group Column Spacing** | `0.5rem` | `input.group.button.vstack` | `--nypl-spacing-input-group-button-vstack` |
|
|
98
|
+
|
|
99
|
+
## Tabular Data Spacing
|
|
100
|
+
|
|
101
|
+
When data is displayed in a tabular layout (i.e. rows and columns in a table,
|
|
102
|
+
a description list, etc.), the space between data cells in a row should be
|
|
103
|
+
`1.5rem` and the space between rows should be `2rem`.
|
|
104
|
+
|
|
105
|
+
| | Value | JS Theme Object | CSS Variable |
|
|
106
|
+
| -------------- | -------- | --------------- | ----------------------------- |
|
|
107
|
+
| **Column Gap** | `1.5rem` | `table.column` | `--nypl-spacing-table-column` |
|
|
108
|
+
| **Row Gap** | `2rem` | `table.row` | `--nypl-spacing-table-row` |
|
|
70
109
|
|
|
71
110
|
## Figma Reference
|
|
72
111
|
|
|
@@ -1,25 +1,15 @@
|
|
|
1
1
|
import { Canvas, Meta } from "@storybook/addon-docs";
|
|
2
|
-
import { withDesign } from "storybook-addon-designs";
|
|
3
2
|
|
|
4
3
|
import Heading from "../Heading/Heading";
|
|
5
|
-
import {
|
|
4
|
+
import { HeadingSizes, HeadingLevels } from "../Heading/HeadingTypes";
|
|
6
5
|
import List from "../List/List";
|
|
7
6
|
import { ListTypes } from "../List/ListTypes";
|
|
8
7
|
import Text from "../Text/Text";
|
|
9
|
-
import {
|
|
8
|
+
import { TextSizes } from "../Text/TextTypes";
|
|
10
9
|
import { getCategory } from "../../utils/componentCategories";
|
|
11
10
|
import DSProvider from "../../theme/provider";
|
|
12
11
|
|
|
13
|
-
<Meta
|
|
14
|
-
title={getCategory("Typography")}
|
|
15
|
-
decorators={[withDesign]}
|
|
16
|
-
parameters={{
|
|
17
|
-
design: {
|
|
18
|
-
type: "figma",
|
|
19
|
-
url: "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Master?node-id=10975%3A16",
|
|
20
|
-
},
|
|
21
|
-
}}
|
|
22
|
-
/>
|
|
12
|
+
<Meta title={getCategory("Typography")} />
|
|
23
13
|
|
|
24
14
|
# Typography
|
|
25
15
|
|
|
@@ -38,13 +28,18 @@ import DSProvider from "../../theme/provider";
|
|
|
38
28
|
|
|
39
29
|
## General Information
|
|
40
30
|
|
|
41
|
-
Consuming applications should utilize the
|
|
31
|
+
Consuming applications should utilize the Reservoir Design System (DS) standard
|
|
32
|
+
text components as much as possible. In cases where that is not possible, the
|
|
33
|
+
DS exposes CSS variables to assist with formatting text elements.
|
|
42
34
|
|
|
43
|
-
The sizing of all text elements in the Design System is based on `1rem` being
|
|
35
|
+
The sizing of all text elements in the Design System is based on `1rem` being
|
|
36
|
+
equal to `16px`.
|
|
44
37
|
|
|
45
38
|
## Heading Component
|
|
46
39
|
|
|
47
|
-
Use the
|
|
40
|
+
Use the DS [Heading](/docs/components-typography-styles-heading--heading-props)
|
|
41
|
+
component to render a standard HTML `<h>` tag. The `level` prop can be used to
|
|
42
|
+
set the specific `<h>` tag that you require.
|
|
48
43
|
|
|
49
44
|
<Canvas>
|
|
50
45
|
<DSProvider>
|
|
@@ -59,9 +54,14 @@ Use the NYPL Design System [Heading](/docs/components-typography-styles-heading-
|
|
|
59
54
|
|
|
60
55
|
<DSProvider>
|
|
61
56
|
|
|
62
|
-
Each heading level has a default style and size, but those styles can be overridden
|
|
57
|
+
Each heading level has a default style and size, but those styles can be overridden
|
|
58
|
+
using the `size` prop. The display sizes are separate from semantic elements and
|
|
59
|
+
may be used to override the default size and styling of the semantic HTML heading
|
|
60
|
+
elements. For example, the `h1` element has the `Primary` style applied by default,
|
|
61
|
+
but a new style can be applied through the `size` prop. Any `size` style can be
|
|
62
|
+
applied to any `Heading` element.
|
|
63
63
|
|
|
64
|
-
<Heading level={HeadingLevels.One}
|
|
64
|
+
<Heading level={HeadingLevels.One} size={HeadingSizes.Primary}>
|
|
65
65
|
Primary Heading
|
|
66
66
|
</Heading>
|
|
67
67
|
|
|
@@ -71,7 +71,7 @@ Each heading level has a default style and size, but those styles can be overrid
|
|
|
71
71
|
| **Font Weight** | `300` | `fontWeight: "heading.primary"` | `font-weight: var(--nypl-fontWeights-heading-primary)` |
|
|
72
72
|
| **Line Height** | `1.1` | n/a | n/a |
|
|
73
73
|
|
|
74
|
-
<Heading level={HeadingLevels.One}
|
|
74
|
+
<Heading level={HeadingLevels.One} size={HeadingSizes.Secondary}>
|
|
75
75
|
Secondary Heading
|
|
76
76
|
</Heading>
|
|
77
77
|
|
|
@@ -81,7 +81,7 @@ Each heading level has a default style and size, but those styles can be overrid
|
|
|
81
81
|
| **Font Weight** | `500` | `fontWeight: "heading.secondary"` | `font-weight: var(--nypl-fontWeights-heading-secondary)` |
|
|
82
82
|
| **Line Height** | `1.25` | n/a | n/a |
|
|
83
83
|
|
|
84
|
-
<Heading level={HeadingLevels.One}
|
|
84
|
+
<Heading level={HeadingLevels.One} size={HeadingSizes.Tertiary}>
|
|
85
85
|
Tertiary Heading
|
|
86
86
|
</Heading>
|
|
87
87
|
|
|
@@ -91,7 +91,7 @@ Each heading level has a default style and size, but those styles can be overrid
|
|
|
91
91
|
| **Font Weight** | `500` | `fontWeight: "heading.tertiary"` | `font-weight: var(--nypl-fontWeights-heading-tertiary)` |
|
|
92
92
|
| **Line Height** | `1.25` | n/a | n/a |
|
|
93
93
|
|
|
94
|
-
<Heading level={HeadingLevels.One}
|
|
94
|
+
<Heading level={HeadingLevels.One} size={HeadingSizes.Callout}>
|
|
95
95
|
Callout Heading
|
|
96
96
|
</Heading>
|
|
97
97
|
|
|
@@ -105,7 +105,9 @@ Each heading level has a default style and size, but those styles can be overrid
|
|
|
105
105
|
|
|
106
106
|
## Text Component
|
|
107
107
|
|
|
108
|
-
Use the
|
|
108
|
+
Use the DS [Text](/docs/components-typography-styles-text--text)
|
|
109
|
+
component to render a standard HTML `<p>` tag. The Text component is generally
|
|
110
|
+
used for body copy, captions and secondary captions.
|
|
109
111
|
|
|
110
112
|
<Canvas>
|
|
111
113
|
<DSProvider>
|
|
@@ -122,12 +124,12 @@ Use the NYPL Design System [Text](/docs/components-typography-styles-text--text)
|
|
|
122
124
|
|
|
123
125
|
<DSProvider>
|
|
124
126
|
|
|
125
|
-
The `
|
|
127
|
+
The `size` prop can be used to render a specific style from the DS default text styles.
|
|
126
128
|
|
|
127
129
|
- [Typography: Body Styles](https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Main?node-id=10975%3A52)
|
|
128
130
|
- [Typography: Other Styles](https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Main?node-id=10975%3A100)
|
|
129
131
|
|
|
130
|
-
<Text
|
|
132
|
+
<Text size={TextSizes.Default}>Default</Text>
|
|
131
133
|
|
|
132
134
|
| | Value | JS Theme Object | CSS Variable |
|
|
133
135
|
| --------------- | ------ | ---------------------------- | --------------------------------------------------- |
|
|
@@ -135,7 +137,7 @@ The `displaySize` prop can be used to render a specific style from the DS defaul
|
|
|
135
137
|
| **Font Weight** | `300` | `fontWeight: "text.default"` | `font-weight: var(--nypl-fontWeights-text-default)` |
|
|
136
138
|
| **Line Height** | `1.5` | `fontWeight: 1.5` | `font-weight: 1.5` |
|
|
137
139
|
|
|
138
|
-
<Text
|
|
140
|
+
<Text size={TextSizes.Caption}>Caption</Text>
|
|
139
141
|
|
|
140
142
|
| | Value | JS Theme Object | CSS Variable |
|
|
141
143
|
| --------------- | ---------- | ---------------------------- | --------------------------------------------------- |
|
|
@@ -143,7 +145,7 @@ The `displaySize` prop can be used to render a specific style from the DS defaul
|
|
|
143
145
|
| **Font Weight** | `300` | `fontWeight: "text.caption"` | `font-weight: var(--nypl-fontWeights-text-caption)` |
|
|
144
146
|
| **Line Height** | `1.25` | `fontWeight: 1.25` | `font-weight: 1.25` |
|
|
145
147
|
|
|
146
|
-
<Text
|
|
148
|
+
<Text size={TextSizes.Tag}>Tag</Text>
|
|
147
149
|
|
|
148
150
|
| | Value | JS Theme Object | CSS Variable |
|
|
149
151
|
| --------------- | --------- | ------------------------ | ----------------------------------------------- |
|
|
@@ -151,7 +153,7 @@ The `displaySize` prop can be used to render a specific style from the DS defaul
|
|
|
151
153
|
| **Font Weight** | `400` | `fontWeight: "text.tag"` | `font-weight: var(--nypl-fontWeights-text-tag)` |
|
|
152
154
|
| **Line Height** | `1.5` | `fontWeight: 1.5` | `font-weight: 1.5` |
|
|
153
155
|
|
|
154
|
-
<Text
|
|
156
|
+
<Text size={TextSizes.Mini}>Mini</Text>
|
|
155
157
|
|
|
156
158
|
| | Value | JS Theme Object | CSS Variable |
|
|
157
159
|
| --------------- | ---------- | ------------------------- | ------------------------------------------------ |
|
|
@@ -163,7 +165,9 @@ The `displaySize` prop can be used to render a specific style from the DS defaul
|
|
|
163
165
|
|
|
164
166
|
## Font Family
|
|
165
167
|
|
|
166
|
-
With website accessibility in mind, font choices for the DS were made with an
|
|
168
|
+
With website accessibility in mind, font choices for the DS were made with an
|
|
169
|
+
eye toward clarity and readability. Headings and body content use the
|
|
170
|
+
following font family assignment:
|
|
167
171
|
|
|
168
172
|
<Canvas>
|
|
169
173
|
<DSProvider>
|
|
@@ -179,11 +183,15 @@ The following CSS variables are available through the DS.
|
|
|
179
183
|
```
|
|
180
184
|
|
|
181
185
|
> **RECOMMENDATIONS**
|
|
182
|
-
> When making font selections for project based components outside the DS,
|
|
186
|
+
> When making font selections for project based components outside the DS,
|
|
187
|
+
> sans serif fonts display better on computers and mobile devices. Avoid
|
|
188
|
+
> decorative or overly stylized fonts, as they are often difficult to read even
|
|
189
|
+
> for users without visual impairments or reading Standard Text Default
|
|
183
190
|
|
|
184
191
|
## Font Color
|
|
185
192
|
|
|
186
|
-
All text within a project, unless specifically noted in mockups, should be
|
|
193
|
+
All text within a project, unless specifically noted in mockups, should be
|
|
194
|
+
black on a white background.
|
|
187
195
|
|
|
188
196
|
<Canvas>
|
|
189
197
|
<DSProvider>
|
|
@@ -198,7 +206,10 @@ All text within a project, unless specifically noted in mockups, should be black
|
|
|
198
206
|
</DSProvider>
|
|
199
207
|
</Canvas>
|
|
200
208
|
|
|
201
|
-
In cases where specific colors must be applied to text elements, the DS
|
|
209
|
+
In cases where specific colors must be applied to text elements, the DS
|
|
210
|
+
provides CSS variables for the full NYPL color palette. Refer to the
|
|
211
|
+
[Colors](https://nypl.github.io/nypl-design-system/storybook-static/?path=/docs/style-guide-colors--colors-brand)
|
|
212
|
+
section of the Style Guide for details.
|
|
202
213
|
|
|
203
214
|
## Font Weight
|
|
204
215
|
|
|
@@ -342,7 +353,9 @@ The following font size design tokens are available through the DS.
|
|
|
342
353
|
|
|
343
354
|
## Text Case
|
|
344
355
|
|
|
345
|
-
In general, the New York Public Library uses Title Case for titles. This means
|
|
356
|
+
In general, the New York Public Library uses Title Case for titles. This means
|
|
357
|
+
only using capital letters for the principal words. Articles, conjunctions, and
|
|
358
|
+
prepositions do not get capital letters unless they start the title. For example:
|
|
346
359
|
|
|
347
360
|
<Canvas>
|
|
348
361
|
<DSProvider>
|
|
@@ -373,7 +386,8 @@ In general, the New York Public Library uses Title Case for titles. This means o
|
|
|
373
386
|
### Summaries
|
|
374
387
|
|
|
375
388
|
140 characters max<br />
|
|
376
|
-
Note: Online Exhibitions, with their longer, legacy summaries are an exception
|
|
389
|
+
Note: Online Exhibitions, with their longer, legacy summaries are an exception
|
|
390
|
+
to this.
|
|
377
391
|
|
|
378
392
|
<Canvas>
|
|
379
393
|
<DSProvider>
|
|
@@ -36,7 +36,19 @@ import { getCategory } from "../../utils/componentCategories";
|
|
|
36
36
|
| Component Version | DS Version |
|
|
37
37
|
| ----------------- | ---------- |
|
|
38
38
|
| Added | `0.25.9` |
|
|
39
|
-
| Latest | `0.
|
|
39
|
+
| Latest | `0.26.0` |
|
|
40
|
+
|
|
41
|
+
## Table of Contents
|
|
42
|
+
|
|
43
|
+
- [Overview](#overview)
|
|
44
|
+
- [Component Props](#component-props)
|
|
45
|
+
- [Accessibility](#accessibility)
|
|
46
|
+
- [With a title](#with-a-title)
|
|
47
|
+
- [With Row Dividers](#with-row-dividers)
|
|
48
|
+
- [With Row Headers](#with-row-headers)
|
|
49
|
+
- [With Custom Header Colors](#with-custom-header-colors)
|
|
50
|
+
|
|
51
|
+
## Overview
|
|
40
52
|
|
|
41
53
|
<Description of={Table} />
|
|
42
54
|
|
|
@@ -64,6 +76,8 @@ export const tableData = [
|
|
|
64
76
|
],
|
|
65
77
|
];
|
|
66
78
|
|
|
79
|
+
## Component Props
|
|
80
|
+
|
|
67
81
|
<Canvas withToolbar>
|
|
68
82
|
<Story
|
|
69
83
|
name="Table"
|
|
@@ -87,16 +101,29 @@ export const tableData = [
|
|
|
87
101
|
|
|
88
102
|
## Accessibility
|
|
89
103
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
104
|
+
Internally, the HTML for the `Table` element is structured with proper semantic
|
|
105
|
+
use of the `table`, `caption`, `thead`, `tbody`, `tr`, and `td` HTML elements.
|
|
106
|
+
When titles are added through the `titleText` prop, the `caption` element will
|
|
107
|
+
be rendered above the `thead` element.
|
|
108
|
+
|
|
109
|
+
This component should be used to render tabular data only and not used for layout
|
|
110
|
+
purposes.
|
|
111
|
+
|
|
112
|
+
The first row and/or the first cell in a `tr` row can be headers. Each `th`
|
|
113
|
+
header cell has an appropriate scope attribute set to either `scope="col"` or
|
|
114
|
+
`scope="row"`. For example, every `th` cell in a `thead` `tr` row will have
|
|
115
|
+
`scope="col"`. Every `th` cell in a `tbody` `tr` row will have `scope="row"`.
|
|
116
|
+
These headers are visually different from the data. Use the `useRowHeaders`
|
|
117
|
+
prop to render the first cell in every row as a header. If a table has two levels
|
|
118
|
+
of headers (such as two levels of horizontal headers), break the data into two
|
|
119
|
+
separate tables.
|
|
120
|
+
|
|
121
|
+
Resources:
|
|
122
|
+
|
|
123
|
+
- [W3C Tables Tutorial](https://www.w3.org/WAI/tutorials/tables/)
|
|
124
|
+
- [MDN table: The Table element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table)
|
|
125
|
+
- [MDN HTML table advance features and accessibility](https://developer.mozilla.org/en-US/docs/Learn/HTML/Tables/Advanced)
|
|
126
|
+
- [Chakra UI Table](https://chakra-ui.com/docs/components/data-display/table)
|
|
100
127
|
|
|
101
128
|
## With a title
|
|
102
129
|
|
|
@@ -76,7 +76,7 @@ describe("Table", () => {
|
|
|
76
76
|
const warn = jest.spyOn(console, "warn");
|
|
77
77
|
render(<Table tableData={[]} />);
|
|
78
78
|
expect(warn).toHaveBeenCalledWith(
|
|
79
|
-
"Table:
|
|
79
|
+
"NYPL Reservoir Table: Data in the `tableData` prop must be a two dimensional array."
|
|
80
80
|
);
|
|
81
81
|
});
|
|
82
82
|
|
|
@@ -127,11 +127,26 @@ describe("Table", () => {
|
|
|
127
127
|
/>
|
|
128
128
|
)
|
|
129
129
|
.toJSON();
|
|
130
|
+
const withChakraProps = renderer
|
|
131
|
+
.create(
|
|
132
|
+
<Table
|
|
133
|
+
id="chakra"
|
|
134
|
+
tableData={tableData}
|
|
135
|
+
p="20px"
|
|
136
|
+
color="ui.error.primary"
|
|
137
|
+
/>
|
|
138
|
+
)
|
|
139
|
+
.toJSON();
|
|
140
|
+
const withOtherProps = renderer
|
|
141
|
+
.create(<Table id="props" tableData={tableData} data-testid="props" />)
|
|
142
|
+
.toJSON();
|
|
130
143
|
|
|
131
144
|
expect(basic).toMatchSnapshot();
|
|
132
145
|
expect(withCaption).toMatchSnapshot();
|
|
133
146
|
expect(withHeaders).toMatchSnapshot();
|
|
134
147
|
expect(withRowHeaders).toMatchSnapshot();
|
|
135
148
|
expect(withCustomHeaderColors).toMatchSnapshot();
|
|
149
|
+
expect(withChakraProps).toMatchSnapshot();
|
|
150
|
+
expect(withOtherProps).toMatchSnapshot();
|
|
136
151
|
});
|
|
137
152
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
import {
|
|
2
|
+
chakra,
|
|
3
3
|
Table as ChakraTable,
|
|
4
4
|
TableCaption as ChakraTableCaption,
|
|
5
5
|
Tbody as ChakraTbody,
|
|
@@ -9,8 +9,7 @@ import {
|
|
|
9
9
|
Tr as ChakraTr,
|
|
10
10
|
useMultiStyleConfig,
|
|
11
11
|
} from "@chakra-ui/react";
|
|
12
|
-
|
|
13
|
-
import generateUUID from "../../helpers/generateUUID";
|
|
12
|
+
import * as React from "react";
|
|
14
13
|
|
|
15
14
|
export interface TableProps {
|
|
16
15
|
/** Additional class name for the `Table` component. */
|
|
@@ -39,17 +38,18 @@ export interface TableProps {
|
|
|
39
38
|
* Basic `Table` component used to organize and display tabular data in
|
|
40
39
|
* rows and columns.
|
|
41
40
|
*/
|
|
42
|
-
|
|
41
|
+
export const Table = chakra((props: React.PropsWithChildren<TableProps>) => {
|
|
43
42
|
const {
|
|
44
43
|
className,
|
|
45
44
|
columnHeaders,
|
|
46
45
|
columnHeadersBackgroundColor,
|
|
47
46
|
columnHeadersTextColor,
|
|
48
|
-
id
|
|
47
|
+
id,
|
|
49
48
|
showRowDividers = false,
|
|
50
49
|
tableData,
|
|
51
50
|
titleText,
|
|
52
51
|
useRowHeaders = false,
|
|
52
|
+
...rest
|
|
53
53
|
} = props;
|
|
54
54
|
|
|
55
55
|
const customColors = {};
|
|
@@ -91,7 +91,9 @@ function Table(props: React.PropsWithChildren<TableProps>) {
|
|
|
91
91
|
tableData.length <= 0 ||
|
|
92
92
|
tableData[0].constructor !== Array
|
|
93
93
|
) {
|
|
94
|
-
console.warn(
|
|
94
|
+
console.warn(
|
|
95
|
+
"NYPL Reservoir Table: Data in the `tableData` prop must be a two dimensional array."
|
|
96
|
+
);
|
|
95
97
|
return null;
|
|
96
98
|
}
|
|
97
99
|
|
|
@@ -115,12 +117,12 @@ function Table(props: React.PropsWithChildren<TableProps>) {
|
|
|
115
117
|
};
|
|
116
118
|
|
|
117
119
|
return (
|
|
118
|
-
<ChakraTable id={id} sx={styles} className={className}>
|
|
120
|
+
<ChakraTable id={id} sx={styles} className={className} {...rest}>
|
|
119
121
|
{tableCaption}
|
|
120
122
|
{columnHeadersElems}
|
|
121
123
|
{tableBodyElems()}
|
|
122
124
|
</ChakraTable>
|
|
123
125
|
);
|
|
124
|
-
}
|
|
126
|
+
});
|
|
125
127
|
|
|
126
128
|
export default Table;
|