@dnanpm/styleguide 1.9.0 → 2.0.0
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/build/cjs/components/Accordion/Accordion.d.ts +27 -15
- package/build/cjs/components/Accordion/Accordion.js +29 -12
- package/build/cjs/components/Accordion/AccordionItem.d.ts +14 -29
- package/build/cjs/components/Accordion/AccordionItem.js +29 -52
- package/build/cjs/components/AmountSelector/AmountSelector.js +3 -4
- package/build/cjs/components/Buttons/ButtonBasicStyles.d.ts +37 -30
- package/build/cjs/components/Buttons/ButtonBasicStyles.js +10 -14
- package/build/cjs/components/Buttons/ButtonDefault.js +6 -2
- package/build/cjs/components/Buttons/ButtonIconPrimaryStyles.d.ts +37 -30
- package/build/cjs/components/Buttons/ButtonIconStyles.d.ts +37 -30
- package/build/cjs/components/Buttons/ButtonPrimary.js +6 -2
- package/build/cjs/components/Buttons/ButtonPrimaryStyles.d.ts +37 -30
- package/build/cjs/components/Buttons/ButtonSecondary.js +7 -3
- package/build/cjs/components/Buttons/ButtonSecondaryStyles.d.ts +37 -30
- package/build/cjs/components/Buttons/ButtonTertiary.js +7 -3
- package/build/cjs/components/Buttons/ButtonTertiaryStyles.d.ts +37 -30
- package/build/cjs/components/Buttons/CloseButton.d.ts +37 -30
- package/build/cjs/components/Card/Card.js +4 -2
- package/build/cjs/components/Card/CardRow.js +3 -3
- package/build/cjs/components/Checkbox/Checkbox.d.ts +38 -12
- package/build/cjs/components/Checkbox/Checkbox.js +37 -70
- package/build/cjs/components/DnaLogo/DnaLogo.d.ts +37 -40
- package/build/cjs/components/Footer/Components/FooterComponents.js +3 -2
- package/build/cjs/components/Helper/Helper.js +2 -1
- package/build/cjs/components/Icon/Icon.d.ts +39 -30
- package/build/cjs/components/Icon/Icons.d.ts +1 -4
- package/build/cjs/components/Icon/Icons.js +3 -7
- package/build/cjs/components/Input/Input.d.ts +102 -13
- package/build/cjs/components/Input/Input.js +57 -58
- package/build/cjs/components/Label/Label.js +2 -3
- package/build/cjs/components/LabelText/LabelText.d.ts +38 -30
- package/build/cjs/components/LabelText/LabelText.js +1 -1
- package/build/cjs/components/MainNavigation/ChildComponents/BusinessMenu.js +1 -1
- package/build/cjs/components/MainNavigation/ChildComponents/DesktopMenu.js +10 -4
- package/build/cjs/components/MainNavigation/ChildComponents/HeaderNavigationElements.d.ts +37 -30
- package/build/cjs/components/MainNavigation/ChildComponents/LanguageSelector.js +2 -2
- package/build/cjs/components/MainNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.d.ts +37 -30
- package/build/cjs/components/MainNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.js +1 -4
- package/build/cjs/components/MainNavigation/ChildComponents/MobileMenu.js +1 -1
- package/build/cjs/components/MainNavigation/ChildComponents/Ribbon.js +1 -1
- package/build/cjs/components/MainNavigation/MainNavigation.js +1 -1
- package/build/cjs/components/MainNavigation/globalNavStyles.d.ts +148 -120
- package/build/cjs/components/Notification/Notification.d.ts +1 -5
- package/build/cjs/components/Notification/Notification.js +1 -4
- package/build/cjs/components/NotificationBadge/NotificationBadge.d.ts +37 -30
- package/build/cjs/components/NotificationBadge/NotificationBadge.js +1 -1
- package/build/cjs/components/PixelLoader/PixelLoaderStyles.d.ts +74 -60
- package/build/cjs/components/ProgressIndicator/ProgressIndicator.js +3 -3
- package/build/cjs/components/RadioButton/RadioButton.d.ts +33 -17
- package/build/cjs/components/RadioButton/RadioButton.js +12 -57
- package/build/cjs/components/ReadMore/ReadMore.js +2 -7
- package/build/cjs/components/Ribbon/Ribbon.js +2 -2
- package/build/cjs/components/Search/Search.js +2 -1
- package/build/cjs/components/SecondaryNavigation/SecondaryNavigation.js +2 -2
- package/build/cjs/components/Selectbox/Selectbox.d.ts +102 -13
- package/build/cjs/components/Selectbox/Selectbox.js +40 -49
- package/build/cjs/components/Tabs/Tab.d.ts +37 -30
- package/build/cjs/components/Tabs/Tab.js +3 -2
- package/build/cjs/components/Tabs/Tabs.d.ts +40 -30
- package/build/cjs/components/Textarea/Textarea.js +4 -3
- package/build/cjs/components/Tooltip/Tooltip.d.ts +37 -30
- package/build/cjs/components/TooltipMenu/ChildComponents/TooltipMenuExportedStyles.d.ts +74 -60
- package/build/cjs/components/index.d.ts +3 -2
- package/build/cjs/index.js +2 -2
- package/build/cjs/themes/globalStyles.d.ts +174 -60
- package/build/cjs/themes/globalStyles.js +132 -142
- package/build/cjs/themes/styled.d.ts +259 -210
- package/build/cjs/themes/theme.d.ts +37 -30
- package/build/cjs/themes/themeComponents/buttons.d.ts +1 -6
- package/build/cjs/themes/themeComponents/buttons.js +1 -6
- package/build/cjs/themes/themeComponents/fontFamily.d.ts +3 -1
- package/build/cjs/themes/themeComponents/fontFamily.js +3 -1
- package/build/cjs/themes/themeComponents/fontSize.d.ts +18 -15
- package/build/cjs/themes/themeComponents/fontSize.js +20 -14
- package/build/cjs/themes/themeComponents/lineHeight.d.ts +19 -12
- package/build/cjs/themes/themeComponents/lineHeight.js +21 -11
- package/build/es/components/Accordion/Accordion.d.ts +27 -15
- package/build/es/components/Accordion/Accordion.js +29 -12
- package/build/es/components/Accordion/AccordionItem.d.ts +14 -29
- package/build/es/components/Accordion/AccordionItem.js +31 -54
- package/build/es/components/AmountSelector/AmountSelector.js +3 -4
- package/build/es/components/Buttons/ButtonBasicStyles.d.ts +37 -30
- package/build/es/components/Buttons/ButtonBasicStyles.js +10 -14
- package/build/es/components/Buttons/ButtonDefault.js +6 -2
- package/build/es/components/Buttons/ButtonIconPrimaryStyles.d.ts +37 -30
- package/build/es/components/Buttons/ButtonIconStyles.d.ts +37 -30
- package/build/es/components/Buttons/ButtonPrimary.js +6 -2
- package/build/es/components/Buttons/ButtonPrimaryStyles.d.ts +37 -30
- package/build/es/components/Buttons/ButtonSecondary.js +7 -3
- package/build/es/components/Buttons/ButtonSecondaryStyles.d.ts +37 -30
- package/build/es/components/Buttons/ButtonTertiary.js +7 -3
- package/build/es/components/Buttons/ButtonTertiaryStyles.d.ts +37 -30
- package/build/es/components/Buttons/CloseButton.d.ts +37 -30
- package/build/es/components/Card/Card.js +4 -2
- package/build/es/components/Card/CardRow.js +3 -3
- package/build/es/components/Checkbox/Checkbox.d.ts +38 -12
- package/build/es/components/Checkbox/Checkbox.js +39 -72
- package/build/es/components/DnaLogo/DnaLogo.d.ts +37 -40
- package/build/es/components/Footer/Components/FooterComponents.js +3 -2
- package/build/es/components/Helper/Helper.js +2 -1
- package/build/es/components/Icon/Icon.d.ts +39 -30
- package/build/es/components/Icon/Icons.d.ts +1 -4
- package/build/es/components/Icon/Icons.js +3 -7
- package/build/es/components/Input/Input.d.ts +102 -13
- package/build/es/components/Input/Input.js +57 -58
- package/build/es/components/Label/Label.js +2 -3
- package/build/es/components/LabelText/LabelText.d.ts +38 -30
- package/build/es/components/LabelText/LabelText.js +1 -1
- package/build/es/components/MainNavigation/ChildComponents/BusinessMenu.js +1 -1
- package/build/es/components/MainNavigation/ChildComponents/DesktopMenu.js +10 -4
- package/build/es/components/MainNavigation/ChildComponents/HeaderNavigationElements.d.ts +37 -30
- package/build/es/components/MainNavigation/ChildComponents/LanguageSelector.js +2 -2
- package/build/es/components/MainNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.d.ts +37 -30
- package/build/es/components/MainNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.js +2 -5
- package/build/es/components/MainNavigation/ChildComponents/MobileMenu.js +1 -1
- package/build/es/components/MainNavigation/ChildComponents/Ribbon.js +1 -1
- package/build/es/components/MainNavigation/MainNavigation.js +1 -1
- package/build/es/components/MainNavigation/globalNavStyles.d.ts +148 -120
- package/build/es/components/Notification/Notification.d.ts +1 -5
- package/build/es/components/Notification/Notification.js +1 -4
- package/build/es/components/NotificationBadge/NotificationBadge.d.ts +37 -30
- package/build/es/components/NotificationBadge/NotificationBadge.js +1 -1
- package/build/es/components/PixelLoader/PixelLoaderStyles.d.ts +74 -60
- package/build/es/components/ProgressIndicator/ProgressIndicator.js +3 -3
- package/build/es/components/RadioButton/RadioButton.d.ts +33 -17
- package/build/es/components/RadioButton/RadioButton.js +12 -57
- package/build/es/components/ReadMore/ReadMore.js +2 -7
- package/build/es/components/Ribbon/Ribbon.js +2 -2
- package/build/es/components/Search/Search.js +2 -1
- package/build/es/components/SecondaryNavigation/SecondaryNavigation.js +2 -2
- package/build/es/components/Selectbox/Selectbox.d.ts +102 -13
- package/build/es/components/Selectbox/Selectbox.js +40 -49
- package/build/es/components/Tabs/Tab.d.ts +37 -30
- package/build/es/components/Tabs/Tab.js +3 -2
- package/build/es/components/Tabs/Tabs.d.ts +40 -30
- package/build/es/components/Textarea/Textarea.js +4 -3
- package/build/es/components/Tooltip/Tooltip.d.ts +37 -30
- package/build/es/components/TooltipMenu/ChildComponents/TooltipMenuExportedStyles.d.ts +74 -60
- package/build/es/components/index.d.ts +3 -2
- package/build/es/index.js +1 -1
- package/build/es/themes/globalStyles.d.ts +174 -60
- package/build/es/themes/globalStyles.js +134 -145
- package/build/es/themes/styled.d.ts +259 -210
- package/build/es/themes/theme.d.ts +37 -30
- package/build/es/themes/themeComponents/buttons.d.ts +1 -6
- package/build/es/themes/themeComponents/buttons.js +1 -6
- package/build/es/themes/themeComponents/fontFamily.d.ts +3 -1
- package/build/es/themes/themeComponents/fontFamily.js +3 -1
- package/build/es/themes/themeComponents/fontSize.d.ts +18 -15
- package/build/es/themes/themeComponents/fontSize.js +20 -14
- package/build/es/themes/themeComponents/lineHeight.d.ts +19 -12
- package/build/es/themes/themeComponents/lineHeight.js +21 -11
- package/package.json +2 -2
- package/build/cjs/components/Accordion/index.d.ts +0 -2
- package/build/es/components/Accordion/index.d.ts +0 -2
|
@@ -11,12 +11,7 @@ declare const theme: {
|
|
|
11
11
|
};
|
|
12
12
|
breakpoints: import("./themeComponents/breakpoints").ViewBreakpoints;
|
|
13
13
|
button: {
|
|
14
|
-
|
|
15
|
-
buttonPadding: string;
|
|
16
|
-
smallButtonPadding: string;
|
|
17
|
-
buttonLineHeight: string;
|
|
18
|
-
buttonWidth: string;
|
|
19
|
-
buttonSmallWidth: string;
|
|
14
|
+
border: string;
|
|
20
15
|
};
|
|
21
16
|
color: {
|
|
22
17
|
black: string;
|
|
@@ -47,22 +42,27 @@ declare const theme: {
|
|
|
47
42
|
gray5: string;
|
|
48
43
|
};
|
|
49
44
|
fontFamily: {
|
|
50
|
-
|
|
45
|
+
default: string;
|
|
46
|
+
heading: string;
|
|
47
|
+
numerals: string;
|
|
51
48
|
};
|
|
52
49
|
fontSize: {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
50
|
+
default: string;
|
|
51
|
+
xl: string;
|
|
52
|
+
l: string;
|
|
53
|
+
s: string;
|
|
54
|
+
xs: string;
|
|
55
|
+
h1XL: string;
|
|
56
|
+
h1L: string;
|
|
57
|
+
h1M: string;
|
|
58
|
+
h1S: string;
|
|
59
|
+
h2M: string;
|
|
60
|
+
h2S: string;
|
|
61
|
+
h3: string;
|
|
62
|
+
h4: string;
|
|
63
|
+
h5: string;
|
|
64
|
+
h1: string;
|
|
65
|
+
h2: string;
|
|
66
66
|
};
|
|
67
67
|
fontWeight: {
|
|
68
68
|
book: number;
|
|
@@ -78,16 +78,23 @@ declare const theme: {
|
|
|
78
78
|
gutter: string;
|
|
79
79
|
};
|
|
80
80
|
lineHeight: {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
81
|
+
default: string;
|
|
82
|
+
xl: string;
|
|
83
|
+
s: string;
|
|
84
|
+
xs: string;
|
|
85
|
+
xxs: string;
|
|
86
|
+
auto: string;
|
|
87
|
+
h1XL: string;
|
|
88
|
+
h1L: string;
|
|
89
|
+
h1M: string;
|
|
90
|
+
h1S: string;
|
|
91
|
+
h2M: string;
|
|
92
|
+
h2S: string;
|
|
93
|
+
h3: string;
|
|
94
|
+
h4: string;
|
|
95
|
+
h5: string;
|
|
96
|
+
h1: string;
|
|
97
|
+
h2: string;
|
|
91
98
|
};
|
|
92
99
|
media: Record<string | number, (l: TemplateStringsArray, ...p: any[]) => string>;
|
|
93
100
|
};
|
|
@@ -3,12 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const buttons = {
|
|
6
|
-
|
|
7
|
-
buttonPadding: '0.68rem 0.625rem',
|
|
8
|
-
smallButtonPadding: '0.375rem 1.25rem',
|
|
9
|
-
buttonLineHeight: '1.125',
|
|
10
|
-
buttonWidth: '7.8125rem',
|
|
11
|
-
buttonSmallWidth: '6.5625rem',
|
|
6
|
+
border: '1px',
|
|
12
7
|
};
|
|
13
8
|
|
|
14
9
|
exports.default = buttons;
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const fontFamily = {
|
|
6
|
-
|
|
6
|
+
default: `"DNA Text", "Helvetica Neue", Helvetica, Arial, sans-serif`,
|
|
7
|
+
heading: `"DNA Heading", "Helvetica Neue", Helvetica, Arial, sans-serif`,
|
|
8
|
+
numerals: `"DNA Numerals", "DNA Text", "Helvetica Neue", Helvetica, Arial, sans-serif`,
|
|
7
9
|
};
|
|
8
10
|
|
|
9
11
|
exports.default = fontFamily;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
declare const _default: {
|
|
2
|
+
default: string;
|
|
3
|
+
xl: string;
|
|
4
|
+
l: string;
|
|
5
|
+
s: string;
|
|
6
|
+
xs: string;
|
|
7
|
+
h1XL: string;
|
|
8
|
+
h1L: string;
|
|
9
|
+
h1M: string;
|
|
10
|
+
h1S: string;
|
|
11
|
+
h2M: string;
|
|
12
|
+
h2S: string;
|
|
13
|
+
h3: string;
|
|
14
|
+
h4: string;
|
|
15
|
+
h5: string;
|
|
16
|
+
h1: string;
|
|
17
|
+
h2: string;
|
|
15
18
|
};
|
|
16
|
-
export default
|
|
19
|
+
export default _default;
|
|
@@ -3,19 +3,25 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const fontSize = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
default: '1rem',
|
|
7
|
+
xl: '1.25rem',
|
|
8
|
+
l: '1.125rem',
|
|
9
|
+
s: '0.875rem',
|
|
10
|
+
xs: '0.75rem',
|
|
11
|
+
h1XL: '2.875rem',
|
|
12
|
+
h1L: '2.5rem',
|
|
13
|
+
h1M: '2.125rem',
|
|
14
|
+
h1S: '1.875rem',
|
|
15
|
+
h2M: '1.875rem',
|
|
16
|
+
h2S: '1.625rem',
|
|
17
|
+
h3: '1.5rem',
|
|
18
|
+
h4: '1.25rem',
|
|
19
|
+
h5: '1rem',
|
|
20
|
+
};
|
|
21
|
+
var fontSize$1 = {
|
|
22
|
+
h1: fontSize.h1L,
|
|
23
|
+
h2: fontSize.h2M,
|
|
24
|
+
...fontSize,
|
|
19
25
|
};
|
|
20
26
|
|
|
21
|
-
exports.default = fontSize;
|
|
27
|
+
exports.default = fontSize$1;
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
declare const _default: {
|
|
2
|
+
default: string;
|
|
3
|
+
xl: string;
|
|
4
|
+
s: string;
|
|
5
|
+
xs: string;
|
|
6
|
+
xxs: string;
|
|
7
|
+
auto: string;
|
|
8
|
+
h1XL: string;
|
|
9
|
+
h1L: string;
|
|
10
|
+
h1M: string;
|
|
11
|
+
h1S: string;
|
|
12
|
+
h2M: string;
|
|
13
|
+
h2S: string;
|
|
14
|
+
h3: string;
|
|
15
|
+
h4: string;
|
|
16
|
+
h5: string;
|
|
17
|
+
h1: string;
|
|
18
|
+
h2: string;
|
|
12
19
|
};
|
|
13
|
-
export default
|
|
20
|
+
export default _default;
|
|
@@ -3,16 +3,26 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const lineHeight = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
default: '1.5rem',
|
|
7
|
+
xl: '1.625rem',
|
|
8
|
+
s: '1.125rem',
|
|
9
|
+
xs: '1rem',
|
|
10
|
+
xxs: '0.875rem',
|
|
11
|
+
auto: 'inherit',
|
|
12
|
+
h1XL: '3rem',
|
|
13
|
+
h1L: '2.875rem',
|
|
14
|
+
h1M: '2.5rem',
|
|
15
|
+
h1S: '2.25rem',
|
|
16
|
+
h2M: '2.25rem',
|
|
17
|
+
h2S: '2rem',
|
|
18
|
+
h3: '1.875rem',
|
|
19
|
+
h4: '1.5rem',
|
|
20
|
+
h5: '1rem',
|
|
21
|
+
};
|
|
22
|
+
var lineHeight$1 = {
|
|
23
|
+
h1: lineHeight.h1L,
|
|
24
|
+
h2: lineHeight.h2M,
|
|
25
|
+
...lineHeight,
|
|
16
26
|
};
|
|
17
27
|
|
|
18
|
-
exports.default = lineHeight;
|
|
28
|
+
exports.default = lineHeight$1;
|
|
@@ -1,38 +1,50 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
interface
|
|
2
|
+
export interface Props {
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
className?: string;
|
|
7
|
-
/**
|
|
8
|
-
* The actual content
|
|
4
|
+
* Content of Accordion
|
|
5
|
+
*
|
|
9
6
|
* @type AccordionItem
|
|
10
7
|
*/
|
|
11
8
|
children: React.ReactNode;
|
|
12
|
-
/** Allow multiple accordion items to be open
|
|
13
|
-
* @default true
|
|
14
|
-
*/
|
|
15
|
-
allowMultiOpen?: boolean;
|
|
16
9
|
/**
|
|
17
|
-
*
|
|
10
|
+
* Allows only one AccordionItem to be opened when set to true
|
|
11
|
+
*
|
|
18
12
|
* @default false
|
|
19
13
|
*/
|
|
20
|
-
|
|
14
|
+
autoCollapsible?: boolean;
|
|
21
15
|
/**
|
|
22
|
-
*
|
|
16
|
+
* Allows to remove item title highlight when it is in expanded state
|
|
17
|
+
* Removes also highlight of CSS :hover and :active states
|
|
18
|
+
*
|
|
23
19
|
* @default true
|
|
24
20
|
*/
|
|
25
21
|
highlightSelected?: boolean;
|
|
26
22
|
/**
|
|
27
|
-
*
|
|
23
|
+
* Allows to expand or collapse the component
|
|
24
|
+
*
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
isExpanded?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Display close button in the item content
|
|
30
|
+
*
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
hasCloseButton?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Label to show for the open icon for accessibility
|
|
28
36
|
*/
|
|
29
37
|
openLabel?: string;
|
|
30
38
|
/**
|
|
31
39
|
* Label to show for the close button in the content
|
|
32
40
|
*/
|
|
33
41
|
closeLabel?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Allows to pass a custom className
|
|
44
|
+
*/
|
|
45
|
+
className?: string;
|
|
34
46
|
}
|
|
35
47
|
/** @visibleName Accordion */
|
|
36
|
-
declare const Accordion: ({
|
|
48
|
+
declare const Accordion: ({ autoCollapsible, highlightSelected, hasCloseButton, ...props }: Props) => JSX.Element;
|
|
37
49
|
/** @component */
|
|
38
50
|
export default Accordion;
|
|
@@ -2,26 +2,43 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import AccordionItem from './AccordionItem.js';
|
|
3
3
|
|
|
4
4
|
/** @visibleName Accordion */
|
|
5
|
-
const Accordion = ({
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const Accordion = ({ autoCollapsible = false, highlightSelected = true, hasCloseButton = false, ...props }) => {
|
|
6
|
+
const initialItemList = {};
|
|
7
|
+
const getAccordionItemId = (index, title) => `${title.replace(/\s+/g, '')}-${index}`;
|
|
8
|
+
if (props.isExpanded) {
|
|
9
|
+
React.Children.map(props.children, (child, index) => {
|
|
10
|
+
if (React.isValidElement(child) && child.type === AccordionItem) {
|
|
11
|
+
initialItemList[getAccordionItemId(index, child.props.title)] = Boolean(props.isExpanded);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
const [itemList, setItemList] = useState(initialItemList);
|
|
16
|
+
const toggleExpanded = (currentItemId) => {
|
|
17
|
+
const currentItemState = itemList[currentItemId];
|
|
18
|
+
setItemList({
|
|
19
|
+
...(autoCollapsible ? {} : itemList),
|
|
20
|
+
[currentItemId]: !currentItemState,
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
const handleClick = (e) => {
|
|
24
|
+
toggleExpanded(e.currentTarget.parentElement.id);
|
|
25
|
+
};
|
|
26
|
+
const handleKeyDown = (e) => {
|
|
27
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
toggleExpanded(e.currentTarget.parentElement.id);
|
|
10
30
|
}
|
|
11
|
-
setActiveItem(index);
|
|
12
31
|
};
|
|
13
|
-
|
|
14
|
-
const accordionItems = React.Children.map(children, (child, index) => {
|
|
32
|
+
const accordionItems = React.Children.map(props.children, (child, index) => {
|
|
15
33
|
if (React.isValidElement(child) && child.type === AccordionItem) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
onOpen: () => handleItemOpen(index) }, child.props), child.props.children));
|
|
34
|
+
const id = getAccordionItemId(index, child.props.title);
|
|
35
|
+
return (React.createElement(AccordionItem, Object.assign({ id: id, key: id, title: child.props.title, isExpanded: itemList[id], hasCloseButton: hasCloseButton, highlightSelected: highlightSelected, openLabel: props.openLabel, closeLabel: props.closeLabel, onClick: handleClick, onKeyDown: handleKeyDown }, child.props), child.props.children));
|
|
19
36
|
}
|
|
20
37
|
});
|
|
21
38
|
if (!accordionItems) {
|
|
22
39
|
return React.createElement(React.Fragment, null);
|
|
23
40
|
}
|
|
24
|
-
return React.createElement("div", { className: className }, accordionItems);
|
|
41
|
+
return React.createElement("div", { className: props.className }, accordionItems);
|
|
25
42
|
};
|
|
26
43
|
|
|
27
44
|
export default Accordion;
|
|
@@ -1,45 +1,30 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Allows to pass a custom className
|
|
5
|
-
*/
|
|
6
|
-
className?: string;
|
|
7
|
-
/**
|
|
8
|
-
* The actual content
|
|
9
|
-
*/
|
|
10
|
-
children?: React.ReactNode;
|
|
2
|
+
import { Props as AccordionProps } from './Accordion';
|
|
3
|
+
interface Props extends Omit<AccordionProps, 'children' | 'autoCollapsible'> {
|
|
11
4
|
/**
|
|
12
5
|
* Accordion item title
|
|
13
6
|
*/
|
|
14
7
|
title: string;
|
|
15
8
|
/**
|
|
16
|
-
*
|
|
17
|
-
* @default false
|
|
9
|
+
* Unique ID for the component
|
|
18
10
|
*/
|
|
19
|
-
|
|
11
|
+
id?: string;
|
|
20
12
|
/**
|
|
21
|
-
*
|
|
22
|
-
* @default true
|
|
13
|
+
* Content of Accordion Item
|
|
23
14
|
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Label to show for the open icon for accessibility
|
|
27
|
-
*/
|
|
28
|
-
openLabel?: string;
|
|
29
|
-
/**
|
|
30
|
-
* Label to show for the close button in the content
|
|
31
|
-
*/
|
|
32
|
-
closeLabel?: string;
|
|
15
|
+
children?: React.ReactNode;
|
|
33
16
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
17
|
+
* On component title and close button mouse click callback
|
|
18
|
+
* Use `e.currentTarget.parentElement` to get AccordionItem element
|
|
36
19
|
*/
|
|
37
|
-
|
|
20
|
+
onClick?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
38
21
|
/**
|
|
39
|
-
*
|
|
22
|
+
* On component title and close button keyboard key down callback
|
|
23
|
+
* Use `e.currentTarget.parentElement` to get AccordionItem element
|
|
40
24
|
*/
|
|
41
|
-
|
|
25
|
+
onKeyDown?: (e: React.KeyboardEvent<HTMLElement>) => void;
|
|
42
26
|
}
|
|
43
|
-
|
|
27
|
+
/** @visibleName Accordion Item */
|
|
28
|
+
declare const AccordionItem: ({ hasCloseButton, highlightSelected, ...props }: Props) => JSX.Element;
|
|
44
29
|
/** @component */
|
|
45
30
|
export default AccordionItem;
|
|
@@ -1,91 +1,68 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import styled__default, { css } from 'styled-components';
|
|
3
3
|
import useResizeObserver from '../../hooks/useElementDimensions.js';
|
|
4
|
-
import {
|
|
4
|
+
import { getDividedSize, getMultipliedSize } from '../../utils/styledUtils.js';
|
|
5
5
|
import Icon from '../Icon/Icon.js';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const AccordionItemContainer = styled__default.div `
|
|
8
|
+
margin: ${p => `0 ${getDividedSize(p.theme.base.baseHeight, 2.5)}}`};
|
|
9
|
+
border-bottom: 1px solid
|
|
10
|
+
${p => (p.isExpanded && p.highlightSelected ? p.theme.color.hotPink : p.theme.color.gray15)};
|
|
11
|
+
`;
|
|
8
12
|
const AccordionItemTitle = styled__default.div `
|
|
9
|
-
font-size: ${p => p.theme.fontSize.
|
|
13
|
+
font-size: ${p => p.theme.fontSize.default};
|
|
10
14
|
font-weight: ${p => p.theme.fontWeight.bold};
|
|
11
15
|
display: flex;
|
|
12
16
|
justify-content: space-between;
|
|
13
17
|
flex-direction: row;
|
|
14
18
|
cursor: pointer;
|
|
19
|
+
padding: ${p => getMultipliedSize(p.theme.base.baseHeight, 1.6)}
|
|
20
|
+
${p => getMultipliedSize(p.theme.base.baseHeight, 2)};
|
|
15
21
|
color: ${p => p.isExpanded && p.highlightSelected ? p.theme.color.hotPink : p.theme.color.text};
|
|
16
|
-
padding: ${p => `${getMultipliedSize(p.theme.base.baseHeight, 1.6)} ${getMultipliedSize(p.theme.base.baseHeight, 2)}`};
|
|
17
22
|
transition: color 0.2s;
|
|
18
23
|
${p => p.highlightSelected &&
|
|
19
24
|
css `
|
|
20
25
|
&:hover,
|
|
21
|
-
&:active
|
|
22
|
-
&:focus {
|
|
26
|
+
&:active {
|
|
23
27
|
color: ${p.theme.color.hotPink};
|
|
24
28
|
text-decoration: none;
|
|
25
29
|
}
|
|
26
30
|
`}
|
|
27
31
|
`;
|
|
28
|
-
const
|
|
29
|
-
margin: ${p => `0 ${getDividedSize(p.theme.base.baseHeight, 2.5)}}`};
|
|
30
|
-
border-bottom: 1px solid
|
|
31
|
-
${p => (p.isExpanded && p.highlightSelected ? p.theme.color.hotPink : p.theme.color.gray15)};
|
|
32
|
-
`;
|
|
33
|
-
const AccordionItemContent = styled__default.div `
|
|
32
|
+
const AccordionItemContentWrapper = styled__default.div `
|
|
34
33
|
overflow: hidden;
|
|
35
34
|
color: ${p => p.theme.color.slateGray};
|
|
36
35
|
transition: all 0.2s ease;
|
|
37
36
|
height: ${p => (p.isExpanded ? p.maxHeight / 16 + 1.25 : 0)}rem;
|
|
37
|
+
padding: 0 ${p => getMultipliedSize(p.theme.base.baseHeight, 2)};
|
|
38
38
|
visibility: ${p => (p.isExpanded ? 'visible' : 'hidden')};
|
|
39
39
|
`;
|
|
40
|
-
const
|
|
41
|
-
padding: ${p =>
|
|
40
|
+
const AccordionItemContent = styled__default.div `
|
|
41
|
+
padding-bottom: ${p => getMultipliedSize(p.theme.base.baseHeight, 1.6)};
|
|
42
42
|
`;
|
|
43
|
-
const
|
|
43
|
+
const AccordionItemCloseButton = styled__default.div `
|
|
44
44
|
display: flex;
|
|
45
|
-
flex: 1;
|
|
46
45
|
justify-content: flex-end;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
line-height: ${p => p.theme.lineHeight.default};
|
|
47
|
+
margin-bottom: ${p => getMultipliedSize(p.theme.base.baseHeight, 1.6)};
|
|
48
|
+
padding: 0 ${p => getMultipliedSize(p.theme.base.baseHeight, 2)};
|
|
50
49
|
gap: ${p => getMultipliedSize(p.theme.base.baseHeight, 1)};
|
|
51
50
|
color: ${p => p.theme.color.text};
|
|
52
51
|
cursor: pointer;
|
|
53
52
|
`;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
setExpanded(!isExpanded);
|
|
58
|
-
};
|
|
59
|
-
// get height when element dimensions change
|
|
53
|
+
/** @visibleName Accordion Item */
|
|
54
|
+
const AccordionItem = ({ hasCloseButton = false, highlightSelected = true, ...props }) => {
|
|
55
|
+
// Get height when element dimensions change
|
|
60
56
|
const { height: contentHeight, ref: contentRef } = useResizeObserver();
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}, [isExpanded]);
|
|
71
|
-
const handleKeyDown = (e) => {
|
|
72
|
-
const key = e.key;
|
|
73
|
-
if (key === 'Enter' || key === ' ') {
|
|
74
|
-
e.preventDefault();
|
|
75
|
-
setExpanded(!isExpanded);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
return (React.createElement(AccordionItemContainer, { "aria-expanded": isExpanded, className: props.className, isExpanded: isExpanded, highlightSelected: highlightSelected },
|
|
79
|
-
React.createElement(AccordionItemTitle, { tabIndex: 0, onKeyDown: handleKeyDown, isExpanded: isExpanded, highlightSelected: highlightSelected, onClick: toggleExpanded, role: "button" },
|
|
80
|
-
React.createElement("span", null, title),
|
|
81
|
-
isExpanded ? (React.createElement(Icon, { name: "hlChevronUp", size: "1.5rem", right: true, "aria-label": closeLabel })) : (React.createElement(Icon, { name: "hlChevronDown", size: "1.5rem", right: true, "aria-label": openLabel }))),
|
|
82
|
-
React.createElement(AccordionItemContent, { maxHeight: contentHeight, isExpanded: isExpanded },
|
|
83
|
-
React.createElement(AccordionItemContentInner, { ref: contentRef },
|
|
84
|
-
children,
|
|
85
|
-
hasCloseButton && (React.createElement(CloseAccordionItemWrapper, null,
|
|
86
|
-
React.createElement(CloseAccordionItem, { onClick: toggleExpanded, "aria-label": closeLabel, tabIndex: 0, onKeyDown: handleKeyDown, role: "button" },
|
|
87
|
-
React.createElement("span", null, closeLabel),
|
|
88
|
-
React.createElement(Icon, { name: "hlX", size: "1.5rem" }))))))));
|
|
57
|
+
return (React.createElement(AccordionItemContainer, { id: props.id, "aria-expanded": Boolean(props.isExpanded), className: props.className, isExpanded: Boolean(props.isExpanded), highlightSelected: highlightSelected },
|
|
58
|
+
React.createElement(AccordionItemTitle, { tabIndex: 0, onClick: props.onClick, onKeyDown: props.onKeyDown, isExpanded: Boolean(props.isExpanded), highlightSelected: highlightSelected, role: "button" },
|
|
59
|
+
props.title,
|
|
60
|
+
Boolean(props.isExpanded) ? (React.createElement(Icon, { name: "hlChevronUp", size: "1.5rem", right: true, "aria-label": props.closeLabel })) : (React.createElement(Icon, { name: "hlChevronDown", size: "1.5rem", right: true, "aria-label": props.openLabel }))),
|
|
61
|
+
React.createElement(AccordionItemContentWrapper, { maxHeight: contentHeight, isExpanded: props.isExpanded },
|
|
62
|
+
React.createElement(AccordionItemContent, { ref: contentRef }, props.children)),
|
|
63
|
+
hasCloseButton && props.isExpanded && (React.createElement(AccordionItemCloseButton, { tabIndex: 0, onClick: props.onClick, onKeyDown: props.onKeyDown, "aria-label": props.closeLabel, role: "button" },
|
|
64
|
+
React.createElement("span", null, props.closeLabel),
|
|
65
|
+
React.createElement(Icon, { name: "hlX", size: "1.5rem" })))));
|
|
89
66
|
};
|
|
90
67
|
|
|
91
68
|
export default AccordionItem;
|
|
@@ -2,11 +2,10 @@ import React from 'react';
|
|
|
2
2
|
import styled from '../../themes/styled.js';
|
|
3
3
|
import theme from '../../themes/theme.js';
|
|
4
4
|
import { getMultipliedSize } from '../../utils/styledUtils.js';
|
|
5
|
-
import '../Buttons/
|
|
6
|
-
import '../
|
|
7
|
-
import '../Buttons/ButtonPrimaryStyles.js';
|
|
5
|
+
import '../Buttons/ButtonDefault.js';
|
|
6
|
+
import '../Buttons/ButtonPrimary.js';
|
|
8
7
|
import ButtonSecondary from '../Buttons/ButtonSecondary.js';
|
|
9
|
-
import '../Buttons/
|
|
8
|
+
import '../Buttons/ButtonTertiary.js';
|
|
10
9
|
import '../Buttons/ButtonRoundStyles.js';
|
|
11
10
|
import '../Buttons/CloseButton.js';
|
|
12
11
|
import '../Buttons/ButtonIconStyles.js';
|