@dxc-technology/halstack-react 8.0.0 → 9.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/HalstackContext.js +94 -45
- package/accordion/Accordion.js +7 -13
- package/accordion/Accordion.stories.tsx +102 -13
- package/alert/Alert.stories.tsx +28 -0
- package/box/Box.js +1 -3
- package/box/Box.stories.tsx +15 -0
- package/button/Button.js +11 -13
- package/button/Button.stories.tsx +150 -8
- package/checkbox/Checkbox.stories.tsx +52 -0
- package/chip/Chip.js +16 -22
- package/chip/Chip.stories.tsx +96 -9
- package/common/variables.js +280 -288
- package/date-input/Calendar.d.ts +1 -1
- package/date-input/Calendar.js +43 -43
- package/date-input/DateInput.js +74 -32
- package/date-input/DateInput.stories.tsx +183 -30
- package/date-input/DateInput.test.js +120 -37
- package/date-input/DatePicker.js +38 -52
- package/date-input/Icons.d.ts +6 -0
- package/date-input/Icons.js +75 -0
- package/date-input/YearPicker.d.ts +1 -1
- package/date-input/YearPicker.js +23 -12
- package/date-input/types.d.ts +6 -8
- package/dialog/Dialog.js +60 -73
- package/dialog/Dialog.stories.tsx +211 -159
- package/dialog/Dialog.test.js +301 -2
- package/dropdown/Dropdown.js +3 -6
- package/dropdown/Dropdown.stories.tsx +210 -84
- package/dropdown/DropdownMenu.js +8 -18
- package/dropdown/DropdownMenuItem.js +4 -15
- package/file-input/FileInput.js +3 -6
- package/file-input/FileInput.stories.tsx +85 -2
- package/file-input/FileInput.test.js +0 -41
- package/file-input/FileItem.js +1 -0
- package/footer/Footer.stories.tsx +91 -0
- package/header/Header.js +18 -20
- package/header/Header.stories.tsx +149 -6
- package/link/Link.stories.tsx +60 -0
- package/main.d.ts +1 -1
- package/main.js +1 -1
- package/{tabs-nav → nav-tabs}/NavTabs.js +1 -1
- package/{tabs-nav → nav-tabs}/NavTabs.stories.tsx +96 -6
- package/{tabs-nav → nav-tabs}/Tab.js +35 -15
- package/package.json +1 -1
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +16 -28
- package/paginator/Paginator.js +5 -11
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +17 -10
- package/progress-bar/ProgressBar.js +4 -4
- package/progress-bar/ProgressBar.stories.jsx +35 -2
- package/quick-nav/QuickNav.stories.tsx +14 -0
- package/radio-group/RadioGroup.stories.tsx +131 -18
- package/resultsetTable/ResultsetTable.test.js +17 -22
- package/select/Listbox.d.ts +1 -1
- package/select/Listbox.js +5 -34
- package/select/Option.js +11 -24
- package/select/Select.js +43 -24
- package/select/Select.stories.tsx +492 -145
- package/select/Select.test.js +17 -22
- package/select/types.d.ts +2 -2
- package/sidenav/Sidenav.js +8 -10
- package/sidenav/Sidenav.stories.tsx +148 -46
- package/slider/Slider.js +4 -4
- package/slider/Slider.stories.tsx +57 -0
- package/spinner/Spinner.js +2 -2
- package/spinner/Spinner.stories.jsx +27 -1
- package/switch/Switch.js +1 -1
- package/switch/Switch.stories.tsx +33 -0
- package/table/Table.stories.jsx +80 -1
- package/tabs/Tab.js +3 -5
- package/tabs/Tabs.js +3 -3
- package/tabs/Tabs.stories.tsx +45 -5
- package/tag/Tag.stories.tsx +14 -1
- package/text-input/Suggestion.js +32 -5
- package/text-input/TextInput.js +7 -11
- package/text-input/TextInput.stories.tsx +92 -4
- package/text-input/TextInput.test.js +125 -25
- package/textarea/Textarea.stories.jsx +60 -1
- package/toggle-group/ToggleGroup.stories.tsx +42 -0
- package/utils/FocusLock.d.ts +13 -0
- package/utils/FocusLock.js +139 -0
- package/wizard/Wizard.stories.tsx +20 -0
- /package/{tabs-nav → nav-tabs}/NavTabs.d.ts +0 -0
- /package/{tabs-nav → nav-tabs}/NavTabs.test.js +0 -0
- /package/{tabs-nav → nav-tabs}/Tab.d.ts +0 -0
- /package/{tabs-nav → nav-tabs}/types.d.ts +0 -0
- /package/{tabs-nav → nav-tabs}/types.js +0 -0
package/alert/Alert.stories.tsx
CHANGED
|
@@ -2,12 +2,21 @@ import React from "react";
|
|
|
2
2
|
import DxcAlert from "./Alert";
|
|
3
3
|
import Title from "../../.storybook/components/Title";
|
|
4
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
|
+
import { HalstackProvider } from "../HalstackContext";
|
|
5
6
|
|
|
6
7
|
export default {
|
|
7
8
|
title: "Alert",
|
|
8
9
|
component: DxcAlert,
|
|
9
10
|
};
|
|
10
11
|
|
|
12
|
+
const opinionatedTheme = {
|
|
13
|
+
alert: {
|
|
14
|
+
baseColor: "#e6f4ff",
|
|
15
|
+
accentColor: "#0067b3",
|
|
16
|
+
overlayColor: "#000000b3",
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
11
20
|
export const Chromatic = () => (
|
|
12
21
|
<>
|
|
13
22
|
<ExampleContainer>
|
|
@@ -155,6 +164,12 @@ export const Chromatic = () => (
|
|
|
155
164
|
</div>
|
|
156
165
|
</DxcAlert>
|
|
157
166
|
</ExampleContainer>
|
|
167
|
+
<Title title="Opinionated theme" theme="light" level={2} />
|
|
168
|
+
<ExampleContainer>
|
|
169
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
170
|
+
<DxcAlert inlineText="Info type alert with inline text." />
|
|
171
|
+
</HalstackProvider>
|
|
172
|
+
</ExampleContainer>
|
|
158
173
|
</>
|
|
159
174
|
);
|
|
160
175
|
|
|
@@ -168,3 +183,16 @@ export const ModalAlert = () => (
|
|
|
168
183
|
</DxcAlert>
|
|
169
184
|
</ExampleContainer>
|
|
170
185
|
);
|
|
186
|
+
|
|
187
|
+
export const ModalAlertOpinionated = () => (
|
|
188
|
+
<ExampleContainer>
|
|
189
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
190
|
+
<DxcAlert inlineText="Modal alert." mode="modal" onClose={() => {}}>
|
|
191
|
+
<div>
|
|
192
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo
|
|
193
|
+
lobortis eget.
|
|
194
|
+
</div>
|
|
195
|
+
</DxcAlert>
|
|
196
|
+
</HalstackProvider>
|
|
197
|
+
</ExampleContainer>
|
|
198
|
+
);
|
package/box/Box.js
CHANGED
|
@@ -71,7 +71,7 @@ var calculateWidth = function calculateWidth(margin, size, padding) {
|
|
|
71
71
|
return sizes[size];
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
-
var StyledDxcBox = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: ", ";\n border-radius: ", ";\n border-width: ", ";\n border-style: ", ";\n border-color: ", ";\n
|
|
74
|
+
var StyledDxcBox = _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\n padding: ", ";\n padding-top: ", ";\n padding-right: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n"])), function (props) {
|
|
75
75
|
return props.display;
|
|
76
76
|
}, function (props) {
|
|
77
77
|
return props.theme.borderRadius;
|
|
@@ -81,8 +81,6 @@ var StyledDxcBox = _styledComponents["default"].div(_templateObject || (_templat
|
|
|
81
81
|
return props.theme.borderStyle;
|
|
82
82
|
}, function (props) {
|
|
83
83
|
return props.theme.borderColor;
|
|
84
|
-
}, function (props) {
|
|
85
|
-
return props.theme.letterSpacing;
|
|
86
84
|
}, function (props) {
|
|
87
85
|
return calculateWidth(props.margin, props.size, props.padding);
|
|
88
86
|
}, function (props) {
|
package/box/Box.stories.tsx
CHANGED
|
@@ -2,12 +2,19 @@ import React from "react";
|
|
|
2
2
|
import Title from "../../.storybook/components/Title";
|
|
3
3
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
4
4
|
import DxcBox from "./Box";
|
|
5
|
+
import { HalstackProvider } from "../HalstackContext";
|
|
5
6
|
|
|
6
7
|
export default {
|
|
7
8
|
title: "Box ",
|
|
8
9
|
component: DxcBox,
|
|
9
10
|
};
|
|
10
11
|
|
|
12
|
+
const opinionatedTheme = {
|
|
13
|
+
box: {
|
|
14
|
+
baseColor: "#ffffff",
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
11
18
|
export const Chromatic = () => (
|
|
12
19
|
<>
|
|
13
20
|
<Title title="Display flex" theme="light" level={2} />
|
|
@@ -128,5 +135,13 @@ export const Chromatic = () => (
|
|
|
128
135
|
<Title title="FitContent" theme="light" level={4} />
|
|
129
136
|
<DxcBox size="fitContent">Box</DxcBox>
|
|
130
137
|
</ExampleContainer>
|
|
138
|
+
<Title title="Opinionated theme" theme="light" level={2} />
|
|
139
|
+
<ExampleContainer>
|
|
140
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
141
|
+
<DxcBox display="flex" padding="medium">
|
|
142
|
+
Box
|
|
143
|
+
</DxcBox>
|
|
144
|
+
</HalstackProvider>
|
|
145
|
+
</ExampleContainer>
|
|
131
146
|
</>
|
|
132
147
|
);
|
package/button/Button.js
CHANGED
|
@@ -25,7 +25,7 @@ var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
|
25
25
|
|
|
26
26
|
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
27
27
|
|
|
28
|
-
var _templateObject, _templateObject2, _templateObject3
|
|
28
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
29
29
|
|
|
30
30
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
31
|
|
|
@@ -69,12 +69,6 @@ var DxcButton = function DxcButton(_ref) {
|
|
|
69
69
|
|
|
70
70
|
var colorsTheme = (0, _useTheme["default"])();
|
|
71
71
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
72
|
-
|
|
73
|
-
var labelComponent = /*#__PURE__*/_react["default"].createElement(LabelContainer, {
|
|
74
|
-
icon: icon,
|
|
75
|
-
iconPosition: iconPosition
|
|
76
|
-
}, label);
|
|
77
|
-
|
|
78
72
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
79
73
|
theme: colorsTheme.button
|
|
80
74
|
}, /*#__PURE__*/_react["default"].createElement(Button, {
|
|
@@ -89,12 +83,18 @@ var DxcButton = function DxcButton(_ref) {
|
|
|
89
83
|
onClick: function onClick() {
|
|
90
84
|
_onClick();
|
|
91
85
|
}
|
|
92
|
-
}, label && iconPosition === "after" &&
|
|
86
|
+
}, label && iconPosition === "after" && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
|
|
87
|
+
icon: icon,
|
|
88
|
+
iconPosition: iconPosition
|
|
89
|
+
}, label), icon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
93
90
|
label: label,
|
|
94
91
|
iconPosition: iconPosition
|
|
95
|
-
}, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement(
|
|
92
|
+
}, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
96
93
|
src: icon
|
|
97
|
-
}) : icon), label && iconPosition === "before" &&
|
|
94
|
+
}) : icon), label && iconPosition === "before" && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
|
|
95
|
+
icon: icon,
|
|
96
|
+
iconPosition: iconPosition
|
|
97
|
+
}, label)));
|
|
98
98
|
};
|
|
99
99
|
|
|
100
100
|
var Button = _styledComponents["default"].button(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n display: inline-flex;\n width: ", ";\n height: 40px;\n padding-left: ", ";\n padding-right: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n align-items: center;\n justify-content: center;\n box-shadow: 0 0 0 2px transparent;\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n letter-spacing: ", ";\n cursor: pointer;\n &:focus {\n outline: none;\n box-shadow: 0 0 0 2px\n ", ";\n }\n ", "\n"])), function (props) {
|
|
@@ -144,13 +144,11 @@ var LabelContainer = _styledComponents["default"].span(_templateObject2 || (_tem
|
|
|
144
144
|
return !props.icon || props.iconPosition === "after" ? "8px" : "0px";
|
|
145
145
|
});
|
|
146
146
|
|
|
147
|
-
var IconContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n
|
|
147
|
+
var IconContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n margin-left: ", ";\n margin-right: ", ";\n\n img,\n svg {\n height: 24px;\n width: 24px;\n }\n"])), function (props) {
|
|
148
148
|
return !props.label ? "0px" : props.iconPosition === "after" && props.label !== "" && "8px" || "8px";
|
|
149
149
|
}, function (props) {
|
|
150
150
|
return !props.label ? "0px" : props.iconPosition === "before" && props.label !== "" && "8px" || "8px";
|
|
151
151
|
});
|
|
152
152
|
|
|
153
|
-
var ButtonIcon = _styledComponents["default"].img(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])));
|
|
154
|
-
|
|
155
153
|
var _default = DxcButton;
|
|
156
154
|
exports["default"] = _default;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { BackgroundColorProvider } from "../BackgroundColorContext";
|
|
2
3
|
import DxcButton from "./Button";
|
|
3
4
|
import DxcFlex from "./../flex/Flex";
|
|
4
|
-
import { BackgroundColorProvider } from "../BackgroundColorContext";
|
|
5
5
|
import Title from "../../.storybook/components/Title";
|
|
6
6
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
7
7
|
import DarkContainer from "../../.storybook/components/DarkSection";
|
|
8
|
+
import { HalstackProvider } from "../HalstackContext";
|
|
8
9
|
|
|
9
10
|
export default {
|
|
10
11
|
title: "Button",
|
|
@@ -12,11 +13,50 @@ export default {
|
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
const iconSVG = (
|
|
15
|
-
<svg viewBox="0 0 24 24" fill="currentColor">
|
|
16
|
+
<svg width="24px" height="24px" viewBox="0 0 24 24" fill="currentColor">
|
|
16
17
|
<path d="M0 0h24v24H0z" fill="none" />
|
|
17
18
|
<path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z" />
|
|
18
19
|
</svg>
|
|
19
20
|
);
|
|
21
|
+
|
|
22
|
+
const facebookIcon = (
|
|
23
|
+
<svg
|
|
24
|
+
version="1.1"
|
|
25
|
+
id="Capa_1"
|
|
26
|
+
x="0px"
|
|
27
|
+
y="0px"
|
|
28
|
+
width="438.536px"
|
|
29
|
+
height="438.536px"
|
|
30
|
+
viewBox="0 0 438.536 438.536"
|
|
31
|
+
fill="currentColor"
|
|
32
|
+
>
|
|
33
|
+
<g>
|
|
34
|
+
<path
|
|
35
|
+
d="M414.41,24.123C398.333,8.042,378.963,0,356.315,0H82.228C59.58,0,40.21,8.042,24.126,24.123
|
|
36
|
+
C8.045,40.207,0.003,59.576,0.003,82.225v274.084c0,22.647,8.042,42.018,24.123,58.102c16.084,16.084,35.454,24.126,58.102,24.126
|
|
37
|
+
h274.084c22.648,0,42.018-8.042,58.095-24.126c16.084-16.084,24.126-35.454,24.126-58.102V82.225
|
|
38
|
+
C438.532,59.576,430.49,40.204,414.41,24.123z M373.155,225.548h-49.963V406.84h-74.802V225.548H210.99V163.02h37.401v-37.402
|
|
39
|
+
c0-26.838,6.283-47.107,18.843-60.813c12.559-13.706,33.304-20.555,62.242-20.555h49.963v62.526h-31.401
|
|
40
|
+
c-10.663,0-17.467,1.853-20.417,5.568c-2.949,3.711-4.428,10.23-4.428,19.558v31.119h56.534L373.155,225.548z"
|
|
41
|
+
/>
|
|
42
|
+
</g>
|
|
43
|
+
</svg>
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const smallIcon = (
|
|
47
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" height="20" width="20" fill="currentColor">
|
|
48
|
+
<path d="m7.646 18.333-.313-2.625q-.208-.125-.458-.27-.25-.146-.458-.271l-2.438 1.021-2.354-4.063 2.083-1.583V9.458L1.625 7.875l2.354-4.063 2.438 1.021q.208-.125.458-.27.25-.146.458-.271l.313-2.625h4.708l.313 2.625q.208.125.458.271.25.145.458.27l2.438-1.021 2.354 4.063-2.063 1.583v1.084l2.063 1.583-2.354 4.063-2.438-1.021q-.208.125-.458.271-.25.145-.458.27l-.313 2.625ZM10 12.979q1.229 0 2.104-.875T12.979 10q0-1.229-.875-2.104T10 7.021q-1.229 0-2.104.875T7.021 10q0 1.229.875 2.104t2.104.875Zm0-1.75q-.5 0-.865-.364-.364-.365-.364-.865t.364-.865q.365-.364.865-.364t.865.364q.364.365.364.865t-.364.865q-.365.364-.865.364ZM10.021 10Zm-.854 6.583h1.666l.25-2.166q.605-.167 1.167-.5.562-.334 1.021-.792l2.021.854.833-1.375-1.771-1.354q.104-.292.146-.604.042-.313.042-.646 0-.292-.042-.594t-.125-.635l1.771-1.375-.834-1.375-2.02.875q-.48-.479-1.032-.802-.552-.323-1.156-.49l-.271-2.187H9.167l-.271 2.187q-.604.167-1.156.49-.552.323-1.011.781l-2.021-.854-.833 1.375 1.75 1.354q-.083.333-.125.646-.042.312-.042.604t.042.594q.042.302.125.635l-1.75 1.375.833 1.375 2.021-.854q.459.458 1.011.781.552.323 1.156.49Z" />
|
|
49
|
+
</svg>
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const opinionatedTheme = {
|
|
53
|
+
button: {
|
|
54
|
+
baseColor: "#5f249f",
|
|
55
|
+
primaryFontColor: "#ffffff",
|
|
56
|
+
secondaryHoverFontColor: "#ffffff",
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
20
60
|
export const Chromatic = () => (
|
|
21
61
|
<>
|
|
22
62
|
<Title title="Primary" theme="light" level={2} />
|
|
@@ -38,7 +78,7 @@ export const Chromatic = () => (
|
|
|
38
78
|
</ExampleContainer>
|
|
39
79
|
<ExampleContainer>
|
|
40
80
|
<Title title="Disabled" theme="light" level={4} />
|
|
41
|
-
<DxcButton label="Primary disabled" disabled />
|
|
81
|
+
<DxcButton label="Primary disabled" disabled icon={iconSVG} />
|
|
42
82
|
</ExampleContainer>
|
|
43
83
|
<ExampleContainer>
|
|
44
84
|
<Title title="With left icon" theme="light" level={4} />
|
|
@@ -52,6 +92,18 @@ export const Chromatic = () => (
|
|
|
52
92
|
<Title title="Only icon" theme="light" level={4} />
|
|
53
93
|
<DxcButton icon={iconSVG} />
|
|
54
94
|
</ExampleContainer>
|
|
95
|
+
<ExampleContainer>
|
|
96
|
+
<Title title="Big icon (SVG)" theme="light" level={4} />
|
|
97
|
+
<DxcButton icon={facebookIcon} />
|
|
98
|
+
</ExampleContainer>
|
|
99
|
+
<ExampleContainer>
|
|
100
|
+
<Title title="Big icon (image)" theme="light" level={4} />
|
|
101
|
+
<DxcButton icon="https://developer.apple.com/design/human-interface-guidelines/foundations/app-icons/images/icon-and-image-large-icon-settings_2x.png" />
|
|
102
|
+
</ExampleContainer>
|
|
103
|
+
<ExampleContainer>
|
|
104
|
+
<Title title="Small icon" theme="light" level={4} />
|
|
105
|
+
<DxcButton icon={smallIcon} />
|
|
106
|
+
</ExampleContainer>
|
|
55
107
|
<Title title="Secondary" theme="light" level={2} />
|
|
56
108
|
<ExampleContainer>
|
|
57
109
|
<Title title="Enabled" theme="light" level={4} />
|
|
@@ -71,12 +123,19 @@ export const Chromatic = () => (
|
|
|
71
123
|
</ExampleContainer>
|
|
72
124
|
<ExampleContainer>
|
|
73
125
|
<Title title="Disabled" theme="light" level={4} />
|
|
74
|
-
<DxcButton mode="secondary" disabled label="Secondary disabled" />
|
|
126
|
+
<DxcButton mode="secondary" disabled label="Secondary disabled" icon={iconSVG} />
|
|
75
127
|
</ExampleContainer>
|
|
76
128
|
<ExampleContainer>
|
|
77
129
|
<Title title="With icon" theme="light" level={4} />
|
|
78
130
|
<DxcButton mode="secondary" label="Secondary" icon={iconSVG} />
|
|
79
131
|
</ExampleContainer>
|
|
132
|
+
<ExampleContainer>
|
|
133
|
+
<Title title="Only icon (image)" theme="light" level={4} />
|
|
134
|
+
<DxcButton
|
|
135
|
+
mode="secondary"
|
|
136
|
+
icon="https://developer.apple.com/design/human-interface-guidelines/foundations/app-icons/images/icon-and-image-large-icon-settings_2x.png"
|
|
137
|
+
/>
|
|
138
|
+
</ExampleContainer>
|
|
80
139
|
<Title title="Text" theme="light" level={2} />
|
|
81
140
|
<ExampleContainer>
|
|
82
141
|
<Title title="Enabled" theme="light" level={4} />
|
|
@@ -96,12 +155,19 @@ export const Chromatic = () => (
|
|
|
96
155
|
</ExampleContainer>
|
|
97
156
|
<ExampleContainer>
|
|
98
157
|
<Title title="Disabled" theme="light" level={4} />
|
|
99
|
-
<DxcButton mode="text" label="Text disabled" disabled />
|
|
158
|
+
<DxcButton mode="text" label="Text disabled" disabled icon={iconSVG} />
|
|
100
159
|
</ExampleContainer>
|
|
101
160
|
<ExampleContainer>
|
|
102
161
|
<Title title="With icon" theme="light" level={4} />
|
|
103
162
|
<DxcButton label="Text" mode="text" icon={iconSVG} />
|
|
104
163
|
</ExampleContainer>
|
|
164
|
+
<ExampleContainer>
|
|
165
|
+
<Title title="Only icon (image)" theme="light" level={4} />
|
|
166
|
+
<DxcButton
|
|
167
|
+
mode="text"
|
|
168
|
+
icon="https://developer.apple.com/design/human-interface-guidelines/foundations/app-icons/images/icon-and-image-large-icon-settings_2x.png"
|
|
169
|
+
/>
|
|
170
|
+
</ExampleContainer>
|
|
105
171
|
<BackgroundColorProvider color="#333333">
|
|
106
172
|
<DarkContainer>
|
|
107
173
|
<Title title="Primary" theme="dark" level={2} />
|
|
@@ -123,7 +189,7 @@ export const Chromatic = () => (
|
|
|
123
189
|
</ExampleContainer>
|
|
124
190
|
<ExampleContainer>
|
|
125
191
|
<Title title="Disabled" theme="dark" level={4} />
|
|
126
|
-
<DxcButton label="Primary disabled" disabled />
|
|
192
|
+
<DxcButton label="Primary disabled" disabled icon={iconSVG} />
|
|
127
193
|
</ExampleContainer>
|
|
128
194
|
<ExampleContainer>
|
|
129
195
|
<Title title="With icon" theme="dark" level={4} />
|
|
@@ -148,7 +214,7 @@ export const Chromatic = () => (
|
|
|
148
214
|
</ExampleContainer>
|
|
149
215
|
<ExampleContainer>
|
|
150
216
|
<Title title="Disabled" theme="dark" level={4} />
|
|
151
|
-
<DxcButton mode="secondary" disabled label="Secondary disabled" />
|
|
217
|
+
<DxcButton mode="secondary" disabled label="Secondary disabled" icon={iconSVG} />
|
|
152
218
|
</ExampleContainer>
|
|
153
219
|
<ExampleContainer>
|
|
154
220
|
<Title title="With icon" theme="dark" level={4} />
|
|
@@ -173,7 +239,7 @@ export const Chromatic = () => (
|
|
|
173
239
|
</ExampleContainer>
|
|
174
240
|
<ExampleContainer>
|
|
175
241
|
<Title title="Disabled" theme="dark" level={4} />
|
|
176
|
-
<DxcButton mode="text" label="Text disabled" disabled />
|
|
242
|
+
<DxcButton mode="text" label="Text disabled" disabled icon={iconSVG} />
|
|
177
243
|
</ExampleContainer>
|
|
178
244
|
<ExampleContainer>
|
|
179
245
|
<Title title="With icon" theme="dark" level={4} />
|
|
@@ -279,5 +345,81 @@ export const Chromatic = () => (
|
|
|
279
345
|
<DxcButton label="Button" />
|
|
280
346
|
</DxcFlex>
|
|
281
347
|
</ExampleContainer>
|
|
348
|
+
<Title title="Opinionated theme" theme="light" level={2} />
|
|
349
|
+
<Title title="Primary" theme="light" level={3} />
|
|
350
|
+
<ExampleContainer>
|
|
351
|
+
<Title title="Enabled" theme="light" level={4} />
|
|
352
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
353
|
+
<DxcButton label="Primary" icon={iconSVG} />
|
|
354
|
+
</HalstackProvider>
|
|
355
|
+
</ExampleContainer>
|
|
356
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
357
|
+
<Title title="Hovered" theme="light" level={4} />
|
|
358
|
+
<DxcButton label="Primary hovered" icon={iconSVG} />
|
|
359
|
+
</ExampleContainer>
|
|
360
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
361
|
+
<Title title="Focused" theme="light" level={4} />
|
|
362
|
+
<DxcButton label="Primary focused" icon={iconSVG} />
|
|
363
|
+
</ExampleContainer>
|
|
364
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
365
|
+
<Title title="Actived" theme="light" level={4} />
|
|
366
|
+
<DxcButton label="Primary actived" icon={iconSVG} />
|
|
367
|
+
</ExampleContainer>
|
|
368
|
+
<ExampleContainer>
|
|
369
|
+
<Title title="Disabled" theme="light" level={4} />
|
|
370
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
371
|
+
<DxcButton label="Primary" icon={iconSVG} disabled />
|
|
372
|
+
</HalstackProvider>
|
|
373
|
+
</ExampleContainer>
|
|
374
|
+
<Title title="Secondary" theme="light" level={3} />
|
|
375
|
+
<ExampleContainer>
|
|
376
|
+
<Title title="Enabled" theme="light" level={4} />
|
|
377
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
378
|
+
<DxcButton mode="secondary" label="Secondary" icon={iconSVG} />
|
|
379
|
+
</HalstackProvider>
|
|
380
|
+
</ExampleContainer>
|
|
381
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
382
|
+
<Title title="Hovered" theme="light" level={4} />
|
|
383
|
+
<DxcButton mode="secondary" label="Secondary hovered" icon={iconSVG} />
|
|
384
|
+
</ExampleContainer>
|
|
385
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
386
|
+
<Title title="Focused" theme="light" level={4} />
|
|
387
|
+
<DxcButton mode="secondary" label="Secondary focused" icon={iconSVG} />
|
|
388
|
+
</ExampleContainer>
|
|
389
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
390
|
+
<Title title="Actived" theme="light" level={4} />
|
|
391
|
+
<DxcButton mode="secondary" label="Secondary actived" icon={iconSVG} />
|
|
392
|
+
</ExampleContainer>
|
|
393
|
+
<ExampleContainer>
|
|
394
|
+
<Title title="Disabled" theme="light" level={4} />
|
|
395
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
396
|
+
<DxcButton mode="secondary" label="Secondary" icon={iconSVG} disabled />
|
|
397
|
+
</HalstackProvider>
|
|
398
|
+
</ExampleContainer>
|
|
399
|
+
<Title title="Text" theme="light" level={3} />
|
|
400
|
+
<ExampleContainer>
|
|
401
|
+
<Title title="Enabled" theme="light" level={4} />
|
|
402
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
403
|
+
<DxcButton mode="text" label="Text" icon={iconSVG} />
|
|
404
|
+
</HalstackProvider>
|
|
405
|
+
</ExampleContainer>
|
|
406
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
407
|
+
<Title title="Hovered" theme="light" level={4} />
|
|
408
|
+
<DxcButton mode="text" label="Text hovered" icon={iconSVG} />
|
|
409
|
+
</ExampleContainer>
|
|
410
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
411
|
+
<Title title="Focused" theme="light" level={4} />
|
|
412
|
+
<DxcButton mode="text" label="Text focused" icon={iconSVG} />
|
|
413
|
+
</ExampleContainer>
|
|
414
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
415
|
+
<Title title="Actived" theme="light" level={4} />
|
|
416
|
+
<DxcButton mode="text" label="Text actived" icon={iconSVG} />
|
|
417
|
+
</ExampleContainer>
|
|
418
|
+
<ExampleContainer>
|
|
419
|
+
<Title title="Disabled" theme="light" level={4} />
|
|
420
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
421
|
+
<DxcButton mode="text" label="Text disabled" icon={iconSVG} disabled />
|
|
422
|
+
</HalstackProvider>
|
|
423
|
+
</ExampleContainer>
|
|
282
424
|
</>
|
|
283
425
|
);
|
|
@@ -5,12 +5,21 @@ import Title from "../../.storybook/components/Title";
|
|
|
5
5
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
6
6
|
import DarkContainer from "../../.storybook/components/DarkSection";
|
|
7
7
|
import styled from "styled-components";
|
|
8
|
+
import { HalstackProvider } from "../HalstackContext";
|
|
8
9
|
|
|
9
10
|
export default {
|
|
10
11
|
title: "Checkbox",
|
|
11
12
|
component: DxcCheckbox,
|
|
12
13
|
};
|
|
13
14
|
|
|
15
|
+
const opinionatedTheme = {
|
|
16
|
+
checkbox: {
|
|
17
|
+
baseColor: "#0067b3",
|
|
18
|
+
checkColor: "#ffffff",
|
|
19
|
+
fontColor: "#000000",
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
14
23
|
const Checkbox = () => (
|
|
15
24
|
<>
|
|
16
25
|
<ExampleContainer>
|
|
@@ -178,6 +187,49 @@ const Checkbox = () => (
|
|
|
178
187
|
<DxcCheckbox label="Very long label to check its overflowing" labelPosition="after" />
|
|
179
188
|
</SmallContainer>
|
|
180
189
|
</ExampleContainer>
|
|
190
|
+
<Title title="Opinionated theme" theme="light" level={2} />
|
|
191
|
+
<ExampleContainer>
|
|
192
|
+
<Title title="Default" theme="light" level={4} />
|
|
193
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
194
|
+
<DxcCheckbox label="Checkbox" />
|
|
195
|
+
</HalstackProvider>
|
|
196
|
+
</ExampleContainer>
|
|
197
|
+
<ExampleContainer>
|
|
198
|
+
<Title title="Checked" theme="light" level={4} />
|
|
199
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
200
|
+
<DxcCheckbox label="Checkbox" defaultChecked />
|
|
201
|
+
</HalstackProvider>
|
|
202
|
+
</ExampleContainer>
|
|
203
|
+
<ExampleContainer>
|
|
204
|
+
<Title title="Disabled" theme="light" level={4} />
|
|
205
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
206
|
+
<DxcCheckbox label="Checkbox" disabled />
|
|
207
|
+
</HalstackProvider>
|
|
208
|
+
</ExampleContainer>
|
|
209
|
+
<ExampleContainer>
|
|
210
|
+
<Title title="Disabled checked" theme="light" level={4} />
|
|
211
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
212
|
+
<DxcCheckbox label="Checkbox" defaultChecked disabled />
|
|
213
|
+
</HalstackProvider>
|
|
214
|
+
</ExampleContainer>
|
|
215
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
216
|
+
<Title title="Focused" theme="light" level={4} />
|
|
217
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
218
|
+
<DxcCheckbox label="Focused" />
|
|
219
|
+
</HalstackProvider>
|
|
220
|
+
</ExampleContainer>
|
|
221
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
222
|
+
<Title title="Hovered" theme="light" level={4} />
|
|
223
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
224
|
+
<DxcCheckbox label="Hovered" />
|
|
225
|
+
</HalstackProvider>
|
|
226
|
+
</ExampleContainer>
|
|
227
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
228
|
+
<Title title="Hovered and checked" theme="light" level={4} />
|
|
229
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
230
|
+
<DxcCheckbox label="Hovered" defaultChecked />
|
|
231
|
+
</HalstackProvider>
|
|
232
|
+
</ExampleContainer>
|
|
181
233
|
</>
|
|
182
234
|
);
|
|
183
235
|
|
package/chip/Chip.js
CHANGED
|
@@ -23,7 +23,7 @@ var _utils = require("../common/utils.js");
|
|
|
23
23
|
|
|
24
24
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
25
|
|
|
26
|
-
var _templateObject, _templateObject2, _templateObject3
|
|
26
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
27
27
|
|
|
28
28
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
29
|
|
|
@@ -55,7 +55,7 @@ var DxcChip = function DxcChip(_ref) {
|
|
|
55
55
|
return onClickPrefix && !disabled && onClickPrefix();
|
|
56
56
|
},
|
|
57
57
|
interactuable: typeof onClickPrefix === "function" && !disabled
|
|
58
|
-
}, typeof prefixIcon === "string" ? /*#__PURE__*/_react["default"].createElement(
|
|
58
|
+
}, typeof prefixIcon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
59
59
|
src: prefixIcon
|
|
60
60
|
}) : prefixIcon), label && /*#__PURE__*/_react["default"].createElement(ChipTextContainer, {
|
|
61
61
|
disabled: disabled
|
|
@@ -69,21 +69,13 @@ var DxcChip = function DxcChip(_ref) {
|
|
|
69
69
|
return onClickSuffix && !disabled && onClickSuffix();
|
|
70
70
|
},
|
|
71
71
|
interactuable: typeof onClickSuffix === "function" && !disabled
|
|
72
|
-
}, typeof suffixIcon === "string" ? /*#__PURE__*/_react["default"].createElement(
|
|
72
|
+
}, typeof suffixIcon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
73
73
|
src: suffixIcon
|
|
74
74
|
}) : suffixIcon)));
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
var getCursor = function getCursor(interactuable, disabled) {
|
|
78
|
-
if (disabled)
|
|
79
|
-
return "cursor:not-allowed;";
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (interactuable) {
|
|
83
|
-
return "cursor:pointer;";
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return "cursor:default; outline:none;";
|
|
78
|
+
if (disabled) return "cursor: not-allowed;";else if (interactuable) return "cursor: pointer;";else return "cursor: default; outline:none;";
|
|
87
79
|
};
|
|
88
80
|
|
|
89
81
|
var StyledDxcChip = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n align-items: center;\n min-height: 40px;\n max-width: ", ";\n background-color: ", ";\n border-radius: ", ";\n border-width: ", ";\n border-style: ", ";\n border-color: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n padding-right: ", ";\n\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n cursor: ", ";\n"])), function (_ref2) {
|
|
@@ -137,24 +129,26 @@ var ChipTextContainer = _styledComponents["default"].span(_templateObject2 || (_
|
|
|
137
129
|
return disabled && "not-allowed" || "default";
|
|
138
130
|
});
|
|
139
131
|
|
|
140
|
-
var
|
|
141
|
-
|
|
142
|
-
var PrefixIconContainer = _styledComponents["default"].img(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])([""])));
|
|
143
|
-
|
|
144
|
-
var IconContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n ", "\n ", "\n width: ", ";\n height: ", ";\n overflow: hidden;\n\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n &:focus {\n outline-color: ", ";\n outline-width: 2px;\n ", "\n }\n"])), function (props) {
|
|
145
|
-
return props.disabled ? props.theme.disabledIconColor : props.theme.iconColor;
|
|
146
|
-
}, function (props) {
|
|
132
|
+
var IconContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n ", "\n color: ", ";\n ", "\n\n &:hover {\n color: ", ";\n }\n &:focus {\n outline-color: ", ";\n outline-width: ", ";\n ", "\n }\n &:active {\n color: ", ";\n }\n img,\n svg {\n width: ", ";\n height: ", ";\n }\n"])), function (props) {
|
|
147
133
|
return props.prefixIcon ? "margin-right: ".concat((props.label || props.suffixIcon) && props.theme.iconSpacing || props.prefixIcon && "0", ";") : "margin-left: ".concat((props.label || props.prefixIcon) && props.theme.iconSpacing || props.prefixIcon && "0", ";");
|
|
134
|
+
}, function (props) {
|
|
135
|
+
return props.disabled ? props.theme.disabledIconColor : props.theme.iconColor;
|
|
148
136
|
}, function (props) {
|
|
149
137
|
return getCursor(props.interactuable, props.disabled);
|
|
150
138
|
}, function (props) {
|
|
151
|
-
return props.theme.
|
|
139
|
+
return !props.disabled && props.theme.hoverIconColor;
|
|
152
140
|
}, function (props) {
|
|
153
|
-
return props.theme.
|
|
141
|
+
return !props.disabled && props.theme.focusColor;
|
|
154
142
|
}, function (props) {
|
|
155
|
-
return props.theme.
|
|
143
|
+
return !props.disabled && props.theme.focusBorderThickness;
|
|
156
144
|
}, function (props) {
|
|
157
145
|
return props.disabled && "outline: none;";
|
|
146
|
+
}, function (props) {
|
|
147
|
+
return !props.disabled && props.theme.activeIconColor;
|
|
148
|
+
}, function (props) {
|
|
149
|
+
return props.theme.iconSize;
|
|
150
|
+
}, function (props) {
|
|
151
|
+
return props.theme.iconSize;
|
|
158
152
|
});
|
|
159
153
|
|
|
160
154
|
var _default = DxcChip;
|