@dxc-technology/halstack-react 0.0.0-de7c6b0 → 0.0.0-dec566a
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/BackgroundColorContext.d.ts +1 -10
- package/BackgroundColorContext.js +4 -21
- package/HalstackContext.d.ts +52 -139
- package/HalstackContext.js +11 -36
- package/README.md +47 -0
- package/accordion/Accordion.js +31 -84
- package/accordion/Accordion.stories.tsx +5 -50
- package/accordion/Accordion.test.js +18 -33
- package/accordion/types.d.ts +6 -6
- package/accordion-group/AccordionGroup.d.ts +2 -3
- package/accordion-group/AccordionGroup.js +17 -44
- package/accordion-group/AccordionGroup.stories.tsx +1 -1
- package/accordion-group/AccordionGroup.test.js +42 -60
- package/accordion-group/AccordionGroupAccordion.js +11 -23
- package/accordion-group/AccordionGroupContext.d.ts +3 -0
- package/accordion-group/AccordionGroupContext.js +8 -0
- package/accordion-group/types.d.ts +7 -7
- package/action-icon/ActionIcon.d.ts +4 -0
- package/action-icon/ActionIcon.js +48 -0
- package/action-icon/ActionIcon.stories.tsx +41 -0
- package/action-icon/ActionIcon.test.js +64 -0
- package/action-icon/types.d.ts +26 -0
- package/alert/Alert.js +29 -118
- package/alert/Alert.test.js +28 -45
- package/alert/types.d.ts +5 -5
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +141 -43
- package/badge/Badge.stories.tsx +210 -0
- package/badge/Badge.test.js +30 -0
- package/badge/types.d.ts +52 -3
- package/bleed/Bleed.js +13 -21
- package/bleed/types.d.ts +2 -2
- package/box/Box.js +11 -33
- package/box/Box.test.js +1 -6
- package/box/types.d.ts +3 -3
- package/bulleted-list/BulletedList.js +22 -55
- package/bulleted-list/BulletedList.stories.tsx +2 -93
- package/bulleted-list/types.d.ts +5 -5
- package/button/Button.d.ts +1 -1
- package/button/Button.js +68 -100
- package/button/Button.stories.tsx +33 -132
- package/button/Button.test.js +19 -16
- package/button/types.d.ts +9 -5
- package/card/Card.js +21 -44
- package/card/Card.test.js +10 -21
- package/card/types.d.ts +5 -5
- package/checkbox/Checkbox.js +85 -120
- package/checkbox/Checkbox.stories.tsx +16 -54
- package/checkbox/Checkbox.test.js +107 -63
- package/checkbox/types.d.ts +8 -4
- package/chip/Chip.js +12 -31
- package/chip/Chip.stories.tsx +1 -1
- package/chip/Chip.test.js +15 -28
- package/chip/types.d.ts +4 -4
- package/common/coreTokens.d.ts +105 -14
- package/common/coreTokens.js +41 -24
- package/common/utils.js +2 -8
- package/common/variables.d.ts +52 -139
- package/common/variables.js +63 -157
- package/container/Container.d.ts +4 -0
- package/container/Container.js +194 -0
- package/container/Container.stories.tsx +214 -0
- package/container/types.d.ts +74 -0
- package/contextual-menu/ContextualMenu.d.ts +7 -0
- package/contextual-menu/ContextualMenu.js +71 -0
- package/contextual-menu/ContextualMenu.stories.tsx +182 -0
- package/contextual-menu/ContextualMenu.test.js +71 -0
- package/contextual-menu/MenuItemAction.d.ts +4 -0
- package/contextual-menu/MenuItemAction.js +46 -0
- package/contextual-menu/types.d.ts +22 -0
- package/contextual-menu/types.js +5 -0
- package/date-input/Calendar.js +15 -59
- package/date-input/DateInput.js +50 -96
- package/date-input/DateInput.stories.tsx +11 -30
- package/date-input/DateInput.test.js +674 -701
- package/date-input/DatePicker.js +11 -42
- package/date-input/Icons.d.ts +6 -6
- package/date-input/Icons.js +6 -23
- package/date-input/YearPicker.js +8 -34
- package/date-input/types.d.ts +28 -22
- package/dialog/Dialog.js +13 -40
- package/dialog/Dialog.stories.tsx +170 -0
- package/dialog/Dialog.test.js +125 -187
- package/dialog/types.d.ts +18 -13
- package/divider/Divider.d.ts +4 -0
- package/divider/Divider.js +36 -0
- package/divider/Divider.stories.tsx +223 -0
- package/divider/Divider.test.js +38 -0
- package/divider/types.d.ts +21 -0
- package/divider/types.js +5 -0
- package/dropdown/Dropdown.js +59 -128
- package/dropdown/Dropdown.stories.tsx +5 -16
- package/dropdown/Dropdown.test.js +391 -378
- package/dropdown/DropdownMenu.js +8 -19
- package/dropdown/DropdownMenuItem.js +11 -20
- package/dropdown/types.d.ts +20 -24
- package/file-input/FileInput.js +180 -248
- package/file-input/FileInput.stories.tsx +1 -1
- package/file-input/FileInput.test.js +356 -354
- package/file-input/FileItem.js +14 -41
- package/file-input/types.d.ts +10 -10
- package/flex/Flex.js +25 -39
- package/flex/types.d.ts +6 -6
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +70 -102
- package/footer/Footer.stories.tsx +37 -6
- package/footer/Footer.test.js +21 -33
- package/footer/Icons.d.ts +3 -2
- package/footer/Icons.js +66 -7
- package/footer/types.d.ts +25 -21
- package/grid/Grid.d.ts +1 -1
- package/grid/Grid.js +2 -17
- package/grid/Grid.stories.tsx +38 -38
- package/grid/types.d.ts +10 -10
- package/header/Header.d.ts +1 -1
- package/header/Header.js +28 -84
- package/header/Header.test.js +12 -25
- package/header/Icons.d.ts +2 -2
- package/header/Icons.js +2 -7
- package/header/types.d.ts +7 -8
- package/heading/Heading.js +9 -31
- package/heading/Heading.test.js +70 -87
- package/heading/types.d.ts +7 -7
- package/icon/Icon.d.ts +4 -0
- package/icon/Icon.js +33 -0
- package/icon/Icon.stories.tsx +28 -0
- package/icon/types.d.ts +4 -0
- package/icon/types.js +5 -0
- package/image/Image.d.ts +4 -0
- package/image/Image.js +70 -0
- package/image/Image.stories.tsx +129 -0
- package/image/types.d.ts +72 -0
- package/image/types.js +5 -0
- package/inset/Inset.js +13 -21
- package/inset/types.d.ts +2 -2
- package/layout/ApplicationLayout.d.ts +2 -2
- package/layout/ApplicationLayout.js +29 -66
- package/layout/ApplicationLayout.stories.tsx +1 -1
- package/layout/Icons.d.ts +8 -5
- package/layout/Icons.js +51 -59
- package/layout/types.d.ts +3 -3
- package/link/Link.js +21 -42
- package/link/Link.test.js +23 -41
- package/link/types.d.ts +14 -14
- package/main.d.ts +8 -4
- package/main.js +39 -59
- package/nav-tabs/NavTabs.d.ts +1 -2
- package/nav-tabs/NavTabs.js +19 -48
- package/nav-tabs/NavTabs.stories.tsx +7 -5
- package/nav-tabs/NavTabs.test.js +38 -44
- package/nav-tabs/NavTabsContext.d.ts +3 -0
- package/nav-tabs/NavTabsContext.js +8 -0
- package/nav-tabs/Tab.js +24 -52
- package/nav-tabs/types.d.ts +9 -9
- package/number-input/NumberInput.js +46 -36
- package/number-input/NumberInput.stories.tsx +42 -26
- package/number-input/NumberInput.test.js +859 -412
- package/number-input/NumberInputContext.d.ts +3 -4
- package/number-input/NumberInputContext.js +3 -14
- package/number-input/types.d.ts +17 -5
- package/package.json +30 -28
- package/paginator/Icons.d.ts +5 -5
- package/paginator/Icons.js +5 -19
- package/paginator/Paginator.js +15 -43
- package/paginator/Paginator.test.js +224 -207
- package/paginator/types.d.ts +3 -3
- package/paragraph/Paragraph.js +3 -19
- package/paragraph/Paragraph.stories.tsx +0 -17
- package/password-input/Icons.d.ts +6 -0
- package/password-input/Icons.js +35 -0
- package/password-input/PasswordInput.js +57 -126
- package/password-input/PasswordInput.stories.tsx +1 -33
- package/password-input/PasswordInput.test.js +157 -140
- package/password-input/types.d.ts +8 -7
- package/progress-bar/ProgressBar.js +21 -53
- package/progress-bar/{ProgressBar.stories.jsx → ProgressBar.stories.tsx} +1 -1
- package/progress-bar/ProgressBar.test.js +35 -52
- package/progress-bar/types.d.ts +3 -3
- package/quick-nav/QuickNav.js +4 -27
- package/quick-nav/QuickNav.stories.tsx +1 -1
- package/quick-nav/types.d.ts +10 -10
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +22 -54
- package/radio-group/RadioGroup.js +37 -83
- package/radio-group/RadioGroup.stories.tsx +10 -10
- package/radio-group/RadioGroup.test.js +504 -470
- package/radio-group/types.d.ts +8 -8
- package/resultset-table/Icons.d.ts +7 -0
- package/{resultsetTable → resultset-table}/Icons.js +1 -5
- package/resultset-table/ResultsetTable.d.ts +7 -0
- package/{resultsetTable → resultset-table}/ResultsetTable.js +44 -69
- package/{resultsetTable → resultset-table}/ResultsetTable.stories.tsx +106 -5
- package/{resultsetTable → resultset-table}/ResultsetTable.test.js +148 -92
- package/{resultsetTable → resultset-table}/types.d.ts +44 -11
- package/resultset-table/types.js +5 -0
- package/select/Icons.d.ts +7 -7
- package/select/Icons.js +1 -5
- package/select/Listbox.js +13 -39
- package/select/Option.js +17 -27
- package/select/Select.js +87 -163
- package/select/Select.stories.tsx +3 -3
- package/select/Select.test.js +1946 -1804
- package/select/types.d.ts +14 -15
- package/sidenav/Icons.d.ts +4 -4
- package/sidenav/Icons.js +1 -5
- package/sidenav/Sidenav.js +29 -70
- package/sidenav/Sidenav.test.js +3 -10
- package/{layout → sidenav}/SidenavContext.d.ts +1 -1
- package/{layout → sidenav}/SidenavContext.js +3 -9
- package/sidenav/types.d.ts +18 -18
- package/slider/Slider.js +68 -125
- package/slider/Slider.test.js +107 -103
- package/slider/types.d.ts +4 -4
- package/spinner/Spinner.js +16 -54
- package/spinner/Spinner.test.js +25 -34
- package/spinner/types.d.ts +3 -3
- package/status-light/StatusLight.d.ts +4 -0
- package/status-light/StatusLight.js +51 -0
- package/status-light/StatusLight.stories.tsx +74 -0
- package/status-light/StatusLight.test.js +25 -0
- package/status-light/types.d.ts +17 -0
- package/status-light/types.js +5 -0
- package/switch/Switch.js +49 -97
- package/switch/Switch.stories.tsx +0 -34
- package/switch/Switch.test.js +51 -96
- package/switch/types.d.ts +4 -4
- package/table/DropdownTheme.js +62 -0
- package/table/Table.d.ts +6 -2
- package/table/Table.js +76 -33
- package/table/{Table.stories.jsx → Table.stories.tsx} +297 -2
- package/table/Table.test.js +93 -6
- package/table/types.d.ts +34 -6
- package/tabs/Tab.js +17 -33
- package/tabs/Tabs.js +52 -129
- package/tabs/Tabs.stories.tsx +1 -1
- package/tabs/Tabs.test.js +62 -118
- package/tabs/types.d.ts +19 -19
- package/tag/Tag.js +21 -51
- package/tag/Tag.test.js +19 -30
- package/tag/types.d.ts +7 -7
- package/text-input/Suggestion.js +9 -26
- package/text-input/Suggestions.d.ts +1 -1
- package/text-input/Suggestions.js +19 -67
- package/text-input/TextInput.js +221 -327
- package/text-input/TextInput.stories.tsx +49 -153
- package/text-input/TextInput.test.js +1227 -1194
- package/text-input/types.d.ts +25 -17
- package/textarea/Textarea.js +67 -109
- package/textarea/{Textarea.stories.jsx → Textarea.stories.tsx} +58 -100
- package/textarea/Textarea.test.js +150 -179
- package/textarea/types.d.ts +9 -5
- package/toggle-group/ToggleGroup.js +90 -107
- package/toggle-group/ToggleGroup.stories.tsx +7 -4
- package/toggle-group/ToggleGroup.test.js +68 -87
- package/toggle-group/types.d.ts +26 -17
- package/typography/Typography.js +4 -13
- package/typography/types.d.ts +1 -1
- package/useTheme.d.ts +49 -136
- package/useTheme.js +1 -8
- package/useTranslatedLabels.js +1 -7
- package/utils/BaseTypography.d.ts +2 -2
- package/utils/BaseTypography.js +16 -30
- package/utils/FocusLock.js +25 -39
- package/wizard/Wizard.js +14 -49
- package/wizard/Wizard.test.js +53 -80
- package/wizard/types.d.ts +7 -7
- package/common/OpenSans.css +0 -69
- package/common/fonts/OpenSans-Bold.ttf +0 -0
- package/common/fonts/OpenSans-BoldItalic.ttf +0 -0
- package/common/fonts/OpenSans-ExtraBold.ttf +0 -0
- package/common/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
- package/common/fonts/OpenSans-Italic.ttf +0 -0
- package/common/fonts/OpenSans-Light.ttf +0 -0
- package/common/fonts/OpenSans-LightItalic.ttf +0 -0
- package/common/fonts/OpenSans-Regular.ttf +0 -0
- package/common/fonts/OpenSans-SemiBold.ttf +0 -0
- package/common/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
- package/number-input/numberInputContextTypes.d.ts +0 -19
- package/resultsetTable/Icons.d.ts +0 -7
- package/resultsetTable/ResultsetTable.d.ts +0 -4
- package/slider/Slider.stories.tsx +0 -240
- package/text-input/Icons.d.ts +0 -8
- package/text-input/Icons.js +0 -60
- /package/{resultsetTable → action-icon}/types.js +0 -0
- /package/{number-input/numberInputContextTypes.js → container/types.js} +0 -0
- /package/spinner/{Spinner.stories.jsx → Spinner.stories.tsx} +0 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import DxcBadge from "./Badge";
|
|
3
|
+
import Title from "../../.storybook/components/Title";
|
|
4
|
+
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
|
+
import DxcFlex from "../flex/Flex";
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: "Badge",
|
|
9
|
+
component: DxcBadge,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const icon = (
|
|
13
|
+
<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="currentColor">
|
|
14
|
+
<path d="M11 17H13V11H11V17ZM12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM12 20C7.59 20 4 16.41 4 12C4 7.59 7.59 4 12 4C16.41 4 20 7.59 20 12C20 16.41 16.41 20 12 20ZM11 9H13V7H11V9Z" />
|
|
15
|
+
<path d="M11 7H13V9H11V7ZM11 11H13V17H11V11Z" />
|
|
16
|
+
<path d="M12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM12 20C7.59 20 4 16.41 4 12C4 7.59 7.59 4 12 4C16.41 4 20 7.59 20 12C20 16.41 16.41 20 12 20Z" />
|
|
17
|
+
</svg>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
export const Chromatic = () => (
|
|
21
|
+
<>
|
|
22
|
+
<Title title="Notification" theme="light" level={2} />
|
|
23
|
+
<ExampleContainer>
|
|
24
|
+
<Title title="Small" theme="light" level={4} />
|
|
25
|
+
<DxcFlex gap="3rem" alignItems="center">
|
|
26
|
+
<DxcBadge mode="notification" size="small" />
|
|
27
|
+
<DxcBadge mode="notification" label={1} size="small" />
|
|
28
|
+
<DxcBadge mode="notification" label={10} size="small" />
|
|
29
|
+
<DxcBadge mode="notification" label={1000000} size="small" notificationLimit={99999999} />
|
|
30
|
+
<DxcBadge mode="notification" label={100} size="small" notificationLimit={99} />
|
|
31
|
+
</DxcFlex>
|
|
32
|
+
</ExampleContainer>
|
|
33
|
+
<ExampleContainer>
|
|
34
|
+
<Title title="Medium" theme="light" level={4} />
|
|
35
|
+
<DxcFlex gap="3rem" alignContent="center" alignItems="center">
|
|
36
|
+
<DxcBadge mode="notification" size="medium" />
|
|
37
|
+
<DxcBadge mode="notification" label={1} size="medium" />
|
|
38
|
+
<DxcBadge mode="notification" label={10} size="medium" />
|
|
39
|
+
<DxcBadge mode="notification" label={1000000} size="medium" notificationLimit={99999999} />
|
|
40
|
+
<DxcBadge mode="notification" label={100} size="medium" />
|
|
41
|
+
</DxcFlex>
|
|
42
|
+
</ExampleContainer>
|
|
43
|
+
<ExampleContainer>
|
|
44
|
+
<Title title="Large" theme="light" level={4} />
|
|
45
|
+
<DxcFlex gap="3rem" alignItems="center">
|
|
46
|
+
<DxcBadge mode="notification" size="large" />
|
|
47
|
+
<DxcBadge mode="notification" label={1} size="large" />
|
|
48
|
+
<DxcBadge mode="notification" label={10} size="large" />
|
|
49
|
+
<DxcBadge mode="notification" label={1000000} size="large" notificationLimit={99999999} />
|
|
50
|
+
<DxcBadge mode="notification" label={100} size="large" />
|
|
51
|
+
</DxcFlex>
|
|
52
|
+
</ExampleContainer>
|
|
53
|
+
<Title title="Contextual" theme="light" level={2} />
|
|
54
|
+
<Title title="Grey" theme="light" level={3} />
|
|
55
|
+
<ExampleContainer>
|
|
56
|
+
<Title title="Small" theme="light" level={4} />
|
|
57
|
+
<DxcFlex gap="3rem" alignItems="center">
|
|
58
|
+
<DxcBadge label="Label" size="small" />
|
|
59
|
+
<DxcBadge label="Label" size="small" icon={icon} />
|
|
60
|
+
</DxcFlex>
|
|
61
|
+
</ExampleContainer>
|
|
62
|
+
<ExampleContainer>
|
|
63
|
+
<Title title="Medium" theme="light" level={4} />
|
|
64
|
+
<DxcFlex gap="3rem" alignItems="center">
|
|
65
|
+
<DxcBadge label="Label" />
|
|
66
|
+
<DxcBadge label="Label" icon={icon} />
|
|
67
|
+
</DxcFlex>
|
|
68
|
+
</ExampleContainer>
|
|
69
|
+
<ExampleContainer>
|
|
70
|
+
<Title title="Large" theme="light" level={4} />
|
|
71
|
+
<DxcFlex gap="3rem" alignItems="center">
|
|
72
|
+
<DxcBadge label="Label" size="large" />
|
|
73
|
+
<DxcBadge label="Label" size="large" icon={icon} />
|
|
74
|
+
</DxcFlex>
|
|
75
|
+
</ExampleContainer>
|
|
76
|
+
<Title title="Blue" theme="light" level={3} />
|
|
77
|
+
<ExampleContainer>
|
|
78
|
+
<Title title="Small" theme="light" level={4} />
|
|
79
|
+
<DxcFlex gap="3rem" alignItems="center">
|
|
80
|
+
<DxcBadge color="blue" label="Label" size="small" />
|
|
81
|
+
<DxcBadge color="blue" label="Label" size="small" icon={icon} />
|
|
82
|
+
</DxcFlex>
|
|
83
|
+
</ExampleContainer>
|
|
84
|
+
<ExampleContainer>
|
|
85
|
+
<Title title="Medium" theme="light" level={4} />
|
|
86
|
+
<DxcFlex gap="3rem" alignItems="center">
|
|
87
|
+
<DxcBadge color="blue" label="Label" />
|
|
88
|
+
<DxcBadge color="blue" label="Label" icon={icon} />
|
|
89
|
+
</DxcFlex>
|
|
90
|
+
</ExampleContainer>
|
|
91
|
+
<ExampleContainer>
|
|
92
|
+
<Title title="Large" theme="light" level={4} />
|
|
93
|
+
<DxcFlex gap="3rem" alignItems="center">
|
|
94
|
+
<DxcBadge color="blue" label="Label" size="large" />
|
|
95
|
+
<DxcBadge color="blue" label="Label" size="large" icon={icon} />
|
|
96
|
+
</DxcFlex>
|
|
97
|
+
</ExampleContainer>
|
|
98
|
+
<Title title="Green" theme="light" level={3} />
|
|
99
|
+
<ExampleContainer>
|
|
100
|
+
<Title title="Small" theme="light" level={4} />
|
|
101
|
+
<DxcFlex gap="3rem" alignItems="center">
|
|
102
|
+
<DxcBadge color="green" label="Label" size="small" />
|
|
103
|
+
<DxcBadge color="green" label="Label" size="small" icon={icon} />
|
|
104
|
+
</DxcFlex>
|
|
105
|
+
</ExampleContainer>
|
|
106
|
+
<ExampleContainer>
|
|
107
|
+
<Title title="Medium" theme="light" level={4} />
|
|
108
|
+
<DxcFlex gap="3rem" alignItems="center">
|
|
109
|
+
<DxcBadge color="green" label="Label" />
|
|
110
|
+
<DxcBadge color="green" label="Label" icon={icon} />
|
|
111
|
+
</DxcFlex>
|
|
112
|
+
</ExampleContainer>
|
|
113
|
+
<ExampleContainer>
|
|
114
|
+
<Title title="Large" theme="light" level={4} />
|
|
115
|
+
<DxcFlex gap="3rem" alignItems="center">
|
|
116
|
+
<DxcBadge color="green" label="Label" size="large" />
|
|
117
|
+
<DxcBadge color="green" label="Label" size="large" icon={icon} />
|
|
118
|
+
</DxcFlex>
|
|
119
|
+
</ExampleContainer>
|
|
120
|
+
<ExampleContainer></ExampleContainer>
|
|
121
|
+
<Title title="Orange" theme="light" level={3} />
|
|
122
|
+
<ExampleContainer>
|
|
123
|
+
<Title title="Small" theme="light" level={4} />
|
|
124
|
+
<DxcFlex gap="3rem" alignItems="center">
|
|
125
|
+
<DxcBadge color="orange" label="Label" size="small" />
|
|
126
|
+
<DxcBadge color="orange" label="Label" size="small" icon={icon} />
|
|
127
|
+
</DxcFlex>
|
|
128
|
+
</ExampleContainer>
|
|
129
|
+
<ExampleContainer>
|
|
130
|
+
<Title title="Medium" theme="light" level={4} />
|
|
131
|
+
<DxcFlex gap="3rem" alignItems="center">
|
|
132
|
+
<DxcBadge color="orange" label="Label" />
|
|
133
|
+
<DxcBadge color="orange" label="Label" icon={icon} />
|
|
134
|
+
</DxcFlex>
|
|
135
|
+
</ExampleContainer>
|
|
136
|
+
<ExampleContainer>
|
|
137
|
+
<Title title="Large" theme="light" level={4} />
|
|
138
|
+
<DxcFlex gap="3rem" alignItems="center">
|
|
139
|
+
<DxcBadge color="orange" label="Label" size="large" />
|
|
140
|
+
<DxcBadge color="orange" label="Label" size="large" icon={icon} />
|
|
141
|
+
</DxcFlex>
|
|
142
|
+
</ExampleContainer>
|
|
143
|
+
<Title title="Red" theme="light" level={3} />
|
|
144
|
+
<ExampleContainer>
|
|
145
|
+
<Title title="Small" theme="light" level={4} />
|
|
146
|
+
<DxcFlex gap="3rem" alignItems="center">
|
|
147
|
+
<DxcBadge color="red" label="Label" size="small" />
|
|
148
|
+
<DxcBadge color="red" label="Label" size="small" icon={icon} />
|
|
149
|
+
</DxcFlex>
|
|
150
|
+
</ExampleContainer>
|
|
151
|
+
<ExampleContainer>
|
|
152
|
+
<Title title="Medium" theme="light" level={4} />
|
|
153
|
+
<DxcFlex gap="3rem" alignItems="center">
|
|
154
|
+
<DxcBadge color="red" label="Label" />
|
|
155
|
+
<DxcBadge color="red" label="Label" icon={icon} />
|
|
156
|
+
</DxcFlex>
|
|
157
|
+
</ExampleContainer>
|
|
158
|
+
<ExampleContainer>
|
|
159
|
+
<Title title="Large" theme="light" level={4} />
|
|
160
|
+
<DxcFlex gap="3rem" alignItems="center">
|
|
161
|
+
<DxcBadge color="red" label="Label" size="large" />
|
|
162
|
+
<DxcBadge color="red" label="Label" size="large" icon={icon} />
|
|
163
|
+
</DxcFlex>
|
|
164
|
+
</ExampleContainer>
|
|
165
|
+
<Title title="Yellow" theme="light" level={3} />
|
|
166
|
+
<ExampleContainer>
|
|
167
|
+
<Title title="Small" theme="light" level={4} />
|
|
168
|
+
<DxcFlex gap="3rem" alignItems="center">
|
|
169
|
+
<DxcBadge color="yellow" label="Label" size="small" />
|
|
170
|
+
<DxcBadge color="yellow" label="Label" size="small" icon={icon} />
|
|
171
|
+
</DxcFlex>
|
|
172
|
+
</ExampleContainer>
|
|
173
|
+
<ExampleContainer>
|
|
174
|
+
<Title title="Medium" theme="light" level={4} />
|
|
175
|
+
<DxcFlex gap="3rem" alignItems="center">
|
|
176
|
+
<DxcBadge color="yellow" label="Label" />
|
|
177
|
+
<DxcBadge color="yellow" label="Label" icon={icon} />
|
|
178
|
+
</DxcFlex>
|
|
179
|
+
</ExampleContainer>
|
|
180
|
+
<ExampleContainer>
|
|
181
|
+
<Title title="Large" theme="light" level={4} />
|
|
182
|
+
<DxcFlex gap="3rem" alignItems="center">
|
|
183
|
+
<DxcBadge color="yellow" label="Label" size="large" />
|
|
184
|
+
<DxcBadge color="yellow" label="Label" size="large" icon={icon} />
|
|
185
|
+
</DxcFlex>
|
|
186
|
+
</ExampleContainer>
|
|
187
|
+
<Title title="Purple" theme="light" level={3} />
|
|
188
|
+
<ExampleContainer>
|
|
189
|
+
<Title title="Small" theme="light" level={4} />
|
|
190
|
+
<DxcFlex gap="3rem" alignItems="center">
|
|
191
|
+
<DxcBadge color="purple" label="Label" size="small" />
|
|
192
|
+
<DxcBadge color="purple" label="Label" size="small" icon={icon} />
|
|
193
|
+
</DxcFlex>
|
|
194
|
+
</ExampleContainer>
|
|
195
|
+
<ExampleContainer>
|
|
196
|
+
<Title title="Medium" theme="light" level={4} />
|
|
197
|
+
<DxcFlex gap="3rem" alignItems="center">
|
|
198
|
+
<DxcBadge color="purple" label="Label" />
|
|
199
|
+
<DxcBadge color="purple" label="Label" icon={icon} />
|
|
200
|
+
</DxcFlex>
|
|
201
|
+
</ExampleContainer>
|
|
202
|
+
<ExampleContainer>
|
|
203
|
+
<Title title="Large" theme="light" level={4} />
|
|
204
|
+
<DxcFlex gap="3rem" alignItems="center">
|
|
205
|
+
<DxcBadge color="purple" label="Label" size="large" />
|
|
206
|
+
<DxcBadge color="purple" label="Label" size="large" icon={icon} />
|
|
207
|
+
</DxcFlex>
|
|
208
|
+
</ExampleContainer>
|
|
209
|
+
</>
|
|
210
|
+
);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _react = _interopRequireDefault(require("react"));
|
|
5
|
+
var _react2 = require("@testing-library/react");
|
|
6
|
+
var _Badge = _interopRequireDefault(require("./Badge.tsx"));
|
|
7
|
+
var _Flex = _interopRequireDefault(require("../flex/Flex.tsx"));
|
|
8
|
+
describe("Badge component tests", function () {
|
|
9
|
+
test("Badge renders with correct label when it is less than notification limit", function () {
|
|
10
|
+
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Badge["default"], {
|
|
11
|
+
label: 99,
|
|
12
|
+
mode: "notification"
|
|
13
|
+
})),
|
|
14
|
+
getByText = _render.getByText;
|
|
15
|
+
expect(getByText("99")).toBeTruthy();
|
|
16
|
+
});
|
|
17
|
+
test("Badge renders +99 as label when it is greater than notification limit", function () {
|
|
18
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Flex["default"], null, /*#__PURE__*/_react["default"].createElement(_Badge["default"], {
|
|
19
|
+
label: 120,
|
|
20
|
+
mode: "notification"
|
|
21
|
+
}), /*#__PURE__*/_react["default"].createElement(_Badge["default"], {
|
|
22
|
+
label: 11,
|
|
23
|
+
mode: "notification",
|
|
24
|
+
notificationLimit: 10
|
|
25
|
+
}))),
|
|
26
|
+
getByText = _render2.getByText;
|
|
27
|
+
expect(getByText("+99")).toBeTruthy();
|
|
28
|
+
expect(getByText("+10")).toBeTruthy();
|
|
29
|
+
});
|
|
30
|
+
});
|
package/badge/types.d.ts
CHANGED
|
@@ -1,5 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
3
|
+
export type ContextualProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Text to be placed in the badge.
|
|
6
|
+
*/
|
|
7
|
+
label: string;
|
|
8
|
+
/**
|
|
9
|
+
* The available badge modes.
|
|
10
|
+
*/
|
|
11
|
+
mode?: "contextual";
|
|
12
|
+
/**
|
|
13
|
+
* In notification mode, if the number entered as label is greater that this notification limit, +99 will be shown. If not, the entered text will be shown as label.
|
|
14
|
+
*/
|
|
15
|
+
notificationLimit?: never;
|
|
16
|
+
/**
|
|
17
|
+
* Affects the visual style of the badge. It can be used following semantic purposes or not.
|
|
18
|
+
*/
|
|
19
|
+
color?: "grey" | "blue" | "green" | "orange" | "red" | "yellow" | "purple";
|
|
4
20
|
};
|
|
21
|
+
export type NotificationProps = {
|
|
22
|
+
/**
|
|
23
|
+
* Text to be placed in the badge.
|
|
24
|
+
*/
|
|
25
|
+
label?: number;
|
|
26
|
+
/**
|
|
27
|
+
* The available badge modes.
|
|
28
|
+
*/
|
|
29
|
+
mode: "notification";
|
|
30
|
+
/**
|
|
31
|
+
* In notification mode, if the number entered as label is greater that this notification limit, +99 will be shown. If not, the entered text will be shown as label.
|
|
32
|
+
*/
|
|
33
|
+
notificationLimit?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Affects the visual style of the badge. It can be used following semantic purposes or not.
|
|
36
|
+
*/
|
|
37
|
+
color?: never;
|
|
38
|
+
};
|
|
39
|
+
export type CommonProps = {
|
|
40
|
+
/**
|
|
41
|
+
* Text representing advisory information related to the badge. Under the hood, this prop also serves as an accessible label for the component.
|
|
42
|
+
*/
|
|
43
|
+
title?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Element or path used as the icon that will be placed next to the badge label in contextual mode.
|
|
46
|
+
*/
|
|
47
|
+
icon?: string | SVG;
|
|
48
|
+
/**
|
|
49
|
+
* Size of the component.
|
|
50
|
+
*/
|
|
51
|
+
size?: "small" | "medium" | "large";
|
|
52
|
+
};
|
|
53
|
+
type Props = (ContextualProps | NotificationProps) & CommonProps;
|
|
5
54
|
export default Props;
|
package/bleed/Bleed.js
CHANGED
|
@@ -1,29 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = Bleed;
|
|
9
|
-
|
|
10
8
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
10
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
15
|
-
|
|
16
11
|
var _templateObject;
|
|
17
|
-
|
|
18
12
|
function Bleed(_ref) {
|
|
19
13
|
var space = _ref.space,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
horizontal = _ref.horizontal,
|
|
15
|
+
vertical = _ref.vertical,
|
|
16
|
+
top = _ref.top,
|
|
17
|
+
right = _ref.right,
|
|
18
|
+
bottom = _ref.bottom,
|
|
19
|
+
left = _ref.left,
|
|
20
|
+
children = _ref.children;
|
|
27
21
|
return /*#__PURE__*/_react["default"].createElement(StyledBleed, {
|
|
28
22
|
space: space,
|
|
29
23
|
horizontal: horizontal,
|
|
@@ -34,18 +28,16 @@ function Bleed(_ref) {
|
|
|
34
28
|
left: left
|
|
35
29
|
}, children);
|
|
36
30
|
}
|
|
37
|
-
|
|
38
31
|
function getSpacingValue(spacingName) {
|
|
39
32
|
return spacingName ? spacingName : "0rem";
|
|
40
33
|
}
|
|
41
|
-
|
|
42
34
|
var StyledBleed = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n ", "\n"])), function (_ref2) {
|
|
43
35
|
var space = _ref2.space,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
horizontal = _ref2.horizontal,
|
|
37
|
+
vertical = _ref2.vertical,
|
|
38
|
+
top = _ref2.top,
|
|
39
|
+
right = _ref2.right,
|
|
40
|
+
bottom = _ref2.bottom,
|
|
41
|
+
left = _ref2.left;
|
|
50
42
|
return "\n margin: -".concat(getSpacingValue(top || vertical || space), " -").concat(getSpacingValue(right || horizontal || space), " -").concat(getSpacingValue(bottom || vertical || space), " -").concat(getSpacingValue(left || horizontal || space), ";\n");
|
|
51
43
|
});
|
package/bleed/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type Spacing = "0rem" | "0.125rem" | "0.25rem" | "0.5rem" | "1rem" | "1.5rem" | "2rem" | "3rem" | "4rem" | "5rem";
|
|
3
|
+
type Props = {
|
|
4
4
|
/**
|
|
5
5
|
* Applies the spacing scale to all sides.
|
|
6
6
|
*/
|
package/box/Box.js
CHANGED
|
@@ -1,45 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports["default"] = void 0;
|
|
11
|
-
|
|
12
9
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
-
|
|
14
10
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
15
|
-
|
|
16
11
|
var _react = _interopRequireDefault(require("react"));
|
|
17
|
-
|
|
18
12
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
19
|
-
|
|
20
13
|
var _variables = require("../common/variables");
|
|
21
|
-
|
|
22
14
|
var _utils = require("../common/utils");
|
|
23
|
-
|
|
24
15
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
|
-
|
|
26
|
-
var _BackgroundColorContext = require("../BackgroundColorContext");
|
|
27
|
-
|
|
28
16
|
var _templateObject;
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
-
|
|
17
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
18
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
34
19
|
var DxcBox = function DxcBox(_ref) {
|
|
35
20
|
var _ref$shadowDepth = _ref.shadowDepth,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
21
|
+
shadowDepth = _ref$shadowDepth === void 0 ? 2 : _ref$shadowDepth,
|
|
22
|
+
_ref$display = _ref.display,
|
|
23
|
+
display = _ref$display === void 0 ? "inline-flex" : _ref$display,
|
|
24
|
+
children = _ref.children,
|
|
25
|
+
margin = _ref.margin,
|
|
26
|
+
_ref$size = _ref.size,
|
|
27
|
+
size = _ref$size === void 0 ? "fitContent" : _ref$size;
|
|
43
28
|
var colorsTheme = (0, _useTheme["default"])();
|
|
44
29
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
45
30
|
theme: colorsTheme.box
|
|
@@ -48,11 +33,8 @@ var DxcBox = function DxcBox(_ref) {
|
|
|
48
33
|
display: display,
|
|
49
34
|
margin: margin,
|
|
50
35
|
size: size
|
|
51
|
-
},
|
|
52
|
-
color: colorsTheme.box.backgroundColor
|
|
53
|
-
}, children)));
|
|
36
|
+
}, children));
|
|
54
37
|
};
|
|
55
|
-
|
|
56
38
|
var sizes = {
|
|
57
39
|
small: "48px",
|
|
58
40
|
medium: "240px",
|
|
@@ -60,11 +42,9 @@ var sizes = {
|
|
|
60
42
|
fillParent: "100%",
|
|
61
43
|
fitContent: "fit-content"
|
|
62
44
|
};
|
|
63
|
-
|
|
64
45
|
var calculateWidth = function calculateWidth(margin, size) {
|
|
65
46
|
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
66
47
|
};
|
|
67
|
-
|
|
68
48
|
var Box = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: ", ";\n border-radius: ", ";\n border-width: ", ";\n border-style: ", ";\n border-color: ", ";\n overflow: hidden;\n width: ", ";\n background-color: ", ";\n box-shadow: ", ";\n\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
|
|
69
49
|
return props.display;
|
|
70
50
|
}, function (props) {
|
|
@@ -92,6 +72,4 @@ var Box = _styledComponents["default"].div(_templateObject || (_templateObject =
|
|
|
92
72
|
}, function (props) {
|
|
93
73
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
94
74
|
});
|
|
95
|
-
|
|
96
|
-
var _default = DxcBox;
|
|
97
|
-
exports["default"] = _default;
|
|
75
|
+
var _default = exports["default"] = DxcBox;
|
package/box/Box.test.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _react = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
5
|
var _react2 = require("@testing-library/react");
|
|
8
|
-
|
|
9
6
|
var _Card = _interopRequireDefault(require("../card/Card.tsx"));
|
|
10
|
-
|
|
11
7
|
describe("Box component tests", function () {
|
|
12
8
|
test("Box renders with correct text", function () {
|
|
13
9
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Card["default"], null, "test-box")),
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
getByText = _render.getByText;
|
|
16
11
|
expect(getByText("test-box")).toBeTruthy();
|
|
17
12
|
});
|
|
18
13
|
});
|
package/box/types.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
+
type Margin = {
|
|
4
4
|
top?: Space;
|
|
5
5
|
bottom?: Space;
|
|
6
6
|
left?: Space;
|
|
7
7
|
right?: Space;
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
type Props = {
|
|
10
10
|
/**
|
|
11
11
|
* The size of the shadow to be displayed around the box.
|
|
12
12
|
*/
|