@dxc-technology/halstack-react 0.0.0-7c194f8 → 0.0.0-7c2b794
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/HalstackContext.d.ts +29 -15
- package/HalstackContext.js +1 -1
- package/accordion/Accordion.js +1 -1
- package/accordion-group/AccordionGroup.d.ts +2 -3
- package/accordion-group/AccordionGroup.js +3 -3
- package/accordion-group/AccordionGroupAccordion.js +2 -2
- package/accordion-group/AccordionGroupContext.d.ts +3 -0
- package/accordion-group/AccordionGroupContext.js +8 -0
- package/action-icon/ActionIcon.d.ts +4 -0
- package/action-icon/ActionIcon.js +47 -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/action-icon/types.js +5 -0
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +140 -29
- package/badge/Badge.stories.tsx +210 -0
- package/badge/Badge.test.js +30 -0
- package/badge/types.d.ts +52 -3
- package/button/Button.js +3 -2
- package/button/Button.stories.tsx +32 -50
- package/button/Button.test.js +3 -1
- package/button/types.d.ts +1 -1
- package/common/coreTokens.js +2 -2
- package/common/variables.d.ts +29 -15
- package/common/variables.js +36 -22
- package/container/Container.js +1 -1
- 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/types.d.ts +2 -2
- 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 +19 -0
- package/divider/types.js +5 -0
- package/dropdown/Dropdown.js +9 -7
- package/dropdown/types.d.ts +1 -1
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +25 -12
- package/footer/Footer.stories.tsx +19 -0
- package/footer/Icons.d.ts +1 -0
- package/footer/Icons.js +65 -1
- package/footer/types.d.ts +6 -0
- package/header/types.d.ts +2 -2
- package/icon/Icon.d.ts +4 -0
- package/icon/Icon.js +33 -0
- package/icon/Icon.stories.tsx +26 -0
- package/icon/types.d.ts +4 -0
- package/icon/types.js +5 -0
- package/image/Image.stories.tsx +3 -1
- package/layout/ApplicationLayout.d.ts +1 -1
- package/layout/ApplicationLayout.js +1 -1
- package/main.d.ts +5 -2
- package/main.js +22 -1
- package/nav-tabs/NavTabs.d.ts +1 -2
- package/nav-tabs/NavTabs.js +9 -6
- package/nav-tabs/NavTabs.stories.tsx +6 -4
- package/nav-tabs/NavTabs.test.js +3 -2
- package/nav-tabs/NavTabsContext.d.ts +3 -0
- package/nav-tabs/NavTabsContext.js +8 -0
- package/nav-tabs/Tab.js +8 -7
- package/number-input/NumberInput.d.ts +0 -7
- package/number-input/NumberInput.js +24 -5
- package/number-input/NumberInput.test.js +165 -6
- package/number-input/NumberInputContext.d.ts +3 -0
- package/number-input/NumberInputContext.js +8 -0
- package/number-input/types.d.ts +6 -0
- package/package.json +2 -2
- package/radio-group/RadioGroup.js +1 -1
- package/resultset-table/ResultsetTable.d.ts +4 -1
- package/resultset-table/ResultsetTable.js +13 -6
- package/resultset-table/ResultsetTable.stories.tsx +102 -5
- package/resultset-table/ResultsetTable.test.js +66 -0
- package/resultset-table/types.d.ts +6 -0
- package/select/Option.js +8 -1
- package/select/Select.js +33 -23
- package/select/types.d.ts +2 -2
- package/sidenav/Sidenav.js +3 -2
- package/slider/Slider.js +5 -6
- 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/table/DropdownTheme.js +62 -0
- package/table/Table.d.ts +6 -2
- package/table/Table.js +82 -8
- package/table/Table.stories.tsx +304 -2
- package/table/Table.test.js +92 -0
- package/table/types.d.ts +42 -0
- package/tabs/Tab.js +7 -4
- package/tabs/Tabs.js +4 -5
- package/tabs/Tabs.stories.tsx +1 -1
- package/text-input/TextInput.js +58 -71
- package/text-input/TextInput.test.js +96 -79
- package/useTheme.d.ts +29 -15
- package/utils/FocusLock.js +3 -0
- package/wizard/types.d.ts +1 -1
- 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/{layout → sidenav}/SidenavContext.d.ts +0 -0
- /package/{layout → sidenav}/SidenavContext.js +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/button/Button.js
CHANGED
|
@@ -13,6 +13,7 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
|
13
13
|
var _variables = require("../common/variables");
|
|
14
14
|
var _utils = require("../common/utils");
|
|
15
15
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
16
|
+
var _Icon = _interopRequireDefault(require("../icon/Icon"));
|
|
16
17
|
var _templateObject, _templateObject2, _templateObject3;
|
|
17
18
|
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
19
|
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; }
|
|
@@ -54,8 +55,8 @@ var DxcButton = function DxcButton(_ref) {
|
|
|
54
55
|
iconPosition: iconPosition,
|
|
55
56
|
size: size,
|
|
56
57
|
margin: margin
|
|
57
|
-
}, label && /*#__PURE__*/_react["default"].createElement(LabelContainer, null, label), icon && /*#__PURE__*/_react["default"].createElement(IconContainer, null, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement("
|
|
58
|
-
|
|
58
|
+
}, label && /*#__PURE__*/_react["default"].createElement(LabelContainer, null, label), icon && /*#__PURE__*/_react["default"].createElement(IconContainer, null, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
|
|
59
|
+
icon: icon
|
|
59
60
|
}) : icon)));
|
|
60
61
|
};
|
|
61
62
|
var sizes = {
|
|
@@ -76,30 +76,26 @@ export const Chromatic = () => (
|
|
|
76
76
|
</ExampleContainer>
|
|
77
77
|
<ExampleContainer>
|
|
78
78
|
<Title title="Disabled" theme="light" level={4} />
|
|
79
|
-
<DxcButton label="Primary disabled" disabled icon=
|
|
79
|
+
<DxcButton label="Primary disabled" disabled icon="filled_bottom_app_bar" />
|
|
80
80
|
</ExampleContainer>
|
|
81
81
|
<ExampleContainer>
|
|
82
82
|
<Title title="With left icon" theme="light" level={4} />
|
|
83
|
-
<DxcButton label="Primary" icon=
|
|
83
|
+
<DxcButton label="Primary" icon="filled_bottom_app_bar" />
|
|
84
84
|
</ExampleContainer>
|
|
85
85
|
<ExampleContainer>
|
|
86
86
|
<Title title="With right icon" theme="light" level={4} />
|
|
87
|
-
<DxcButton label="Primary" icon=
|
|
87
|
+
<DxcButton label="Primary" icon="filled_bottom_app_bar" iconPosition="after" />
|
|
88
88
|
</ExampleContainer>
|
|
89
89
|
<ExampleContainer>
|
|
90
90
|
<Title title="Only icon" theme="light" level={4} />
|
|
91
|
-
<DxcButton icon=
|
|
91
|
+
<DxcButton icon="filled_bottom_app_bar" />
|
|
92
92
|
</ExampleContainer>
|
|
93
93
|
<ExampleContainer>
|
|
94
94
|
<Title title="Big icon (SVG)" theme="light" level={4} />
|
|
95
95
|
<DxcButton icon={facebookIcon} />
|
|
96
96
|
</ExampleContainer>
|
|
97
97
|
<ExampleContainer>
|
|
98
|
-
<Title title="
|
|
99
|
-
<DxcButton icon="https://www.freepnglogos.com/uploads/facebook-logo-design-1.png" />
|
|
100
|
-
</ExampleContainer>
|
|
101
|
-
<ExampleContainer>
|
|
102
|
-
<Title title="Small icon" theme="light" level={4} />
|
|
98
|
+
<Title title="Small icon (SVG)" theme="light" level={4} />
|
|
103
99
|
<DxcButton icon={smallIcon} />
|
|
104
100
|
</ExampleContainer>
|
|
105
101
|
<Title title="Secondary" theme="light" level={2} />
|
|
@@ -121,18 +117,11 @@ export const Chromatic = () => (
|
|
|
121
117
|
</ExampleContainer>
|
|
122
118
|
<ExampleContainer>
|
|
123
119
|
<Title title="Disabled" theme="light" level={4} />
|
|
124
|
-
<DxcButton mode="secondary" disabled label="Secondary disabled" icon=
|
|
120
|
+
<DxcButton mode="secondary" disabled label="Secondary disabled" icon="filled_bottom_app_bar" />
|
|
125
121
|
</ExampleContainer>
|
|
126
122
|
<ExampleContainer>
|
|
127
123
|
<Title title="With icon" theme="light" level={4} />
|
|
128
|
-
<DxcButton mode="secondary" label="Secondary" icon=
|
|
129
|
-
</ExampleContainer>
|
|
130
|
-
<ExampleContainer>
|
|
131
|
-
<Title title="Only icon (image)" theme="light" level={4} />
|
|
132
|
-
<DxcButton
|
|
133
|
-
mode="secondary"
|
|
134
|
-
icon="https://www.freepnglogos.com/uploads/facebook-logo-design-1.png"
|
|
135
|
-
/>
|
|
124
|
+
<DxcButton mode="secondary" label="Secondary" icon="filled_bottom_app_bar" />
|
|
136
125
|
</ExampleContainer>
|
|
137
126
|
<Title title="Text" theme="light" level={2} />
|
|
138
127
|
<ExampleContainer>
|
|
@@ -153,18 +142,11 @@ export const Chromatic = () => (
|
|
|
153
142
|
</ExampleContainer>
|
|
154
143
|
<ExampleContainer>
|
|
155
144
|
<Title title="Disabled" theme="light" level={4} />
|
|
156
|
-
<DxcButton mode="text" label="Text disabled" disabled icon=
|
|
145
|
+
<DxcButton mode="text" label="Text disabled" disabled icon="filled_bottom_app_bar" />
|
|
157
146
|
</ExampleContainer>
|
|
158
147
|
<ExampleContainer>
|
|
159
148
|
<Title title="With icon" theme="light" level={4} />
|
|
160
|
-
<DxcButton label="Text" mode="text" icon=
|
|
161
|
-
</ExampleContainer>
|
|
162
|
-
<ExampleContainer>
|
|
163
|
-
<Title title="Only icon (image)" theme="light" level={4} />
|
|
164
|
-
<DxcButton
|
|
165
|
-
mode="text"
|
|
166
|
-
icon="https://www.freepnglogos.com/uploads/facebook-logo-design-1.png"
|
|
167
|
-
/>
|
|
149
|
+
<DxcButton label="Text" mode="text" icon="filled_bottom_app_bar" />
|
|
168
150
|
</ExampleContainer>
|
|
169
151
|
<Title title="Sizes" theme="light" level={2} />
|
|
170
152
|
<ExampleContainer>
|
|
@@ -181,19 +163,19 @@ export const Chromatic = () => (
|
|
|
181
163
|
</ExampleContainer>
|
|
182
164
|
<ExampleContainer>
|
|
183
165
|
<Title title="Medium size icon after" theme="light" level={4} />
|
|
184
|
-
<DxcButton label="Medium" iconPosition="after" icon=
|
|
166
|
+
<DxcButton label="Medium" iconPosition="after" icon="filled_bottom_app_bar" size="medium" />
|
|
185
167
|
</ExampleContainer>
|
|
186
168
|
<ExampleContainer>
|
|
187
169
|
<Title title="Medium size icon before" theme="light" level={4} />
|
|
188
|
-
<DxcButton label="Medium" iconPosition="before" icon=
|
|
170
|
+
<DxcButton label="Medium" iconPosition="before" icon="filled_bottom_app_bar" size="medium" />
|
|
189
171
|
</ExampleContainer>
|
|
190
172
|
<ExampleContainer>
|
|
191
173
|
<Title title="Medium size icon after with ellipsis" theme="light" level={4} />
|
|
192
|
-
<DxcButton label="Medium" iconPosition="after" icon=
|
|
174
|
+
<DxcButton label="Medium" iconPosition="after" icon="filled_bottom_app_bar" size="medium" />
|
|
193
175
|
</ExampleContainer>
|
|
194
176
|
<ExampleContainer>
|
|
195
177
|
<Title title="Medium size icon before with ellipsis" theme="light" level={4} />
|
|
196
|
-
<DxcButton label="Medium" iconPosition="before" icon=
|
|
178
|
+
<DxcButton label="Medium" iconPosition="before" icon="filled_bottom_app_bar" size="medium" />
|
|
197
179
|
</ExampleContainer>
|
|
198
180
|
<ExampleContainer>
|
|
199
181
|
<Title title="Large size" theme="light" level={4} />
|
|
@@ -205,19 +187,19 @@ export const Chromatic = () => (
|
|
|
205
187
|
</ExampleContainer>
|
|
206
188
|
<ExampleContainer>
|
|
207
189
|
<Title title="Large size icon after" theme="light" level={4} />
|
|
208
|
-
<DxcButton label="LargeSizePrimaryButton" iconPosition="after" icon=
|
|
190
|
+
<DxcButton label="LargeSizePrimaryButton" iconPosition="after" icon="filled_bottom_app_bar" size="large" />
|
|
209
191
|
</ExampleContainer>
|
|
210
192
|
<ExampleContainer>
|
|
211
193
|
<Title title="Large size icon before" theme="light" level={4} />
|
|
212
|
-
<DxcButton label="LargeSizePrimaryButton" iconPosition="before" icon=
|
|
194
|
+
<DxcButton label="LargeSizePrimaryButton" iconPosition="before" icon="filled_bottom_app_bar" size="large" />
|
|
213
195
|
</ExampleContainer>
|
|
214
196
|
<ExampleContainer>
|
|
215
197
|
<Title title="Large size icon after with ellipsis" theme="light" level={4} />
|
|
216
|
-
<DxcButton label="LargeSizePrimaryButton" iconPosition="after" icon=
|
|
198
|
+
<DxcButton label="LargeSizePrimaryButton" iconPosition="after" icon="filled_bottom_app_bar" size="large" />
|
|
217
199
|
</ExampleContainer>
|
|
218
200
|
<ExampleContainer>
|
|
219
201
|
<Title title="Large size icon before with ellipsis" theme="light" level={4} />
|
|
220
|
-
<DxcButton label="LargeSizePrimaryButton" iconPosition="before" icon=
|
|
202
|
+
<DxcButton label="LargeSizePrimaryButton" iconPosition="before" icon="filled_bottom_app_bar" size="large" />
|
|
221
203
|
</ExampleContainer>
|
|
222
204
|
<ExampleContainer>
|
|
223
205
|
<Title title="FillParent size" theme="light" level={4} />
|
|
@@ -269,75 +251,75 @@ export const Chromatic = () => (
|
|
|
269
251
|
<ExampleContainer>
|
|
270
252
|
<Title title="Enabled" theme="light" level={4} />
|
|
271
253
|
<HalstackProvider theme={opinionatedTheme}>
|
|
272
|
-
<DxcButton label="Primary" icon=
|
|
254
|
+
<DxcButton label="Primary" icon="filled_bottom_app_bar" />
|
|
273
255
|
</HalstackProvider>
|
|
274
256
|
</ExampleContainer>
|
|
275
257
|
<ExampleContainer pseudoState="pseudo-hover">
|
|
276
258
|
<Title title="Hovered" theme="light" level={4} />
|
|
277
|
-
<DxcButton label="Primary hovered" icon=
|
|
259
|
+
<DxcButton label="Primary hovered" icon="filled_bottom_app_bar" />
|
|
278
260
|
</ExampleContainer>
|
|
279
261
|
<ExampleContainer pseudoState="pseudo-focus">
|
|
280
262
|
<Title title="Focused" theme="light" level={4} />
|
|
281
|
-
<DxcButton label="Primary focused" icon=
|
|
263
|
+
<DxcButton label="Primary focused" icon="filled_bottom_app_bar" />
|
|
282
264
|
</ExampleContainer>
|
|
283
265
|
<ExampleContainer pseudoState="pseudo-active">
|
|
284
266
|
<Title title="Actived" theme="light" level={4} />
|
|
285
|
-
<DxcButton label="Primary actived" icon=
|
|
267
|
+
<DxcButton label="Primary actived" icon="filled_bottom_app_bar" />
|
|
286
268
|
</ExampleContainer>
|
|
287
269
|
<ExampleContainer>
|
|
288
270
|
<Title title="Disabled" theme="light" level={4} />
|
|
289
271
|
<HalstackProvider theme={opinionatedTheme}>
|
|
290
|
-
<DxcButton label="Primary" icon=
|
|
272
|
+
<DxcButton label="Primary" icon="filled_bottom_app_bar" disabled />
|
|
291
273
|
</HalstackProvider>
|
|
292
274
|
</ExampleContainer>
|
|
293
275
|
<Title title="Secondary" theme="light" level={3} />
|
|
294
276
|
<ExampleContainer>
|
|
295
277
|
<Title title="Enabled" theme="light" level={4} />
|
|
296
278
|
<HalstackProvider theme={opinionatedTheme}>
|
|
297
|
-
<DxcButton mode="secondary" label="Secondary" icon=
|
|
279
|
+
<DxcButton mode="secondary" label="Secondary" icon="filled_bottom_app_bar" />
|
|
298
280
|
</HalstackProvider>
|
|
299
281
|
</ExampleContainer>
|
|
300
282
|
<ExampleContainer pseudoState="pseudo-hover">
|
|
301
283
|
<Title title="Hovered" theme="light" level={4} />
|
|
302
|
-
<DxcButton mode="secondary" label="Secondary hovered" icon=
|
|
284
|
+
<DxcButton mode="secondary" label="Secondary hovered" icon="filled_bottom_app_bar" />
|
|
303
285
|
</ExampleContainer>
|
|
304
286
|
<ExampleContainer pseudoState="pseudo-focus">
|
|
305
287
|
<Title title="Focused" theme="light" level={4} />
|
|
306
|
-
<DxcButton mode="secondary" label="Secondary focused" icon=
|
|
288
|
+
<DxcButton mode="secondary" label="Secondary focused" icon="filled_bottom_app_bar" />
|
|
307
289
|
</ExampleContainer>
|
|
308
290
|
<ExampleContainer pseudoState="pseudo-active">
|
|
309
291
|
<Title title="Actived" theme="light" level={4} />
|
|
310
|
-
<DxcButton mode="secondary" label="Secondary actived" icon=
|
|
292
|
+
<DxcButton mode="secondary" label="Secondary actived" icon="filled_bottom_app_bar" />
|
|
311
293
|
</ExampleContainer>
|
|
312
294
|
<ExampleContainer>
|
|
313
295
|
<Title title="Disabled" theme="light" level={4} />
|
|
314
296
|
<HalstackProvider theme={opinionatedTheme}>
|
|
315
|
-
<DxcButton mode="secondary" label="Secondary" icon=
|
|
297
|
+
<DxcButton mode="secondary" label="Secondary" icon="filled_bottom_app_bar" disabled />
|
|
316
298
|
</HalstackProvider>
|
|
317
299
|
</ExampleContainer>
|
|
318
300
|
<Title title="Text" theme="light" level={3} />
|
|
319
301
|
<ExampleContainer>
|
|
320
302
|
<Title title="Enabled" theme="light" level={4} />
|
|
321
303
|
<HalstackProvider theme={opinionatedTheme}>
|
|
322
|
-
<DxcButton mode="text" label="Text" icon=
|
|
304
|
+
<DxcButton mode="text" label="Text" icon="filled_bottom_app_bar" />
|
|
323
305
|
</HalstackProvider>
|
|
324
306
|
</ExampleContainer>
|
|
325
307
|
<ExampleContainer pseudoState="pseudo-hover">
|
|
326
308
|
<Title title="Hovered" theme="light" level={4} />
|
|
327
|
-
<DxcButton mode="text" label="Text hovered" icon=
|
|
309
|
+
<DxcButton mode="text" label="Text hovered" icon="filled_bottom_app_bar" />
|
|
328
310
|
</ExampleContainer>
|
|
329
311
|
<ExampleContainer pseudoState="pseudo-focus">
|
|
330
312
|
<Title title="Focused" theme="light" level={4} />
|
|
331
|
-
<DxcButton mode="text" label="Text focused" icon=
|
|
313
|
+
<DxcButton mode="text" label="Text focused" icon="filled_bottom_app_bar" />
|
|
332
314
|
</ExampleContainer>
|
|
333
315
|
<ExampleContainer pseudoState="pseudo-active">
|
|
334
316
|
<Title title="Actived" theme="light" level={4} />
|
|
335
|
-
<DxcButton mode="text" label="Text actived" icon=
|
|
317
|
+
<DxcButton mode="text" label="Text actived" icon="filled_bottom_app_bar" />
|
|
336
318
|
</ExampleContainer>
|
|
337
319
|
<ExampleContainer>
|
|
338
320
|
<Title title="Disabled" theme="light" level={4} />
|
|
339
321
|
<HalstackProvider theme={opinionatedTheme}>
|
|
340
|
-
<DxcButton mode="text" label="Text disabled" icon=
|
|
322
|
+
<DxcButton mode="text" label="Text disabled" icon="filled_bottom_app_bar" disabled />
|
|
341
323
|
</HalstackProvider>
|
|
342
324
|
</ExampleContainer>
|
|
343
325
|
</>
|
package/button/Button.test.js
CHANGED
|
@@ -26,11 +26,13 @@ describe("Button component tests", function () {
|
|
|
26
26
|
test("Renders with correct accessibility attributes", function () {
|
|
27
27
|
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
28
28
|
label: "Home",
|
|
29
|
-
title: "Go home"
|
|
29
|
+
title: "Go home",
|
|
30
|
+
tabIndex: 1
|
|
30
31
|
})),
|
|
31
32
|
getByRole = _render3.getByRole;
|
|
32
33
|
var button = getByRole("button");
|
|
33
34
|
expect(button.getAttribute("aria-label")).toBe("Go home");
|
|
34
35
|
expect(button.getAttribute("title")).toBe("Go home");
|
|
36
|
+
expect(button.getAttribute("tabindex")).toBe("1");
|
|
35
37
|
});
|
|
36
38
|
});
|
package/button/types.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ type Props = {
|
|
|
33
33
|
*/
|
|
34
34
|
type?: "button" | "reset" | "submit";
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* Material Symbol name or SVG element as the icon that will be placed next to the label.
|
|
37
37
|
*/
|
|
38
38
|
icon?: string | SVG;
|
|
39
39
|
/**
|
package/common/coreTokens.js
CHANGED
|
@@ -9,7 +9,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
9
9
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
10
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
11
|
/**
|
|
12
|
-
* Halstack Color Palette
|
|
12
|
+
* Halstack Color Palette
|
|
13
13
|
* @link https://developer.dxc.com/halstack/next/principles/color/#color-tokens-core-color-tokens
|
|
14
14
|
*/
|
|
15
15
|
var CoreColorTokens = {
|
|
@@ -112,7 +112,7 @@ var getCoreColorToken = exports.getCoreColorToken = function getCoreColorToken(k
|
|
|
112
112
|
return CoreColorTokens[key];
|
|
113
113
|
};
|
|
114
114
|
/**
|
|
115
|
-
* Halstack Spacing Principles
|
|
115
|
+
* Halstack Spacing Principles
|
|
116
116
|
* @link https://developer.dxc.com/halstack/next/principles/spacing/
|
|
117
117
|
*/
|
|
118
118
|
var SpacingTokens = {
|