@dxc-technology/halstack-react 0.0.0-e1a279c → 0.0.0-e201636
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 +10 -0
- package/BackgroundColorContext.js +1 -4
- package/HalstackContext.d.ts +12 -0
- package/HalstackContext.js +295 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +15 -47
- package/accordion/Accordion.stories.tsx +307 -0
- package/accordion/Accordion.test.js +72 -0
- package/accordion/types.d.ts +8 -8
- package/accordion-group/AccordionGroup.d.ts +1 -1
- package/accordion-group/AccordionGroup.js +15 -17
- package/accordion-group/AccordionGroup.stories.tsx +225 -0
- package/accordion-group/AccordionGroup.test.js +151 -0
- package/accordion-group/types.d.ts +8 -8
- package/alert/Alert.js +6 -3
- package/alert/Alert.test.js +92 -0
- package/alert/types.d.ts +1 -1
- package/badge/Badge.d.ts +4 -0
- package/badge/Badge.js +6 -4
- package/badge/types.d.ts +5 -0
- package/{radio → badge}/types.js +0 -0
- package/bleed/Bleed.d.ts +3 -0
- package/bleed/Bleed.js +84 -0
- package/bleed/Bleed.stories.tsx +342 -0
- package/bleed/types.d.ts +37 -0
- package/bleed/types.js +5 -0
- package/box/Box.d.ts +1 -1
- package/box/Box.js +26 -39
- package/box/Box.test.js +18 -0
- package/box/types.d.ts +0 -4
- package/button/Button.d.ts +1 -1
- package/button/Button.js +24 -27
- package/button/Button.stories.tsx +6 -8
- package/button/Button.test.js +35 -0
- package/button/types.d.ts +5 -9
- package/card/Card.js +32 -34
- package/card/Card.stories.tsx +201 -0
- package/card/Card.test.js +50 -0
- package/card/ice-cream.jpg +0 -0
- package/card/types.d.ts +4 -6
- package/checkbox/Checkbox.d.ts +1 -1
- package/checkbox/Checkbox.js +45 -41
- package/checkbox/Checkbox.stories.tsx +124 -128
- package/checkbox/Checkbox.test.js +78 -0
- package/checkbox/types.d.ts +9 -5
- package/chip/Chip.d.ts +4 -0
- package/chip/Chip.js +16 -76
- package/chip/Chip.stories.tsx +6 -8
- package/chip/Chip.test.js +56 -0
- package/chip/types.d.ts +45 -0
- package/chip/types.js +5 -0
- package/common/variables.js +234 -341
- package/date-input/DateInput.js +63 -52
- package/date-input/DateInput.stories.tsx +7 -7
- package/date-input/DateInput.test.js +479 -0
- package/date-input/types.d.ts +16 -9
- package/dialog/Dialog.js +8 -35
- package/dialog/Dialog.test.js +40 -0
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +22 -48
- package/dropdown/Dropdown.stories.tsx +249 -0
- package/dropdown/Dropdown.test.js +189 -0
- package/dropdown/types.d.ts +6 -15
- package/file-input/FileInput.d.ts +4 -0
- package/file-input/FileInput.js +172 -111
- package/file-input/FileInput.stories.tsx +507 -0
- package/file-input/FileInput.test.js +457 -0
- package/file-input/FileItem.d.ts +14 -0
- package/file-input/FileItem.js +16 -23
- package/file-input/types.d.ts +112 -0
- package/file-input/types.js +5 -0
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +32 -113
- package/footer/{Footer.stories.jsx → Footer.stories.tsx} +1 -22
- package/footer/Footer.test.js +109 -0
- package/footer/Icons.d.ts +2 -0
- package/footer/Icons.js +3 -3
- package/footer/types.d.ts +22 -18
- package/header/Header.js +29 -50
- package/header/Header.stories.tsx +172 -0
- package/header/Header.test.js +79 -0
- package/header/Icons.d.ts +2 -0
- package/header/types.d.ts +4 -2
- package/heading/Heading.d.ts +4 -0
- package/heading/Heading.js +7 -24
- package/heading/Heading.stories.tsx +54 -0
- package/heading/Heading.test.js +186 -0
- package/heading/types.d.ts +33 -0
- package/heading/types.js +5 -0
- package/inset/Inset.d.ts +3 -0
- package/inset/Inset.js +84 -0
- package/inset/Inset.stories.tsx +229 -0
- package/inset/types.d.ts +37 -0
- package/inset/types.js +5 -0
- package/layout/ApplicationLayout.d.ts +11 -0
- package/layout/ApplicationLayout.js +84 -120
- package/layout/ApplicationLayout.stories.tsx +126 -0
- package/layout/Icons.d.ts +5 -0
- package/layout/Icons.js +13 -2
- package/layout/SidenavContext.d.ts +5 -0
- package/layout/SidenavContext.js +19 -0
- package/layout/types.d.ts +52 -0
- package/layout/types.js +5 -0
- package/link/Link.d.ts +3 -2
- package/link/Link.js +61 -86
- package/link/Link.stories.tsx +131 -15
- package/link/Link.test.js +83 -0
- package/link/types.d.ts +9 -29
- package/list/List.d.ts +4 -0
- package/list/List.js +47 -0
- package/list/List.stories.tsx +95 -0
- package/list/types.d.ts +7 -0
- package/list/types.js +5 -0
- package/main.d.ts +12 -9
- package/main.js +72 -42
- package/number-input/NumberInput.js +14 -24
- package/number-input/NumberInput.stories.tsx +5 -5
- package/number-input/NumberInput.test.js +506 -0
- package/number-input/NumberInputContext.d.ts +4 -0
- package/number-input/NumberInputContext.js +5 -2
- package/number-input/numberInputContextTypes.d.ts +19 -0
- package/number-input/numberInputContextTypes.js +5 -0
- package/number-input/types.d.ts +17 -10
- package/package.json +9 -6
- package/paginator/Paginator.js +19 -46
- package/paginator/Paginator.test.js +266 -0
- package/password-input/PasswordInput.js +23 -19
- package/password-input/PasswordInput.stories.tsx +3 -3
- package/password-input/PasswordInput.test.js +180 -0
- package/password-input/types.d.ts +29 -19
- package/progress-bar/ProgressBar.js +5 -5
- package/progress-bar/ProgressBar.stories.jsx +11 -11
- package/progress-bar/ProgressBar.test.js +65 -0
- package/quick-nav/QuickNav.d.ts +4 -0
- package/quick-nav/QuickNav.js +112 -0
- package/quick-nav/QuickNav.stories.tsx +237 -0
- package/quick-nav/types.d.ts +21 -0
- package/quick-nav/types.js +5 -0
- package/radio-group/Radio.d.ts +4 -0
- package/radio-group/Radio.js +141 -0
- package/radio-group/RadioGroup.d.ts +4 -0
- package/radio-group/RadioGroup.js +282 -0
- package/radio-group/RadioGroup.stories.tsx +100 -0
- package/radio-group/RadioGroup.test.js +695 -0
- package/radio-group/types.d.ts +114 -0
- package/radio-group/types.js +5 -0
- package/resultsetTable/ResultsetTable.d.ts +4 -0
- package/resultsetTable/ResultsetTable.js +9 -29
- package/resultsetTable/ResultsetTable.stories.tsx +275 -0
- package/resultsetTable/ResultsetTable.test.js +306 -0
- package/resultsetTable/types.d.ts +67 -0
- package/resultsetTable/types.js +5 -0
- package/row/Row.d.ts +3 -0
- package/row/Row.js +127 -0
- package/row/Row.stories.tsx +237 -0
- package/row/types.d.ts +28 -0
- package/row/types.js +5 -0
- package/select/Icons.d.ts +10 -0
- package/select/Icons.js +93 -0
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +152 -0
- package/select/Option.d.ts +4 -0
- package/select/Option.js +110 -0
- package/select/Select.d.ts +4 -0
- package/select/Select.js +122 -342
- package/select/Select.stories.tsx +103 -81
- package/select/Select.test.js +2120 -0
- package/select/types.d.ts +213 -0
- package/select/types.js +5 -0
- package/sidenav/Sidenav.d.ts +1 -1
- package/sidenav/Sidenav.js +22 -11
- package/sidenav/Sidenav.stories.tsx +182 -0
- package/sidenav/Sidenav.test.js +56 -0
- package/slider/Slider.d.ts +1 -1
- package/slider/Slider.js +6 -5
- package/slider/Slider.stories.tsx +8 -8
- package/slider/Slider.test.js +150 -0
- package/slider/types.d.ts +4 -0
- package/spinner/Spinner.js +3 -3
- package/spinner/Spinner.stories.jsx +1 -0
- package/spinner/Spinner.test.js +64 -0
- package/stack/Stack.d.ts +3 -0
- package/stack/Stack.js +97 -0
- package/stack/Stack.stories.tsx +164 -0
- package/stack/types.d.ts +24 -0
- package/stack/types.js +5 -0
- package/switch/Switch.d.ts +1 -1
- package/switch/Switch.js +37 -21
- package/switch/Switch.stories.tsx +15 -15
- package/switch/Switch.test.js +98 -0
- package/switch/types.d.ts +6 -2
- package/table/Table.js +3 -3
- package/table/Table.stories.jsx +2 -1
- package/table/Table.test.js +26 -0
- package/tabs/Tabs.d.ts +1 -1
- package/tabs/Tabs.js +20 -20
- package/tabs/Tabs.stories.tsx +112 -0
- package/tabs/Tabs.test.js +140 -0
- package/tabs/types.d.ts +29 -18
- package/tabs-nav/NavTabs.d.ts +8 -0
- package/tabs-nav/NavTabs.js +125 -0
- package/tabs-nav/NavTabs.stories.tsx +170 -0
- package/tabs-nav/NavTabs.test.js +82 -0
- package/tabs-nav/Tab.d.ts +4 -0
- package/tabs-nav/Tab.js +132 -0
- package/tabs-nav/types.d.ts +53 -0
- package/tabs-nav/types.js +5 -0
- package/tag/Tag.d.ts +1 -1
- package/tag/Tag.js +18 -28
- package/tag/Tag.stories.tsx +26 -29
- package/tag/Tag.test.js +60 -0
- package/tag/types.d.ts +23 -14
- package/text/Text.d.ts +7 -0
- package/text/Text.js +30 -0
- package/text/Text.stories.tsx +19 -0
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +55 -0
- package/text-input/TextInput.d.ts +4 -0
- package/text-input/TextInput.js +91 -146
- package/text-input/TextInput.stories.tsx +474 -0
- package/text-input/TextInput.test.js +1712 -0
- package/text-input/types.d.ts +178 -0
- package/text-input/types.js +5 -0
- package/textarea/Textarea.d.ts +4 -0
- package/textarea/Textarea.js +39 -79
- package/textarea/Textarea.stories.jsx +37 -15
- package/textarea/Textarea.test.js +437 -0
- package/textarea/types.d.ts +137 -0
- package/textarea/types.js +5 -0
- package/toggle-group/ToggleGroup.d.ts +4 -0
- package/toggle-group/ToggleGroup.js +18 -46
- package/toggle-group/ToggleGroup.stories.tsx +27 -32
- package/toggle-group/ToggleGroup.test.js +156 -0
- package/toggle-group/types.d.ts +105 -0
- package/toggle-group/types.js +5 -0
- package/useTheme.d.ts +2 -0
- package/useTheme.js +2 -2
- package/useTranslatedLabels.d.ts +2 -0
- package/useTranslatedLabels.js +20 -0
- package/wizard/Wizard.d.ts +1 -1
- package/wizard/Wizard.js +107 -46
- package/wizard/{Wizard.stories.jsx → Wizard.stories.tsx} +13 -23
- package/wizard/Wizard.test.js +141 -0
- package/wizard/types.d.ts +9 -9
- package/ThemeContext.js +0 -246
- package/V3Select/V3Select.js +0 -455
- package/V3Select/index.d.ts +0 -27
- package/V3Textarea/V3Textarea.js +0 -260
- package/V3Textarea/index.d.ts +0 -27
- package/chip/index.d.ts +0 -22
- package/date/Date.js +0 -373
- package/date/index.d.ts +0 -27
- package/file-input/index.d.ts +0 -81
- package/heading/index.d.ts +0 -17
- package/input-text/Icons.js +0 -22
- package/input-text/InputText.js +0 -611
- package/input-text/index.d.ts +0 -36
- package/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -174
- package/radio/Radio.stories.tsx +0 -192
- package/radio/types.d.ts +0 -54
- package/resultsetTable/index.d.ts +0 -19
- package/select/index.d.ts +0 -131
- package/text-input/index.d.ts +0 -135
- package/textarea/index.d.ts +0 -117
- package/toggle/Toggle.js +0 -186
- package/toggle/index.d.ts +0 -21
- package/toggle-group/index.d.ts +0 -21
- package/upload/Upload.js +0 -201
- package/upload/buttons-upload/ButtonsUpload.js +0 -111
- package/upload/buttons-upload/Icons.js +0 -40
- package/upload/dragAndDropArea/DragAndDropArea.js +0 -225
- package/upload/dragAndDropArea/Icons.js +0 -39
- package/upload/file-upload/FileToUpload.js +0 -115
- package/upload/file-upload/Icons.js +0 -66
- package/upload/files-upload/FilesToUpload.js +0 -109
- package/upload/index.d.ts +0 -15
- package/upload/transaction/Icons.js +0 -160
- package/upload/transaction/Transaction.js +0 -104
- package/upload/transactions/Transactions.js +0 -94
- package/wizard/Icons.js +0 -65
package/button/Button.js
CHANGED
|
@@ -9,10 +9,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports["default"] = void 0;
|
|
11
11
|
|
|
12
|
-
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
|
-
|
|
14
12
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
15
13
|
|
|
14
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
15
|
+
|
|
16
16
|
var _react = _interopRequireWildcard(require("react"));
|
|
17
17
|
|
|
18
18
|
var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
|
|
@@ -23,9 +23,9 @@ var _variables = require("../common/variables.js");
|
|
|
23
23
|
|
|
24
24
|
var _utils = require("../common/utils.js");
|
|
25
25
|
|
|
26
|
-
var _useTheme = _interopRequireDefault(require("../useTheme
|
|
26
|
+
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
27
27
|
|
|
28
|
-
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext
|
|
28
|
+
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
29
29
|
|
|
30
30
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
31
31
|
|
|
@@ -45,16 +45,22 @@ var DxcButton = function DxcButton(_ref) {
|
|
|
45
45
|
_ref$type = _ref.type,
|
|
46
46
|
type = _ref$type === void 0 ? "button" : _ref$type,
|
|
47
47
|
icon = _ref.icon,
|
|
48
|
-
_ref$
|
|
49
|
-
|
|
50
|
-
onClick = _ref.onClick,
|
|
48
|
+
_ref$onClick = _ref.onClick,
|
|
49
|
+
_onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick,
|
|
51
50
|
margin = _ref.margin,
|
|
52
51
|
_ref$size = _ref.size,
|
|
53
52
|
size = _ref$size === void 0 ? "fitContent" : _ref$size,
|
|
54
53
|
_ref$tabIndex = _ref.tabIndex,
|
|
55
54
|
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
55
|
+
|
|
56
56
|
var colorsTheme = (0, _useTheme["default"])();
|
|
57
57
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
58
|
+
|
|
59
|
+
var labelComponent = /*#__PURE__*/_react["default"].createElement(LabelContainer, {
|
|
60
|
+
icon: icon,
|
|
61
|
+
iconPosition: iconPosition
|
|
62
|
+
}, label);
|
|
63
|
+
|
|
58
64
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
59
65
|
theme: colorsTheme.button
|
|
60
66
|
}, /*#__PURE__*/_react["default"].createElement(DxCButton, {
|
|
@@ -72,18 +78,15 @@ var DxcButton = function DxcButton(_ref) {
|
|
|
72
78
|
disableRipple: true,
|
|
73
79
|
"aria-disabled": disabled,
|
|
74
80
|
tabIndex: disabled ? -1 : tabIndex,
|
|
75
|
-
onClick: onClick
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}, label), icon ? /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
81
|
+
onClick: function onClick() {
|
|
82
|
+
_onClick();
|
|
83
|
+
}
|
|
84
|
+
}, label && iconPosition === "after" && labelComponent, icon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
80
85
|
label: label,
|
|
81
86
|
iconPosition: iconPosition
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
src: iconSrc
|
|
86
|
-
}))));
|
|
87
|
+
}, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement(ButtonIcon, {
|
|
88
|
+
src: icon
|
|
89
|
+
}) : icon), label && iconPosition === "before" && labelComponent)));
|
|
87
90
|
};
|
|
88
91
|
|
|
89
92
|
var sizes = {
|
|
@@ -118,13 +121,9 @@ var IconContainer = _styledComponents["default"].div(_templateObject2 || (_templ
|
|
|
118
121
|
return !props.label ? "0px" : props.iconPosition === "before" && props.label !== "" && "8px" || "8px";
|
|
119
122
|
});
|
|
120
123
|
|
|
121
|
-
var ButtonIcon = _styledComponents["default"].img(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["
|
|
122
|
-
return props.iconPosition === "after" && props.label !== "" && "10px" || "0px";
|
|
123
|
-
}, function (props) {
|
|
124
|
-
return props.iconPosition === "before" && props.label !== "" && "10px" || "0px";
|
|
125
|
-
});
|
|
124
|
+
var ButtonIcon = _styledComponents["default"].img(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])([""])));
|
|
126
125
|
|
|
127
|
-
var DxCButton = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n display: inline-block;\n width: ", ";\n cursor: ", ";\n\n .MuiButtonBase-root {\n padding-left: ", ";\n padding-right: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n\n .MuiButton-label {\n display: flex;\n
|
|
126
|
+
var DxCButton = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n display: inline-block;\n width: ", ";\n cursor: ", ";\n\n .MuiButtonBase-root {\n padding-left: ", ";\n padding-right: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n\n .MuiButton-label {\n display: flex;\n align-items: center;\n }\n\n box-shadow: 0 0 0 2px transparent;\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n letter-spacing: ", ";\n min-width: ", ";\n width: 100%;\n height: 40px;\n transition: none !important;\n\n &:focus {\n border-color: transparent;\n box-shadow: 0 0 0 2px\n ", ";\n }\n\n ", "\n }\n"])), function (props) {
|
|
128
127
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
129
128
|
}, function (props) {
|
|
130
129
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
|
|
@@ -146,8 +145,6 @@ var DxCButton = _styledComponents["default"].div(_templateObject4 || (_templateO
|
|
|
146
145
|
return props.theme.paddingTop;
|
|
147
146
|
}, function (props) {
|
|
148
147
|
return props.theme.paddingBottom;
|
|
149
|
-
}, function (props) {
|
|
150
|
-
return props.iconPosition === "after" && "row" || "row-reverse";
|
|
151
148
|
}, function (props) {
|
|
152
149
|
return props.theme.fontFamily;
|
|
153
150
|
}, function (props) {
|
|
@@ -165,9 +162,9 @@ var DxCButton = _styledComponents["default"].div(_templateObject4 || (_templateO
|
|
|
165
162
|
backgroundType = props.backgroundType;
|
|
166
163
|
|
|
167
164
|
if (mode === "primary") {
|
|
168
|
-
return "\n border-radius: ".concat(props.theme.primaryBorderRadius, ";\n border-width: ").concat(props.theme.primaryBorderThickness, ";\n border-style: ").concat(props.theme.primaryBorderStyle, ";\n font-family: ").concat(props.theme.primaryFontFamily, ";\n font-size: ").concat(props.theme.primaryFontSize, ";\n font-weight: ").concat(props.theme.primaryFontWeight, ";\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryBackgroundColorOnDark : props.theme.primaryBackgroundColor, ";\n color: ").concat(backgroundType && backgroundType === "dark" ? props.theme.primaryFontColorOnDark : props.theme.primaryFontColor, " !important;\n\n &:hover {\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryHoverBackgroundColorOnDark : props.theme.primaryHoverBackgroundColor, ";\n }\n &:active {\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryActiveBackgroundColorOnDark : props.theme.primaryActiveBackgroundColor, " !important;\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor, ";\n }\n &:disabled { \n cursor: not-allowed;\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryDisabledBackgroundColorOnDark : props.theme.primaryDisabledBackgroundColor, ";\n color: ").concat(backgroundType === "dark" ? props.theme.primaryDisabledFontColorOnDark : props.theme.primaryDisabledFontColor, "!important; \n }\n
|
|
165
|
+
return "\n border-radius: ".concat(props.theme.primaryBorderRadius, ";\n border-width: ").concat(props.theme.primaryBorderThickness, ";\n border-style: ").concat(props.theme.primaryBorderStyle, ";\n font-family: ").concat(props.theme.primaryFontFamily, ";\n font-size: ").concat(props.theme.primaryFontSize, ";\n font-weight: ").concat(props.theme.primaryFontWeight, ";\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryBackgroundColorOnDark : props.theme.primaryBackgroundColor, ";\n color: ").concat(backgroundType && backgroundType === "dark" ? props.theme.primaryFontColorOnDark : props.theme.primaryFontColor, " !important;\n\n &:hover {\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryHoverBackgroundColorOnDark : props.theme.primaryHoverBackgroundColor, ";\n }\n &:active {\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryActiveBackgroundColorOnDark : props.theme.primaryActiveBackgroundColor, " !important;\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor, ";\n }\n &:disabled { \n cursor: not-allowed;\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryDisabledBackgroundColorOnDark : props.theme.primaryDisabledBackgroundColor, ";\n color: ").concat(backgroundType === "dark" ? props.theme.primaryDisabledFontColorOnDark : props.theme.primaryDisabledFontColor, " !important; \n }\n ");
|
|
169
166
|
} else if (mode === "secondary") {
|
|
170
|
-
return "\n border-radius: ".concat(props.theme.secondaryBorderRadius, ";\n border-width: ").concat(props.theme.secondaryBorderThickness, ";\n border-style: ").concat(props.theme.secondaryBorderStyle, ";\n font-family: ").concat(props.theme.secondaryFontFamily, ";\n font-size: ").concat(props.theme.secondaryFontSize, ";\n font-weight: ").concat(props.theme.secondaryFontWeight, ";\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryBackgroundColorOnDark : props.theme.secondaryBackgroundColor, ";\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryFontColorOnDark : props.theme.secondaryFontColor, " !important;\n border-color: ").concat(backgroundType === "dark" ? props.theme.secondaryBorderColorOnDark : props.theme.secondaryBorderColor, ";\n\n &:hover {\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryHoverBackgroundColorOnDark : props.theme.secondaryHoverBackgroundColor, ";\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor, " !important;\n }\n &:active {\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryActiveBackgroundColorOnDark : props.theme.secondaryActiveBackgroundColor, " !important;\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor, " !important;\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor, ";\n }\n &:disabled {\n cursor: not-allowed;\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryDisabledBackgroundColorOnDark : props.theme.secondaryDisabledBackgroundColor, " !important;\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryDisabledFontColorOnDark : props.theme.secondaryDisabledFontColor, " !important;\n border-color: ").concat(backgroundType === "dark" ? props.theme.secondaryDisabledBorderColorOnDark : props.theme.secondaryDisabledBorderColor, ";\n }\n
|
|
167
|
+
return "\n border-radius: ".concat(props.theme.secondaryBorderRadius, ";\n border-width: ").concat(props.theme.secondaryBorderThickness, ";\n border-style: ").concat(props.theme.secondaryBorderStyle, ";\n font-family: ").concat(props.theme.secondaryFontFamily, ";\n font-size: ").concat(props.theme.secondaryFontSize, ";\n font-weight: ").concat(props.theme.secondaryFontWeight, ";\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryBackgroundColorOnDark : props.theme.secondaryBackgroundColor, ";\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryFontColorOnDark : props.theme.secondaryFontColor, " !important;\n border-color: ").concat(backgroundType === "dark" ? props.theme.secondaryBorderColorOnDark : props.theme.secondaryBorderColor, ";\n\n &:hover {\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryHoverBackgroundColorOnDark : props.theme.secondaryHoverBackgroundColor, ";\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor, " !important;\n }\n &:active {\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryActiveBackgroundColorOnDark : props.theme.secondaryActiveBackgroundColor, " !important;\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor, " !important;\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor, ";\n }\n &:disabled {\n cursor: not-allowed;\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryDisabledBackgroundColorOnDark : props.theme.secondaryDisabledBackgroundColor, " !important;\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryDisabledFontColorOnDark : props.theme.secondaryDisabledFontColor, " !important;\n border-color: ").concat(backgroundType === "dark" ? props.theme.secondaryDisabledBorderColorOnDark : props.theme.secondaryDisabledBorderColor, ";\n }\n ");
|
|
171
168
|
} else if (mode === "text") {
|
|
172
169
|
return "\n border-radius: ".concat(props.theme.textBorderRadius, ";\n border-width: ").concat(props.theme.textBorderThickness, ";\n border-style: ").concat(props.theme.textBorderStyle, ";\n font-family: ").concat(props.theme.textFontFamily, ";\n font-size: ").concat(props.theme.textFontSize, ";\n font-weight: ").concat(props.theme.textFontWeight, ";\n background-color: ").concat(backgroundType === "dark" ? props.theme.textBackgroundColorOnDark : props.theme.textBackgroundColor, ";\n color: ").concat(backgroundType === "dark" ? props.theme.textFontColorOnDark : props.theme.textFontColor, " !important;\n\n &:hover {\n background-color: ").concat(backgroundType === "dark" ? props.theme.textHoverBackgroundColorOnDark : props.theme.textHoverBackgroundColor, ";\n }\n &:active {\n background-color: ").concat(backgroundType === "dark" ? props.theme.textActiveBackgroundColorOnDark : props.theme.textActiveBackgroundColor, " !important;\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor, ";\n }\n &:disabled {\n cursor:not-allowed;\n color: ").concat(backgroundType === "dark" ? props.theme.textDisabledFontColorOnDark : props.theme.textDisabledFontColor, " !important;\n background-color: ").concat(backgroundType === "dark" ? props.theme.textDisabledBackgroundColorOnDark : props.theme.textDisabledBackgroundColor, ";\n }\n ");
|
|
173
170
|
}
|
|
@@ -10,14 +10,12 @@ export default {
|
|
|
10
10
|
component: DxcButton,
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
const iconSVG = (
|
|
14
|
-
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
);
|
|
20
|
-
};
|
|
13
|
+
const iconSVG = (
|
|
14
|
+
<svg viewBox="0 0 24 24" fill="currentColor">
|
|
15
|
+
<path d="M0 0h24v24H0z" fill="none" />
|
|
16
|
+
<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" />
|
|
17
|
+
</svg>
|
|
18
|
+
);
|
|
21
19
|
export const Chromatic = () => (
|
|
22
20
|
<>
|
|
23
21
|
<Title title="Primary" theme="light" level={2} />
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
|
|
7
|
+
var _react2 = require("@testing-library/react");
|
|
8
|
+
|
|
9
|
+
var _Button = _interopRequireDefault(require("./Button"));
|
|
10
|
+
|
|
11
|
+
describe("Button component tests", function () {
|
|
12
|
+
test("Button renders with correct text", function () {
|
|
13
|
+
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
14
|
+
label: "Button"
|
|
15
|
+
})),
|
|
16
|
+
getByText = _render.getByText;
|
|
17
|
+
|
|
18
|
+
expect(getByText("Button")).toBeTruthy();
|
|
19
|
+
});
|
|
20
|
+
test("Calls correct function on click", function () {
|
|
21
|
+
var onClick = jest.fn();
|
|
22
|
+
|
|
23
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
24
|
+
label: "Button",
|
|
25
|
+
onClick: onClick
|
|
26
|
+
})),
|
|
27
|
+
getByText = _render2.getByText;
|
|
28
|
+
|
|
29
|
+
var button = getByText("Button");
|
|
30
|
+
|
|
31
|
+
_react2.fireEvent.click(button);
|
|
32
|
+
|
|
33
|
+
expect(onClick).toHaveBeenCalled();
|
|
34
|
+
});
|
|
35
|
+
});
|
package/button/types.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ declare type Margin = {
|
|
|
6
6
|
left?: Space;
|
|
7
7
|
right?: Space;
|
|
8
8
|
};
|
|
9
|
-
declare type SVG = React.SVGProps<SVGSVGElement
|
|
9
|
+
declare type SVG = React.SVGProps<SVGSVGElement>;
|
|
10
10
|
declare type Props = {
|
|
11
11
|
/**
|
|
12
12
|
* Text to be placed next to the button.
|
|
@@ -29,17 +29,13 @@ declare type Props = {
|
|
|
29
29
|
*/
|
|
30
30
|
type?: "button" | "reset" | "submit";
|
|
31
31
|
/**
|
|
32
|
-
* Element used as the icon that will be placed next to the button label.
|
|
32
|
+
* Element or path used as the icon that will be placed next to the button label.
|
|
33
33
|
*/
|
|
34
|
-
icon?: SVG;
|
|
34
|
+
icon?: string | SVG;
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* This function will be called when the user clicks the button.
|
|
37
37
|
*/
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* This function will be called when the user clicks the button. The event object will be passed as a parameter.
|
|
41
|
-
*/
|
|
42
|
-
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
38
|
+
onClick?: () => void;
|
|
43
39
|
/**
|
|
44
40
|
* Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
|
|
45
41
|
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
|
package/card/Card.js
CHANGED
|
@@ -21,7 +21,7 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
|
21
21
|
|
|
22
22
|
var _variables = require("../common/variables.js");
|
|
23
23
|
|
|
24
|
-
var _useTheme = _interopRequireDefault(require("../useTheme
|
|
24
|
+
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
25
|
|
|
26
26
|
var _Box = _interopRequireDefault(require("../box/Box"));
|
|
27
27
|
|
|
@@ -47,7 +47,7 @@ var DxcCard = function DxcCard(_ref) {
|
|
|
47
47
|
_ref$tabIndex = _ref.tabIndex,
|
|
48
48
|
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex,
|
|
49
49
|
_ref$outlined = _ref.outlined,
|
|
50
|
-
outlined = _ref$outlined === void 0 ?
|
|
50
|
+
outlined = _ref$outlined === void 0 ? true : _ref$outlined,
|
|
51
51
|
children = _ref.children;
|
|
52
52
|
var colorsTheme = (0, _useTheme["default"])();
|
|
53
53
|
|
|
@@ -56,23 +56,24 @@ var DxcCard = function DxcCard(_ref) {
|
|
|
56
56
|
isHovered = _useState2[0],
|
|
57
57
|
changeIsHovered = _useState2[1];
|
|
58
58
|
|
|
59
|
+
var imageComponent = /*#__PURE__*/_react["default"].createElement(ImageContainer, {
|
|
60
|
+
imageBgColor: imageBgColor
|
|
61
|
+
}, /*#__PURE__*/_react["default"].createElement(TagImage, {
|
|
62
|
+
imagePadding: imagePadding,
|
|
63
|
+
cover: imageCover,
|
|
64
|
+
src: imageSrc
|
|
65
|
+
}));
|
|
66
|
+
|
|
59
67
|
var tagContent = /*#__PURE__*/_react["default"].createElement(_Box["default"], {
|
|
60
|
-
shadowDepth: outlined ? 0 : isHovered && (onClick || linkHref) ? 2 : 1
|
|
68
|
+
shadowDepth: !outlined ? 0 : isHovered && (onClick || linkHref) ? 2 : 1
|
|
61
69
|
}, /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
62
70
|
theme: colorsTheme.card
|
|
63
71
|
}, /*#__PURE__*/_react["default"].createElement(CardContainer, {
|
|
64
72
|
hasAction: onClick || linkHref,
|
|
65
|
-
outlined: outlined,
|
|
66
73
|
imagePosition: imagePosition
|
|
67
|
-
}, imageSrc && /*#__PURE__*/_react["default"].createElement(
|
|
68
|
-
imageBgColor: imageBgColor
|
|
69
|
-
}, /*#__PURE__*/_react["default"].createElement(TagImage, {
|
|
70
|
-
imagePadding: imagePadding,
|
|
71
|
-
cover: imageCover,
|
|
72
|
-
src: imageSrc
|
|
73
|
-
})), /*#__PURE__*/_react["default"].createElement(CardContent, {
|
|
74
|
+
}, imageSrc && imagePosition === "before" && imageComponent, /*#__PURE__*/_react["default"].createElement(CardContent, {
|
|
74
75
|
contentPadding: contentPadding
|
|
75
|
-
}, children))));
|
|
76
|
+
}, children), imageSrc && imagePosition === "after" && imageComponent)));
|
|
76
77
|
|
|
77
78
|
return /*#__PURE__*/_react["default"].createElement(StyledDxcCard, {
|
|
78
79
|
margin: margin,
|
|
@@ -91,7 +92,7 @@ var DxcCard = function DxcCard(_ref) {
|
|
|
91
92
|
}, tagContent) || tagContent);
|
|
92
93
|
};
|
|
93
94
|
|
|
94
|
-
var StyledDxcCard = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n cursor: ", ";\n outline: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (_ref2) {
|
|
95
|
+
var StyledDxcCard = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n cursor: ", ";\n outline: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n :focus {\n outline: #0095ff auto 1px;\n }\n"])), function (_ref2) {
|
|
95
96
|
var hasAction = _ref2.hasAction;
|
|
96
97
|
return hasAction && "pointer" || "unset";
|
|
97
98
|
}, function (_ref3) {
|
|
@@ -114,50 +115,47 @@ var StyledDxcCard = _styledComponents["default"].div(_templateObject || (_templa
|
|
|
114
115
|
return margin && margin.left ? _variables.spaces[margin.left] : "";
|
|
115
116
|
});
|
|
116
117
|
|
|
117
|
-
var CardContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n
|
|
118
|
-
var imagePosition = _ref9.imagePosition;
|
|
119
|
-
return imagePosition === "before" && "row" || "row-reverse";
|
|
120
|
-
}, function (props) {
|
|
118
|
+
var CardContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n height: ", ";\n width: ", ";\n &:hover {\n border-color: ", ";\n }\n"])), function (props) {
|
|
121
119
|
return props.theme.height;
|
|
122
120
|
}, function (props) {
|
|
123
121
|
return props.theme.width;
|
|
124
|
-
}, function (
|
|
125
|
-
var hasAction =
|
|
122
|
+
}, function (_ref9) {
|
|
123
|
+
var hasAction = _ref9.hasAction;
|
|
126
124
|
return hasAction ? "" : "unset";
|
|
127
125
|
});
|
|
128
126
|
|
|
129
|
-
var StyledLink = _styledComponents["default"].a(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n cursor: pointer;\n text-decoration: none;\n"])));
|
|
127
|
+
var StyledLink = _styledComponents["default"].a(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n cursor: pointer;\n text-decoration: none;\n\n :focus {\n outline-color: #0095ff;\n }\n"])));
|
|
130
128
|
|
|
131
|
-
var TagImage = _styledComponents["default"].img(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n height: ", ";\n width: ", ";\n object-fit: ", ";\n"])), function (
|
|
129
|
+
var TagImage = _styledComponents["default"].img(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n height: ", ";\n width: ", ";\n object-fit: ", ";\n"])), function (_ref10) {
|
|
130
|
+
var imagePadding = _ref10.imagePadding;
|
|
131
|
+
return !imagePadding ? "100%" : "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
|
|
132
|
+
}, function (_ref11) {
|
|
132
133
|
var imagePadding = _ref11.imagePadding;
|
|
133
134
|
return !imagePadding ? "100%" : "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
|
|
134
135
|
}, function (_ref12) {
|
|
135
|
-
var
|
|
136
|
-
return !imagePadding ? "100%" : "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
|
|
137
|
-
}, function (_ref13) {
|
|
138
|
-
var cover = _ref13.cover;
|
|
136
|
+
var cover = _ref12.cover;
|
|
139
137
|
return cover ? "cover" : "contain";
|
|
140
138
|
});
|
|
141
139
|
|
|
142
|
-
var ImageContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n width: 35%;\n height: 100%;\n flex-shrink: 0;\n background: ", ";\n justify-content: center;\n align-items: center;\n display: inline-flex;\n"])), function (
|
|
143
|
-
var imageBgColor =
|
|
140
|
+
var ImageContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n width: 35%;\n height: 100%;\n flex-shrink: 0;\n background: ", ";\n justify-content: center;\n align-items: center;\n display: inline-flex;\n"])), function (_ref13) {
|
|
141
|
+
var imageBgColor = _ref13.imageBgColor;
|
|
144
142
|
return imageBgColor;
|
|
145
143
|
});
|
|
146
144
|
|
|
147
|
-
var CardContent = _styledComponents["default"].div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n flex-grow: 1;\n padding: ", ";\n padding-top: ", ";\n padding-right: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n overflow: hidden;\n"])), function (
|
|
148
|
-
var contentPadding =
|
|
145
|
+
var CardContent = _styledComponents["default"].div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n flex-grow: 1;\n padding: ", ";\n padding-top: ", ";\n padding-right: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n overflow: hidden;\n"])), function (_ref14) {
|
|
146
|
+
var contentPadding = _ref14.contentPadding;
|
|
149
147
|
return contentPadding && (0, _typeof2["default"])(contentPadding) !== "object" ? _variables.spaces[contentPadding] : "0px";
|
|
148
|
+
}, function (_ref15) {
|
|
149
|
+
var contentPadding = _ref15.contentPadding;
|
|
150
|
+
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.top ? _variables.spaces[contentPadding.top] : "";
|
|
150
151
|
}, function (_ref16) {
|
|
151
152
|
var contentPadding = _ref16.contentPadding;
|
|
152
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.
|
|
153
|
+
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.right ? _variables.spaces[contentPadding.right] : "";
|
|
153
154
|
}, function (_ref17) {
|
|
154
155
|
var contentPadding = _ref17.contentPadding;
|
|
155
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.
|
|
156
|
+
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.bottom ? _variables.spaces[contentPadding.bottom] : "";
|
|
156
157
|
}, function (_ref18) {
|
|
157
158
|
var contentPadding = _ref18.contentPadding;
|
|
158
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.bottom ? _variables.spaces[contentPadding.bottom] : "";
|
|
159
|
-
}, function (_ref19) {
|
|
160
|
-
var contentPadding = _ref19.contentPadding;
|
|
161
159
|
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.left ? _variables.spaces[contentPadding.left] : "";
|
|
162
160
|
});
|
|
163
161
|
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Title from "../../.storybook/components/Title";
|
|
3
|
+
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
4
|
+
import DxcCard from "./Card";
|
|
5
|
+
import imagePath from "./ice-cream.jpg";
|
|
6
|
+
import { userEvent, within } from "@storybook/testing-library";
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: "Card",
|
|
10
|
+
component: DxcCard,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const Card = () => (
|
|
14
|
+
<>
|
|
15
|
+
<Title title="Default" theme="light" level={4} />
|
|
16
|
+
<ExampleContainer>
|
|
17
|
+
<DxcCard>Default</DxcCard>
|
|
18
|
+
</ExampleContainer>
|
|
19
|
+
<Title title="Not outlined" theme="light" level={4} />
|
|
20
|
+
<ExampleContainer>
|
|
21
|
+
<DxcCard outlined={false}>Not outlined</DxcCard>
|
|
22
|
+
</ExampleContainer>
|
|
23
|
+
<Title title="Default with link" theme="light" level={4} />
|
|
24
|
+
<ExampleContainer>
|
|
25
|
+
<DxcCard linkHref="https://www.dxc.com">Default with link</DxcCard>
|
|
26
|
+
</ExampleContainer>
|
|
27
|
+
<Title title="Focused default with link" theme="light" level={4} />
|
|
28
|
+
<ExampleContainer>
|
|
29
|
+
<DxcCard linkHref="https://www.dxc.com">Focused default with link</DxcCard>
|
|
30
|
+
</ExampleContainer>
|
|
31
|
+
<Title title="Hovered default with link" theme="light" level={4} />
|
|
32
|
+
<ExampleContainer>
|
|
33
|
+
<DxcCard linkHref="https://www.dxc.com">Hovered default with link</DxcCard>
|
|
34
|
+
</ExampleContainer>
|
|
35
|
+
<Title title="Default with action" theme="light" level={4} />
|
|
36
|
+
<ExampleContainer>
|
|
37
|
+
<DxcCard onClick={() => {}}>Default with action</DxcCard>
|
|
38
|
+
</ExampleContainer>
|
|
39
|
+
<Title title="Default with image" theme="light" level={4} />
|
|
40
|
+
<ExampleContainer>
|
|
41
|
+
<DxcCard imageSrc={imagePath}>Default</DxcCard>
|
|
42
|
+
</ExampleContainer>
|
|
43
|
+
<Title title="Default image with background color" theme="light" level={4} />
|
|
44
|
+
<ExampleContainer>
|
|
45
|
+
<DxcCard imageSrc={imagePath} imageBgColor="yellow">
|
|
46
|
+
Background color
|
|
47
|
+
</DxcCard>
|
|
48
|
+
</ExampleContainer>
|
|
49
|
+
<Title title="Default image with position after" theme="light" level={4} />
|
|
50
|
+
<ExampleContainer>
|
|
51
|
+
<DxcCard imageSrc={imagePath} imagePosition="after">
|
|
52
|
+
Position after
|
|
53
|
+
</DxcCard>
|
|
54
|
+
</ExampleContainer>
|
|
55
|
+
<Title title="Image cover" theme="light" level={4} />
|
|
56
|
+
<ExampleContainer>
|
|
57
|
+
<DxcCard imageSrc={imagePath} imageCover>
|
|
58
|
+
Image cover
|
|
59
|
+
</DxcCard>
|
|
60
|
+
</ExampleContainer>
|
|
61
|
+
<Title title="Image cover with position after" theme="light" level={4} />
|
|
62
|
+
<ExampleContainer>
|
|
63
|
+
<DxcCard imageSrc={imagePath} imageCover imagePosition="after">
|
|
64
|
+
Image cover with position after
|
|
65
|
+
</DxcCard>
|
|
66
|
+
</ExampleContainer>
|
|
67
|
+
<Title title="Image padding" theme="light" level={2} />
|
|
68
|
+
<ExampleContainer>
|
|
69
|
+
<Title title="Xxsmall" theme="light" level={4} />
|
|
70
|
+
<DxcCard imageSrc={imagePath} imagePadding="xxsmall" imageCover>
|
|
71
|
+
Xxsmall
|
|
72
|
+
</DxcCard>
|
|
73
|
+
</ExampleContainer>
|
|
74
|
+
<ExampleContainer>
|
|
75
|
+
<Title title="Xsmall" theme="light" level={4} />
|
|
76
|
+
<DxcCard imageSrc={imagePath} imagePadding="xsmall" imageCover>
|
|
77
|
+
Xsmall
|
|
78
|
+
</DxcCard>
|
|
79
|
+
</ExampleContainer>
|
|
80
|
+
<ExampleContainer>
|
|
81
|
+
<Title title="Small" theme="light" level={4} />
|
|
82
|
+
<DxcCard imageSrc={imagePath} imagePadding="small" imageCover>
|
|
83
|
+
Small
|
|
84
|
+
</DxcCard>
|
|
85
|
+
</ExampleContainer>
|
|
86
|
+
<ExampleContainer>
|
|
87
|
+
<Title title="Medium" theme="light" level={4} />
|
|
88
|
+
<DxcCard imageSrc={imagePath} imagePadding="medium" imageCover>
|
|
89
|
+
Medium
|
|
90
|
+
</DxcCard>
|
|
91
|
+
</ExampleContainer>
|
|
92
|
+
<ExampleContainer>
|
|
93
|
+
<Title title="Large" theme="light" level={4} />
|
|
94
|
+
<DxcCard imageSrc={imagePath} imagePadding="large" imageCover>
|
|
95
|
+
Large
|
|
96
|
+
</DxcCard>
|
|
97
|
+
</ExampleContainer>
|
|
98
|
+
<ExampleContainer>
|
|
99
|
+
<Title title="Xlarge" theme="light" level={4} />
|
|
100
|
+
<DxcCard imageSrc={imagePath} imagePadding="xlarge" imageCover>
|
|
101
|
+
Xlarge
|
|
102
|
+
</DxcCard>
|
|
103
|
+
</ExampleContainer>
|
|
104
|
+
<ExampleContainer>
|
|
105
|
+
<Title title="Xxlarge" theme="light" level={4} />
|
|
106
|
+
<DxcCard imageSrc={imagePath} imagePadding="xxlarge" imageCover>
|
|
107
|
+
Xxlarge
|
|
108
|
+
</DxcCard>
|
|
109
|
+
</ExampleContainer>
|
|
110
|
+
<Title title="Content padding" theme="light" level={2} />
|
|
111
|
+
<ExampleContainer>
|
|
112
|
+
<Title title="Xxsmall" theme="light" level={4} />
|
|
113
|
+
<DxcCard contentPadding="xxsmall">Xxsmall</DxcCard>
|
|
114
|
+
</ExampleContainer>
|
|
115
|
+
<ExampleContainer>
|
|
116
|
+
<Title title="Xsmall" theme="light" level={4} />
|
|
117
|
+
<DxcCard contentPadding="xsmall">Xsmall</DxcCard>
|
|
118
|
+
</ExampleContainer>
|
|
119
|
+
<ExampleContainer>
|
|
120
|
+
<Title title="Small" theme="light" level={4} />
|
|
121
|
+
<DxcCard contentPadding="small">Small</DxcCard>
|
|
122
|
+
</ExampleContainer>
|
|
123
|
+
<ExampleContainer>
|
|
124
|
+
<Title title="Medium" theme="light" level={4} />
|
|
125
|
+
<DxcCard contentPadding="medium">Medium</DxcCard>
|
|
126
|
+
</ExampleContainer>
|
|
127
|
+
<ExampleContainer>
|
|
128
|
+
<Title title="Large" theme="light" level={4} />
|
|
129
|
+
<DxcCard contentPadding="large">Large</DxcCard>
|
|
130
|
+
</ExampleContainer>
|
|
131
|
+
<ExampleContainer>
|
|
132
|
+
<Title title="Xlarge" theme="light" level={4} />
|
|
133
|
+
<DxcCard contentPadding="xlarge">Xlarge</DxcCard>
|
|
134
|
+
</ExampleContainer>
|
|
135
|
+
<ExampleContainer>
|
|
136
|
+
<Title title="Xxlarge" theme="light" level={4} />
|
|
137
|
+
<DxcCard contentPadding="xxlarge">Xxlarge</DxcCard>
|
|
138
|
+
</ExampleContainer>
|
|
139
|
+
<Title title="Margin" theme="light" level={2} />
|
|
140
|
+
<ExampleContainer>
|
|
141
|
+
<Title title="Xxsmall" theme="light" level={4} />
|
|
142
|
+
<DxcCard margin="xxsmall">Xxsmall</DxcCard>
|
|
143
|
+
</ExampleContainer>
|
|
144
|
+
<ExampleContainer>
|
|
145
|
+
<Title title="Xsmall" theme="light" level={4} />
|
|
146
|
+
<DxcCard margin="xsmall">Xsmall</DxcCard>
|
|
147
|
+
</ExampleContainer>
|
|
148
|
+
<ExampleContainer>
|
|
149
|
+
<Title title="Small" theme="light" level={4} />
|
|
150
|
+
<DxcCard margin="small">Small</DxcCard>
|
|
151
|
+
</ExampleContainer>
|
|
152
|
+
<ExampleContainer>
|
|
153
|
+
<Title title="Medium" theme="light" level={4} />
|
|
154
|
+
<DxcCard margin="medium">Medium</DxcCard>
|
|
155
|
+
</ExampleContainer>
|
|
156
|
+
<ExampleContainer>
|
|
157
|
+
<Title title="Large" theme="light" level={4} />
|
|
158
|
+
<DxcCard margin="large">Large</DxcCard>
|
|
159
|
+
</ExampleContainer>
|
|
160
|
+
<ExampleContainer>
|
|
161
|
+
<Title title="Xlarge" theme="light" level={4} />
|
|
162
|
+
<DxcCard margin="xlarge">Xlarge</DxcCard>
|
|
163
|
+
</ExampleContainer>
|
|
164
|
+
<ExampleContainer>
|
|
165
|
+
<Title title="Xxlarge" theme="light" level={4} />
|
|
166
|
+
<DxcCard margin="xxlarge">Xxlarge</DxcCard>
|
|
167
|
+
</ExampleContainer>
|
|
168
|
+
</>
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
const actionCard = () => (
|
|
172
|
+
<>
|
|
173
|
+
<ExampleContainer>
|
|
174
|
+
<Title title="Focused default with action" theme="light" level={4} />
|
|
175
|
+
<DxcCard onClick={() => {}}>Focused default with action</DxcCard>
|
|
176
|
+
</ExampleContainer>
|
|
177
|
+
<ExampleContainer expanded>
|
|
178
|
+
<Title title="Hovered default with action" theme="light" level={4} />
|
|
179
|
+
<DxcCard onClick={() => {}}>Hovered default with action</DxcCard>
|
|
180
|
+
</ExampleContainer>
|
|
181
|
+
</>
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
const linkStates = async (focusCard, hoverCard) => {
|
|
185
|
+
await focusCard.focus();
|
|
186
|
+
await userEvent.hover(hoverCard);
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export const ActionCardStates = actionCard.bind({});
|
|
190
|
+
ActionCardStates.play = async ({ canvasElement }) => {
|
|
191
|
+
const canvas = within(canvasElement);
|
|
192
|
+
await userEvent.tab();
|
|
193
|
+
await userEvent.hover(canvas.getAllByText("Hovered default with action")[1]);
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export const Chromatic = Card.bind({});
|
|
197
|
+
Chromatic.play = async ({ canvasElement }) => {
|
|
198
|
+
const canvas = within(canvasElement);
|
|
199
|
+
const linkCards = canvas.getAllByRole("link");
|
|
200
|
+
await linkStates(linkCards[1], linkCards[2]);
|
|
201
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
|
|
7
|
+
var _react2 = require("@testing-library/react");
|
|
8
|
+
|
|
9
|
+
var _Card = _interopRequireDefault(require("./Card"));
|
|
10
|
+
|
|
11
|
+
describe("Card component tests", function () {
|
|
12
|
+
test("Card renders with correct content", function () {
|
|
13
|
+
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Card["default"], null, "test-card")),
|
|
14
|
+
getByText = _render.getByText;
|
|
15
|
+
|
|
16
|
+
expect(getByText("test-card")).toBeTruthy();
|
|
17
|
+
});
|
|
18
|
+
test("Card renders with correct href", function () {
|
|
19
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Card["default"], {
|
|
20
|
+
linkHref: "/testPage"
|
|
21
|
+
}, "test-card")),
|
|
22
|
+
getByRole = _render2.getByRole;
|
|
23
|
+
|
|
24
|
+
var card = getByRole("link");
|
|
25
|
+
expect(card.getAttribute("href")).toEqual("/testPage");
|
|
26
|
+
});
|
|
27
|
+
test("Card renders with correct image", function () {
|
|
28
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Card["default"], {
|
|
29
|
+
imageSrc: "/testImage"
|
|
30
|
+
}, "test-card")),
|
|
31
|
+
getByRole = _render3.getByRole;
|
|
32
|
+
|
|
33
|
+
var card = getByRole("img");
|
|
34
|
+
expect(card.getAttribute("src")).toEqual("/testImage");
|
|
35
|
+
});
|
|
36
|
+
test("OnClick function is called", function () {
|
|
37
|
+
var onClick = jest.fn();
|
|
38
|
+
|
|
39
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Card["default"], {
|
|
40
|
+
onClick: onClick
|
|
41
|
+
}, "test-card")),
|
|
42
|
+
getByText = _render4.getByText;
|
|
43
|
+
|
|
44
|
+
var card = getByText("test-card");
|
|
45
|
+
|
|
46
|
+
_react2.fireEvent.click(card);
|
|
47
|
+
|
|
48
|
+
expect(onClick).toHaveBeenCalled();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
Binary file
|
package/card/types.d.ts
CHANGED
|
@@ -42,15 +42,13 @@ declare type Props = {
|
|
|
42
42
|
*/
|
|
43
43
|
imageCover?: boolean;
|
|
44
44
|
/**
|
|
45
|
-
* Size of the margin to be applied to the component
|
|
46
|
-
* an object with 'top', 'bottom', 'left' and 'right' properties
|
|
47
|
-
* in order to specify different margin sizes.
|
|
45
|
+
* Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
|
|
46
|
+
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
|
|
48
47
|
*/
|
|
49
48
|
margin?: Space | Size;
|
|
50
49
|
/**
|
|
51
|
-
* Size of the padding to be applied to the content area
|
|
52
|
-
* an object with 'top', 'bottom', 'left' and 'right' properties in
|
|
53
|
-
* order to specify different padding sizes.
|
|
50
|
+
* Size of the padding to be applied to the content area ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
|
|
51
|
+
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different padding sizes.
|
|
54
52
|
*/
|
|
55
53
|
contentPadding?: Space | Size;
|
|
56
54
|
/**
|
package/checkbox/Checkbox.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import CheckboxPropsType from "./types";
|
|
3
|
-
declare const DxcCheckbox: ({ checked, value, label, labelPosition, name, disabled,
|
|
3
|
+
declare const DxcCheckbox: ({ checked, defaultChecked, value, label, labelPosition, name, disabled, optional, onChange, margin, size, tabIndex, }: CheckboxPropsType) => JSX.Element;
|
|
4
4
|
export default DxcCheckbox;
|