@dxc-technology/halstack-react 0.0.0-9bd9511 → 0.0.0-9c20370
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 +3 -3
- package/BackgroundColorContext.js +12 -2
- package/HalstackContext.d.ts +1330 -7
- package/HalstackContext.js +84 -67
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +74 -55
- package/accordion/Accordion.stories.tsx +3 -101
- package/accordion/Accordion.test.js +34 -19
- package/accordion/types.d.ts +4 -16
- package/accordion-group/AccordionGroup.d.ts +4 -3
- package/accordion-group/AccordionGroup.js +49 -42
- package/accordion-group/AccordionGroup.stories.tsx +77 -76
- package/accordion-group/AccordionGroup.test.js +62 -54
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +43 -0
- package/accordion-group/types.d.ts +6 -18
- package/alert/Alert.js +47 -20
- package/alert/Alert.test.js +46 -29
- package/alert/types.d.ts +3 -3
- package/badge/Badge.js +14 -2
- package/badge/types.d.ts +1 -1
- package/bleed/Bleed.js +21 -13
- package/bleed/Bleed.stories.tsx +1 -0
- package/bleed/types.d.ts +2 -2
- package/box/Box.d.ts +1 -1
- package/box/Box.js +33 -33
- package/box/Box.stories.tsx +25 -53
- package/box/Box.test.js +7 -2
- package/box/types.d.ts +3 -15
- package/bulleted-list/BulletedList.js +36 -9
- package/bulleted-list/BulletedList.stories.tsx +7 -1
- package/bulleted-list/types.d.ts +32 -5
- package/button/Button.d.ts +1 -1
- package/button/Button.js +83 -71
- package/button/Button.stories.tsx +4 -4
- package/button/Button.test.js +28 -8
- package/button/types.d.ts +8 -4
- package/card/Card.d.ts +1 -1
- package/card/Card.js +67 -62
- package/card/Card.stories.tsx +12 -42
- package/card/Card.test.js +22 -11
- package/card/types.d.ts +4 -10
- package/checkbox/Checkbox.js +71 -27
- package/checkbox/Checkbox.test.js +60 -33
- package/checkbox/types.d.ts +4 -4
- package/chip/Chip.js +51 -48
- package/chip/Chip.stories.tsx +25 -17
- package/chip/Chip.test.js +29 -17
- package/chip/types.d.ts +4 -4
- package/common/OpenSans.css +68 -80
- package/common/coreTokens.d.ts +146 -0
- package/common/coreTokens.js +167 -0
- package/common/utils.d.ts +1 -0
- package/common/utils.js +8 -3
- package/common/variables.d.ts +226 -175
- package/common/variables.js +956 -1133
- package/date-input/Calendar.js +55 -12
- package/date-input/DateInput.js +82 -35
- package/date-input/DateInput.test.js +351 -164
- package/date-input/DatePicker.js +38 -8
- package/date-input/Icons.js +12 -0
- package/date-input/YearPicker.js +30 -5
- package/date-input/types.d.ts +7 -7
- package/dialog/Dialog.d.ts +1 -1
- package/dialog/Dialog.js +83 -86
- package/dialog/Dialog.stories.tsx +127 -221
- package/dialog/Dialog.test.js +331 -18
- package/dialog/types.d.ts +1 -14
- package/dropdown/Dropdown.js +86 -32
- package/dropdown/Dropdown.test.js +211 -104
- package/dropdown/DropdownMenu.js +22 -8
- package/dropdown/DropdownMenuItem.js +15 -6
- package/dropdown/types.d.ts +8 -8
- package/file-input/FileInput.js +218 -134
- package/file-input/FileInput.test.js +343 -331
- package/file-input/FileItem.js +39 -12
- package/file-input/types.d.ts +10 -10
- package/flex/Flex.js +39 -25
- package/flex/Flex.stories.tsx +35 -26
- package/flex/types.d.ts +74 -9
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +80 -68
- package/footer/Footer.stories.tsx +12 -89
- package/footer/Footer.test.js +47 -40
- package/footer/Icons.js +4 -0
- package/footer/types.d.ts +15 -17
- package/grid/Grid.d.ts +7 -0
- package/grid/Grid.js +91 -0
- package/grid/Grid.stories.tsx +219 -0
- package/grid/types.d.ts +115 -0
- package/header/Header.d.ts +4 -3
- package/header/Header.js +72 -55
- package/header/Header.stories.tsx +7 -71
- package/header/Header.test.js +26 -13
- package/header/Icons.js +4 -0
- package/header/types.d.ts +2 -16
- package/heading/Heading.js +28 -7
- package/heading/Heading.test.js +88 -71
- package/heading/types.d.ts +3 -3
- package/inset/Inset.js +21 -13
- package/inset/Inset.stories.tsx +2 -1
- package/inset/types.d.ts +2 -2
- package/layout/ApplicationLayout.d.ts +5 -5
- package/layout/ApplicationLayout.js +57 -15
- package/layout/Icons.js +10 -0
- package/layout/SidenavContext.d.ts +1 -1
- package/layout/SidenavContext.js +4 -0
- package/layout/types.d.ts +5 -6
- package/link/Link.js +41 -21
- package/link/Link.test.js +42 -26
- package/link/types.d.ts +4 -4
- package/main.d.ts +2 -1
- package/main.js +55 -0
- package/nav-tabs/NavTabs.d.ts +2 -2
- package/nav-tabs/NavTabs.js +43 -16
- package/nav-tabs/NavTabs.stories.tsx +14 -0
- package/nav-tabs/NavTabs.test.js +44 -37
- package/nav-tabs/Tab.js +71 -45
- package/nav-tabs/types.d.ts +10 -11
- package/number-input/NumberInput.js +30 -20
- package/number-input/NumberInput.test.js +249 -113
- package/number-input/NumberInputContext.js +5 -0
- package/number-input/numberInputContextTypes.d.ts +1 -1
- package/number-input/types.d.ts +4 -4
- package/package.json +7 -7
- package/paginator/Icons.js +10 -0
- package/paginator/Paginator.js +39 -17
- package/paginator/Paginator.test.js +156 -104
- package/paginator/types.d.ts +1 -1
- package/paragraph/Paragraph.d.ts +3 -4
- package/paragraph/Paragraph.js +18 -8
- package/password-input/PasswordInput.js +51 -22
- package/password-input/PasswordInput.test.js +94 -51
- package/password-input/types.d.ts +4 -4
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +39 -14
- package/progress-bar/ProgressBar.test.js +53 -36
- package/progress-bar/types.d.ts +4 -3
- package/quick-nav/QuickNav.js +24 -2
- package/quick-nav/types.d.ts +2 -2
- package/radio-group/Radio.js +53 -22
- package/radio-group/RadioGroup.js +84 -41
- package/radio-group/RadioGroup.test.js +288 -186
- package/radio-group/types.d.ts +4 -4
- package/resultsetTable/Icons.js +3 -0
- package/resultsetTable/ResultsetTable.js +56 -21
- package/resultsetTable/ResultsetTable.test.js +75 -42
- package/resultsetTable/types.d.ts +5 -5
- package/select/Icons.js +3 -0
- package/select/Listbox.js +35 -10
- package/select/Option.js +24 -8
- package/select/Select.js +143 -56
- package/select/Select.test.js +839 -456
- package/select/types.d.ts +12 -12
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +51 -0
- package/sidenav/Sidenav.d.ts +2 -2
- package/sidenav/Sidenav.js +116 -104
- package/sidenav/Sidenav.stories.tsx +60 -60
- package/sidenav/Sidenav.test.js +10 -3
- package/sidenav/types.d.ts +26 -23
- package/slider/Slider.js +84 -38
- package/slider/Slider.test.js +104 -76
- package/slider/types.d.ts +4 -4
- package/spinner/Spinner.js +51 -28
- package/spinner/Spinner.stories.jsx +28 -28
- package/spinner/Spinner.test.js +35 -26
- package/spinner/types.d.ts +3 -3
- package/switch/Switch.js +66 -24
- package/switch/Switch.test.js +97 -52
- package/switch/types.d.ts +4 -4
- package/table/Table.js +22 -4
- package/table/Table.test.js +7 -2
- package/table/types.d.ts +3 -3
- package/tabs/Tab.js +39 -22
- package/tabs/Tabs.js +131 -62
- package/tabs/Tabs.test.js +122 -67
- package/tabs/types.d.ts +8 -8
- package/tag/Tag.js +54 -27
- package/tag/Tag.test.js +31 -20
- package/tag/types.d.ts +7 -7
- package/text-input/Icons.js +3 -0
- package/text-input/Suggestion.js +24 -8
- package/text-input/Suggestions.js +36 -11
- package/text-input/TextInput.js +144 -59
- package/text-input/TextInput.stories.tsx +1 -1
- package/text-input/TextInput.test.js +858 -539
- package/text-input/types.d.ts +9 -9
- package/textarea/Textarea.js +73 -38
- package/textarea/Textarea.test.js +173 -98
- package/textarea/types.d.ts +4 -4
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +59 -21
- package/toggle-group/ToggleGroup.test.js +72 -40
- package/toggle-group/types.d.ts +11 -11
- package/typography/Typography.d.ts +2 -2
- package/typography/Typography.js +23 -110
- package/typography/Typography.stories.tsx +1 -1
- package/typography/types.d.ts +1 -1
- package/useTheme.d.ts +1234 -1
- package/useTheme.js +6 -0
- package/useTranslatedLabels.d.ts +84 -2
- package/useTranslatedLabels.js +5 -0
- package/utils/BaseTypography.d.ts +21 -0
- package/utils/BaseTypography.js +108 -0
- package/utils/FocusLock.d.ts +13 -0
- package/utils/FocusLock.js +138 -0
- package/wizard/Wizard.js +47 -13
- package/wizard/Wizard.test.js +81 -54
- package/wizard/types.d.ts +7 -8
- package/card/ice-cream.jpg +0 -0
- package/translatedLabelsType.d.ts +0 -82
- /package/{translatedLabelsType.js → grid/types.js} +0 -0
package/bulleted-list/types.d.ts
CHANGED
|
@@ -1,11 +1,38 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
type SVG = React.ReactNode &
|
|
3
|
-
type
|
|
2
|
+
declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
3
|
+
declare type IconProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Defines the style of the bullet point in the list.
|
|
6
|
+
*/
|
|
7
|
+
type: "icon";
|
|
8
|
+
/**
|
|
9
|
+
* Icon to display as bullet.
|
|
10
|
+
*/
|
|
11
|
+
icon: string | SVG;
|
|
12
|
+
/**
|
|
13
|
+
* Text to be shown in the list.
|
|
14
|
+
*/
|
|
4
15
|
children: React.ReactNode;
|
|
5
|
-
type?: "disc" | "circle" | "square" | "number" | "icon";
|
|
6
|
-
icon?: string | SVG;
|
|
7
16
|
};
|
|
17
|
+
declare type OtherProps = {
|
|
18
|
+
/**
|
|
19
|
+
* Defines the style of the bullet point in the list.
|
|
20
|
+
*/
|
|
21
|
+
type?: "disc" | "circle" | "square" | "number";
|
|
22
|
+
/**
|
|
23
|
+
* Icon to display as bullet.
|
|
24
|
+
*/
|
|
25
|
+
icon?: never;
|
|
26
|
+
/**
|
|
27
|
+
* Text to be shown in the list.
|
|
28
|
+
*/
|
|
29
|
+
children: React.ReactNode;
|
|
30
|
+
};
|
|
31
|
+
declare type Props = IconProps | OtherProps;
|
|
8
32
|
export default Props;
|
|
9
|
-
export type BulletedListItemPropsType = {
|
|
33
|
+
export declare type BulletedListItemPropsType = {
|
|
34
|
+
/**
|
|
35
|
+
* Text to be shown in the list.
|
|
36
|
+
*/
|
|
10
37
|
children?: React.ReactNode;
|
|
11
38
|
};
|
package/button/Button.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import ButtonPropsType from "./types";
|
|
3
|
-
declare const DxcButton: ({ label, mode, disabled, iconPosition, type, icon, onClick, margin, size, tabIndex, }: ButtonPropsType) => JSX.Element;
|
|
3
|
+
declare const DxcButton: ({ label, mode, disabled, iconPosition, title, type, icon, onClick, margin, size, tabIndex, }: ButtonPropsType) => JSX.Element;
|
|
4
4
|
export default DxcButton;
|
package/button/Button.js
CHANGED
|
@@ -1,84 +1,106 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
8
10
|
exports["default"] = void 0;
|
|
11
|
+
|
|
9
12
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
+
|
|
10
14
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
15
|
+
|
|
11
16
|
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
+
|
|
12
18
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
19
|
+
|
|
13
20
|
var _variables = require("../common/variables");
|
|
14
|
-
|
|
21
|
+
|
|
22
|
+
var _utils = require("../common/utils");
|
|
23
|
+
|
|
15
24
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
|
+
|
|
16
26
|
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
27
|
+
|
|
17
28
|
var _templateObject, _templateObject2, _templateObject3;
|
|
29
|
+
|
|
18
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
|
+
|
|
19
32
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
20
|
-
|
|
21
|
-
small: "42px",
|
|
22
|
-
medium: "120px",
|
|
23
|
-
large: "240px",
|
|
24
|
-
fillParent: "100%",
|
|
25
|
-
fitContent: "fit-content"
|
|
26
|
-
};
|
|
27
|
-
var calculateWidth = function calculateWidth(margin, size) {
|
|
28
|
-
if (size === "fillParent") {
|
|
29
|
-
return "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
|
|
30
|
-
}
|
|
31
|
-
return sizes[size];
|
|
32
|
-
};
|
|
33
|
+
|
|
33
34
|
var DxcButton = function DxcButton(_ref) {
|
|
34
35
|
var _ref$label = _ref.label,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
36
|
+
label = _ref$label === void 0 ? "" : _ref$label,
|
|
37
|
+
_ref$mode = _ref.mode,
|
|
38
|
+
mode = _ref$mode === void 0 ? "primary" : _ref$mode,
|
|
39
|
+
_ref$disabled = _ref.disabled,
|
|
40
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
41
|
+
_ref$iconPosition = _ref.iconPosition,
|
|
42
|
+
iconPosition = _ref$iconPosition === void 0 ? "before" : _ref$iconPosition,
|
|
43
|
+
title = _ref.title,
|
|
44
|
+
_ref$type = _ref.type,
|
|
45
|
+
type = _ref$type === void 0 ? "button" : _ref$type,
|
|
46
|
+
icon = _ref.icon,
|
|
47
|
+
_ref$onClick = _ref.onClick,
|
|
48
|
+
_onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick,
|
|
49
|
+
margin = _ref.margin,
|
|
50
|
+
_ref$size = _ref.size,
|
|
51
|
+
size = _ref$size === void 0 ? "fitContent" : _ref$size,
|
|
52
|
+
_ref$tabIndex = _ref.tabIndex,
|
|
53
|
+
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
54
|
+
|
|
52
55
|
var colorsTheme = (0, _useTheme["default"])();
|
|
53
56
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
54
57
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
55
|
-
theme: colorsTheme
|
|
58
|
+
theme: colorsTheme.button
|
|
56
59
|
}, /*#__PURE__*/_react["default"].createElement(Button, {
|
|
57
|
-
|
|
58
|
-
mode: mode !== "primary" && mode !== "secondary" && mode !== "text" ? "primary" : mode,
|
|
60
|
+
"aria-label": title,
|
|
59
61
|
disabled: disabled,
|
|
60
|
-
|
|
62
|
+
onClick: function onClick() {
|
|
63
|
+
_onClick();
|
|
64
|
+
},
|
|
61
65
|
tabIndex: disabled ? -1 : tabIndex,
|
|
66
|
+
title: title,
|
|
67
|
+
type: type,
|
|
68
|
+
$mode: mode !== "primary" && mode !== "secondary" && mode !== "text" ? "primary" : mode,
|
|
69
|
+
hasLabel: label ? true : false,
|
|
70
|
+
hasIcon: icon ? true : false,
|
|
71
|
+
iconPosition: iconPosition,
|
|
62
72
|
backgroundType: backgroundType,
|
|
63
73
|
size: size,
|
|
64
|
-
margin: margin
|
|
65
|
-
|
|
66
|
-
_onClick();
|
|
67
|
-
}
|
|
68
|
-
}, label && iconPosition === "after" && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
|
|
69
|
-
icon: icon,
|
|
70
|
-
iconPosition: iconPosition
|
|
71
|
-
}, label), icon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
72
|
-
label: label,
|
|
73
|
-
iconPosition: iconPosition
|
|
74
|
-
}, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
74
|
+
margin: margin
|
|
75
|
+
}, label && /*#__PURE__*/_react["default"].createElement(LabelContainer, null, label), icon && /*#__PURE__*/_react["default"].createElement(IconContainer, null, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
75
76
|
src: icon
|
|
76
|
-
}) : icon)
|
|
77
|
-
icon: icon,
|
|
78
|
-
iconPosition: iconPosition
|
|
79
|
-
}, label)));
|
|
77
|
+
}) : icon)));
|
|
80
78
|
};
|
|
81
|
-
|
|
79
|
+
|
|
80
|
+
var sizes = {
|
|
81
|
+
small: "42px",
|
|
82
|
+
medium: "120px",
|
|
83
|
+
large: "240px",
|
|
84
|
+
fillParent: "100%",
|
|
85
|
+
fitContent: "fit-content"
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
var calculateWidth = function calculateWidth(margin, size) {
|
|
89
|
+
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
var getButtonStyles = function getButtonStyles(props) {
|
|
93
|
+
var $mode = props.$mode,
|
|
94
|
+
backgroundType = props.backgroundType,
|
|
95
|
+
disabled = props.disabled;
|
|
96
|
+
return "\n border-radius: ".concat($mode === "primary" ? props.theme.primaryBorderRadius : $mode === "secondary" ? props.theme.secondaryBorderRadius : props.theme.textBorderRadius, ";\n border-width: ").concat($mode === "primary" ? props.theme.primaryBorderThickness : $mode === "secondary" ? props.theme.secondaryBorderThickness : props.theme.textBorderThickness, ";\n border-style: ").concat($mode === "primary" ? props.theme.primaryBorderStyle : $mode === "secondary" ? props.theme.secondaryBorderStyle : props.theme.textBorderStyle, ";\n font-family: ").concat($mode === "primary" ? props.theme.primaryFontFamily : $mode === "secondary" ? props.theme.secondaryFontFamily : props.theme.textFontFamily, ";\n font-size: ").concat($mode === "primary" ? props.theme.primaryFontSize : $mode === "secondary" ? props.theme.secondaryFontSize : props.theme.textFontSize, ";\n font-weight: ").concat($mode === "primary" ? props.theme.primaryFontWeight : $mode === "secondary" ? props.theme.secondaryFontWeight : props.theme.textFontWeight, ";\n background-color: ").concat($mode === "primary" ? backgroundType === "dark" ? props.theme.primaryBackgroundColorOnDark : props.theme.primaryBackgroundColor : $mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryBackgroundColorOnDark : props.theme.secondaryBackgroundColor : backgroundType === "dark" ? props.theme.textBackgroundColorOnDark : props.theme.textBackgroundColor, ";\n color: ").concat($mode === "primary" ? backgroundType === "dark" ? props.theme.primaryFontColorOnDark : props.theme.primaryFontColor : $mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryFontColorOnDark : props.theme.secondaryFontColor : backgroundType === "dark" ? props.theme.textFontColorOnDark : props.theme.textFontColor, ";\n border-color: ").concat($mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryBorderColorOnDark : props.theme.secondaryBorderColor : "", ";\n &:hover {\n background-color: ").concat($mode === "primary" ? backgroundType === "dark" ? props.theme.primaryHoverBackgroundColorOnDark : props.theme.primaryHoverBackgroundColor : $mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryHoverBackgroundColorOnDark : props.theme.secondaryHoverBackgroundColor : backgroundType === "dark" ? props.theme.textHoverBackgroundColorOnDark : props.theme.textHoverBackgroundColor, ";\n color: ").concat($mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor : "", ";\n }\n &:focus {\n border-color: ").concat($mode === "secondary" ? "transparent" : "", ";\n }\n &:active {\n background-color: ").concat($mode === "primary" ? backgroundType === "dark" ? props.theme.primaryActiveBackgroundColorOnDark : props.theme.primaryActiveBackgroundColor : $mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryActiveBackgroundColorOnDark : props.theme.secondaryActiveBackgroundColor : backgroundType === "dark" ? props.theme.textActiveBackgroundColorOnDark : props.theme.textActiveBackgroundColor, ";\n color: ").concat($mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor : "", ";\n border-color: ").concat($mode === "secondary" ? "transparent" : "", ";\n outline: none;\n box-shadow: ").concat(!disabled ? "0 0 0 2px ".concat(backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor) : "", ";\n }\n &:disabled {\n cursor: not-allowed;\n background-color: ").concat($mode === "primary" ? backgroundType === "dark" ? props.theme.primaryDisabledBackgroundColorOnDark : props.theme.primaryDisabledBackgroundColor : $mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryDisabledBackgroundColorOnDark : props.theme.secondaryDisabledBackgroundColor : backgroundType === "dark" ? props.theme.textDisabledBackgroundColorOnDark : props.theme.textDisabledBackgroundColor, ";\n color: ").concat($mode === "primary" ? backgroundType === "dark" ? props.theme.primaryDisabledFontColorOnDark : props.theme.primaryDisabledFontColor : $mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryDisabledFontColorOnDark : props.theme.secondaryDisabledFontColor : backgroundType === "dark" ? props.theme.textDisabledFontColorOnDark : props.theme.textDisabledFontColor, ";\n border-color: ").concat($mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryDisabledBorderColorOnDark : props.theme.secondaryDisabledBorderColor : "", ";\n }\n ");
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
var Button = _styledComponents["default"].button(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n flex-direction: ", ";\n gap: 0.5rem;\n align-items: center;\n justify-content: center;\n width: ", ";\n height: 40px;\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n padding-right: ", ";\n box-shadow: 0 0 0 2px transparent;\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n letter-spacing: ", ";\n cursor: pointer;\n\n &:focus {\n outline: none;\n box-shadow: 0 0 0 2px\n ", ";\n }\n\n ", "\n"])), function (props) {
|
|
100
|
+
return props.iconPosition === "after" ? "row" : "row-reverse";
|
|
101
|
+
}, function (props) {
|
|
102
|
+
return calculateWidth(props.margin, props.size);
|
|
103
|
+
}, function (props) {
|
|
82
104
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
83
105
|
}, function (props) {
|
|
84
106
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
|
|
@@ -88,16 +110,14 @@ var Button = _styledComponents["default"].button(_templateObject || (_templateOb
|
|
|
88
110
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
|
|
89
111
|
}, function (props) {
|
|
90
112
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
91
|
-
}, function (props) {
|
|
92
|
-
return calculateWidth(props.margin, props.size);
|
|
93
|
-
}, function (props) {
|
|
94
|
-
return props.theme.paddingLeft;
|
|
95
|
-
}, function (props) {
|
|
96
|
-
return props.theme.paddingRight;
|
|
97
113
|
}, function (props) {
|
|
98
114
|
return props.theme.paddingTop;
|
|
99
115
|
}, function (props) {
|
|
100
116
|
return props.theme.paddingBottom;
|
|
117
|
+
}, function (props) {
|
|
118
|
+
return props.hasIcon && !props.hasLabel ? props.theme.paddingLeft : "calc(".concat(props.theme.paddingLeft, " + 8px)");
|
|
119
|
+
}, function (props) {
|
|
120
|
+
return props.hasIcon && !props.hasLabel ? props.theme.paddingRight : "calc(".concat(props.theme.paddingRight, " + 8px)");
|
|
101
121
|
}, function (props) {
|
|
102
122
|
return props.theme.fontFamily;
|
|
103
123
|
}, function (props) {
|
|
@@ -109,24 +129,16 @@ var Button = _styledComponents["default"].button(_templateObject || (_templateOb
|
|
|
109
129
|
}, function (props) {
|
|
110
130
|
return props.backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor;
|
|
111
131
|
}, function (props) {
|
|
112
|
-
|
|
113
|
-
backgroundType = props.backgroundType,
|
|
114
|
-
disabled = props.disabled;
|
|
115
|
-
return "\n border-radius: ".concat(props.mode === "primary" ? props.theme.primaryBorderRadius : props.mode === "secondary" ? props.theme.secondaryBorderRadius : props.theme.textBorderRadius, ";\n border-width: ").concat(props.mode === "primary" ? props.theme.primaryBorderThickness : props.mode === "secondary" ? props.theme.secondaryBorderThickness : props.theme.textBorderThickness, ";\n border-style: ").concat(mode === "primary" ? props.theme.primaryBorderStyle : mode === "secondary" ? props.theme.secondaryBorderStyle : props.theme.textBorderStyle, ";\n font-family: ").concat(mode === "primary" ? props.theme.primaryFontFamily : mode === "secondary" ? props.theme.secondaryFontFamily : props.theme.textFontFamily, ";\n font-size: ").concat(mode === "primary" ? props.theme.primaryFontSize : mode === "secondary" ? props.theme.secondaryFontSize : props.theme.textFontSize, ";\n font-weight: ").concat(mode === "primary" ? props.theme.primaryFontWeight : mode === "secondary" ? props.theme.secondaryFontWeight : props.theme.textFontWeight, ";\n background-color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryBackgroundColorOnDark : props.theme.primaryBackgroundColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryBackgroundColorOnDark : props.theme.secondaryBackgroundColor : backgroundType === "dark" ? props.theme.textBackgroundColorOnDark : props.theme.textBackgroundColor, ";\n color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryFontColorOnDark : props.theme.primaryFontColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryFontColorOnDark : props.theme.secondaryFontColor : backgroundType === "dark" ? props.theme.textFontColorOnDark : props.theme.textFontColor, ";\n border-color: ").concat(mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryBorderColorOnDark : props.theme.secondaryBorderColor : "", ";\n &:hover {\n background-color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryHoverBackgroundColorOnDark : props.theme.primaryHoverBackgroundColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryHoverBackgroundColorOnDark : props.theme.secondaryHoverBackgroundColor : backgroundType === "dark" ? props.theme.textHoverBackgroundColorOnDark : props.theme.textHoverBackgroundColor, ";\n color: ").concat(mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor : "", ";\n }\n &:focus {\n border-color: ").concat(mode === "secondary" ? "transparent" : "", ";\n }\n &:active {\n background-color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryActiveBackgroundColorOnDark : props.theme.primaryActiveBackgroundColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryActiveBackgroundColorOnDark : props.theme.secondaryActiveBackgroundColor : backgroundType === "dark" ? props.theme.textActiveBackgroundColorOnDark : props.theme.textActiveBackgroundColor, ";\n color: ").concat(mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor : "", ";\n border-color: ").concat(mode === "secondary" ? "transparent" : "", ";\n outline: none;\n box-shadow: ").concat(!disabled ? "0 0 0 2px ".concat(backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor) : "", ";\n }\n &:disabled {\n cursor: not-allowed;\n background-color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryDisabledBackgroundColorOnDark : props.theme.primaryDisabledBackgroundColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryDisabledBackgroundColorOnDark : props.theme.secondaryDisabledBackgroundColor : backgroundType === "dark" ? props.theme.textDisabledBackgroundColorOnDark : props.theme.textDisabledBackgroundColor, ";\n color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryDisabledFontColorOnDark : props.theme.primaryDisabledFontColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryDisabledFontColorOnDark : props.theme.secondaryDisabledFontColor : backgroundType === "dark" ? props.theme.textDisabledFontColorOnDark : props.theme.textDisabledFontColor, ";\n border-color: ").concat(mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryDisabledBorderColorOnDark : props.theme.secondaryDisabledBorderColor : "", ";\n }\n ");
|
|
132
|
+
return getButtonStyles(props);
|
|
116
133
|
});
|
|
117
|
-
|
|
134
|
+
|
|
135
|
+
var LabelContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n line-height: ", ";\n font-size: ", ";\n text-overflow: ellipsis;\n overflow: hidden;\n text-transform: none;\n white-space: nowrap;\n"])), function (props) {
|
|
118
136
|
return props.theme.labelFontLineHeight;
|
|
119
137
|
}, function (props) {
|
|
120
138
|
return props.theme.fontSize;
|
|
121
|
-
}, function (props) {
|
|
122
|
-
return !props.icon || props.iconPosition === "before" ? "8px" : "0px";
|
|
123
|
-
}, function (props) {
|
|
124
|
-
return !props.icon || props.iconPosition === "after" ? "8px" : "0px";
|
|
125
|
-
});
|
|
126
|
-
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) {
|
|
127
|
-
return !props.label ? "0px" : props.iconPosition === "after" && props.label !== "" && "8px" || "8px";
|
|
128
|
-
}, function (props) {
|
|
129
|
-
return !props.label ? "0px" : props.iconPosition === "before" && props.label !== "" && "8px" || "8px";
|
|
130
139
|
});
|
|
140
|
+
|
|
141
|
+
var IconContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n img,\n svg {\n height: 24px;\n width: 24px;\n }\n"])));
|
|
142
|
+
|
|
131
143
|
var _default = DxcButton;
|
|
132
144
|
exports["default"] = _default;
|
|
@@ -98,7 +98,7 @@ export const Chromatic = () => (
|
|
|
98
98
|
</ExampleContainer>
|
|
99
99
|
<ExampleContainer>
|
|
100
100
|
<Title title="Big icon (image)" theme="light" level={4} />
|
|
101
|
-
<DxcButton icon="https://
|
|
101
|
+
<DxcButton icon="https://www.freepnglogos.com/uploads/facebook-logo-design-1.png" />
|
|
102
102
|
</ExampleContainer>
|
|
103
103
|
<ExampleContainer>
|
|
104
104
|
<Title title="Small icon" theme="light" level={4} />
|
|
@@ -133,7 +133,7 @@ export const Chromatic = () => (
|
|
|
133
133
|
<Title title="Only icon (image)" theme="light" level={4} />
|
|
134
134
|
<DxcButton
|
|
135
135
|
mode="secondary"
|
|
136
|
-
icon="https://
|
|
136
|
+
icon="https://www.freepnglogos.com/uploads/facebook-logo-design-1.png"
|
|
137
137
|
/>
|
|
138
138
|
</ExampleContainer>
|
|
139
139
|
<Title title="Text" theme="light" level={2} />
|
|
@@ -165,7 +165,7 @@ export const Chromatic = () => (
|
|
|
165
165
|
<Title title="Only icon (image)" theme="light" level={4} />
|
|
166
166
|
<DxcButton
|
|
167
167
|
mode="text"
|
|
168
|
-
icon="https://
|
|
168
|
+
icon="https://www.freepnglogos.com/uploads/facebook-logo-design-1.png"
|
|
169
169
|
/>
|
|
170
170
|
</ExampleContainer>
|
|
171
171
|
<BackgroundColorProvider color="#333333">
|
|
@@ -339,7 +339,7 @@ export const Chromatic = () => (
|
|
|
339
339
|
</ExampleContainer>
|
|
340
340
|
<Title title="Inside a flex" theme="light" level={2} />
|
|
341
341
|
<ExampleContainer>
|
|
342
|
-
<DxcFlex direction="column" gap="
|
|
342
|
+
<DxcFlex direction="column" gap="1rem">
|
|
343
343
|
<DxcButton label="Button" />
|
|
344
344
|
<DxcButton label="Button" />
|
|
345
345
|
<DxcButton label="Button" />
|
package/button/Button.test.js
CHANGED
|
@@ -1,26 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
|
|
5
7
|
var _react2 = require("@testing-library/react");
|
|
6
|
-
|
|
8
|
+
|
|
9
|
+
var _Button = _interopRequireDefault(require("./Button.tsx"));
|
|
10
|
+
|
|
7
11
|
describe("Button component tests", function () {
|
|
8
12
|
test("Button renders with correct text", function () {
|
|
9
13
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
label: "Button"
|
|
15
|
+
})),
|
|
16
|
+
getByText = _render.getByText;
|
|
17
|
+
|
|
13
18
|
expect(getByText("Button")).toBeTruthy();
|
|
14
19
|
});
|
|
15
20
|
test("Calls correct function on click", function () {
|
|
16
21
|
var onClick = jest.fn();
|
|
22
|
+
|
|
17
23
|
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
label: "Button",
|
|
25
|
+
onClick: onClick
|
|
26
|
+
})),
|
|
27
|
+
getByText = _render2.getByText;
|
|
28
|
+
|
|
22
29
|
var button = getByText("Button");
|
|
30
|
+
|
|
23
31
|
_react2.fireEvent.click(button);
|
|
32
|
+
|
|
24
33
|
expect(onClick).toHaveBeenCalled();
|
|
25
34
|
});
|
|
35
|
+
test("Renders with correct accessibility attributes", function () {
|
|
36
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
37
|
+
label: "Home",
|
|
38
|
+
title: "Go home"
|
|
39
|
+
})),
|
|
40
|
+
getByRole = _render3.getByRole;
|
|
41
|
+
|
|
42
|
+
var button = getByRole("button");
|
|
43
|
+
expect(button.getAttribute("aria-label")).toBe("Go home");
|
|
44
|
+
expect(button.getAttribute("title")).toBe("Go home");
|
|
45
|
+
});
|
|
26
46
|
});
|
package/button/types.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
+
declare type Margin = {
|
|
4
4
|
top?: Space;
|
|
5
5
|
bottom?: Space;
|
|
6
6
|
left?: Space;
|
|
7
7
|
right?: Space;
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
type Props = {
|
|
9
|
+
declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
10
|
+
declare type Props = {
|
|
11
11
|
/**
|
|
12
12
|
* Text to be placed in the button.
|
|
13
13
|
*/
|
|
@@ -24,6 +24,10 @@ type Props = {
|
|
|
24
24
|
* Whether the icon should appear after or before the label.
|
|
25
25
|
*/
|
|
26
26
|
iconPosition?: "before" | "after";
|
|
27
|
+
/**
|
|
28
|
+
* Value for the HTML properties title and aria-label.
|
|
29
|
+
*/
|
|
30
|
+
title?: string;
|
|
27
31
|
/**
|
|
28
32
|
* 'type' html prop of the button.
|
|
29
33
|
*/
|
package/card/Card.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import CardPropsType from "./types";
|
|
3
|
-
declare const DxcCard: ({ imageSrc, imageBgColor, imagePadding, imagePosition, linkHref, onClick, imageCover, margin,
|
|
3
|
+
declare const DxcCard: ({ imageSrc, imageBgColor, imagePadding, imagePosition, linkHref, onClick, imageCover, margin, tabIndex, outlined, children, }: CardPropsType) => JSX.Element;
|
|
4
4
|
export default DxcCard;
|
package/card/Card.js
CHANGED
|
@@ -1,53 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
8
10
|
exports["default"] = void 0;
|
|
11
|
+
|
|
9
12
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
+
|
|
10
14
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
15
|
+
|
|
11
16
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
|
+
|
|
12
18
|
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
+
|
|
13
20
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
21
|
+
|
|
14
22
|
var _variables = require("../common/variables");
|
|
23
|
+
|
|
15
24
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
|
+
|
|
16
26
|
var _Box = _interopRequireDefault(require("../box/Box"));
|
|
27
|
+
|
|
17
28
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
29
|
+
|
|
18
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
|
+
|
|
19
32
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
+
|
|
20
34
|
var DxcCard = function DxcCard(_ref) {
|
|
21
35
|
var imageSrc = _ref.imageSrc,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
children = _ref.children;
|
|
36
|
+
_ref$imageBgColor = _ref.imageBgColor,
|
|
37
|
+
imageBgColor = _ref$imageBgColor === void 0 ? "black" : _ref$imageBgColor,
|
|
38
|
+
imagePadding = _ref.imagePadding,
|
|
39
|
+
_ref$imagePosition = _ref.imagePosition,
|
|
40
|
+
imagePosition = _ref$imagePosition === void 0 ? "before" : _ref$imagePosition,
|
|
41
|
+
linkHref = _ref.linkHref,
|
|
42
|
+
onClick = _ref.onClick,
|
|
43
|
+
_ref$imageCover = _ref.imageCover,
|
|
44
|
+
imageCover = _ref$imageCover === void 0 ? false : _ref$imageCover,
|
|
45
|
+
margin = _ref.margin,
|
|
46
|
+
_ref$tabIndex = _ref.tabIndex,
|
|
47
|
+
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex,
|
|
48
|
+
_ref$outlined = _ref.outlined,
|
|
49
|
+
outlined = _ref$outlined === void 0 ? true : _ref$outlined,
|
|
50
|
+
children = _ref.children;
|
|
38
51
|
var colorsTheme = (0, _useTheme["default"])();
|
|
52
|
+
|
|
39
53
|
var _useState = (0, _react.useState)(false),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
imagePadding: imagePadding,
|
|
47
|
-
cover: imageCover,
|
|
48
|
-
src: imageSrc
|
|
49
|
-
}));
|
|
50
|
-
return /*#__PURE__*/_react["default"].createElement(StyledDxcCard, {
|
|
54
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
55
|
+
isHovered = _useState2[0],
|
|
56
|
+
changeIsHovered = _useState2[1];
|
|
57
|
+
|
|
58
|
+
return /*#__PURE__*/_react["default"].createElement(Card, {
|
|
59
|
+
hasAction: onClick || linkHref ? true : false,
|
|
51
60
|
margin: margin,
|
|
52
61
|
onMouseEnter: function onMouseEnter() {
|
|
53
62
|
return changeIsHovered(true);
|
|
@@ -56,22 +65,26 @@ var DxcCard = function DxcCard(_ref) {
|
|
|
56
65
|
return changeIsHovered(false);
|
|
57
66
|
},
|
|
58
67
|
onClick: onClick,
|
|
59
|
-
hasAction: onClick || linkHref,
|
|
60
68
|
tabIndex: onClick || linkHref ? tabIndex : -1,
|
|
61
69
|
as: linkHref && "a",
|
|
62
70
|
href: linkHref
|
|
63
71
|
}, /*#__PURE__*/_react["default"].createElement(_Box["default"], {
|
|
64
72
|
shadowDepth: !outlined ? 0 : isHovered && (onClick || linkHref) ? 2 : 1
|
|
65
73
|
}, /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
66
|
-
theme: colorsTheme
|
|
74
|
+
theme: colorsTheme.card
|
|
67
75
|
}, /*#__PURE__*/_react["default"].createElement(CardContainer, {
|
|
68
|
-
hasAction: onClick || linkHref,
|
|
69
|
-
imagePosition: imagePosition
|
|
70
|
-
}, imageSrc &&
|
|
71
|
-
|
|
72
|
-
},
|
|
76
|
+
hasAction: onClick || linkHref ? true : false,
|
|
77
|
+
imagePosition: imageSrc ? imagePosition : "none"
|
|
78
|
+
}, imageSrc && /*#__PURE__*/_react["default"].createElement(ImageContainer, {
|
|
79
|
+
imageBgColor: imageBgColor
|
|
80
|
+
}, /*#__PURE__*/_react["default"].createElement(TagImage, {
|
|
81
|
+
imagePadding: imagePadding,
|
|
82
|
+
imageCover: imageCover,
|
|
83
|
+
src: imageSrc
|
|
84
|
+
})), /*#__PURE__*/_react["default"].createElement(CardContent, null, children)))));
|
|
73
85
|
};
|
|
74
|
-
|
|
86
|
+
|
|
87
|
+
var Card = _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 text-decoration: none;\n ", "\n"])), function (_ref2) {
|
|
75
88
|
var hasAction = _ref2.hasAction;
|
|
76
89
|
return hasAction && "pointer" || "unset";
|
|
77
90
|
}, function (_ref3) {
|
|
@@ -82,21 +95,24 @@ var StyledDxcCard = _styledComponents["default"].div(_templateObject || (_templa
|
|
|
82
95
|
return margin && (0, _typeof2["default"])(margin) !== "object" ? _variables.spaces[margin] : "0px";
|
|
83
96
|
}, function (_ref5) {
|
|
84
97
|
var margin = _ref5.margin;
|
|
85
|
-
return margin && margin.top ? _variables.spaces[margin.top] : "";
|
|
98
|
+
return margin && (0, _typeof2["default"])(margin) === "object" && margin.top ? _variables.spaces[margin.top] : "";
|
|
86
99
|
}, function (_ref6) {
|
|
87
100
|
var margin = _ref6.margin;
|
|
88
|
-
return margin && margin.right ? _variables.spaces[margin.right] : "";
|
|
101
|
+
return margin && (0, _typeof2["default"])(margin) === "object" && margin.right ? _variables.spaces[margin.right] : "";
|
|
89
102
|
}, function (_ref7) {
|
|
90
103
|
var margin = _ref7.margin;
|
|
91
|
-
return margin && margin.bottom ? _variables.spaces[margin.bottom] : "";
|
|
104
|
+
return margin && (0, _typeof2["default"])(margin) === "object" && margin.bottom ? _variables.spaces[margin.bottom] : "";
|
|
92
105
|
}, function (_ref8) {
|
|
93
106
|
var margin = _ref8.margin;
|
|
94
|
-
return margin && margin.left ? _variables.spaces[margin.left] : "";
|
|
107
|
+
return margin && (0, _typeof2["default"])(margin) === "object" && margin.left ? _variables.spaces[margin.left] : "";
|
|
95
108
|
}, function (_ref9) {
|
|
96
109
|
var hasAction = _ref9.hasAction;
|
|
97
|
-
return hasAction && ":focus {\n
|
|
110
|
+
return hasAction && ":focus {\n outline: #0095ff auto 1px;\n }";
|
|
98
111
|
});
|
|
99
|
-
|
|
112
|
+
|
|
113
|
+
var CardContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n flex-direction: ", ";\n height: ", ";\n width: ", ";\n &:hover {\n border-color: ", ";\n }\n"])), function (props) {
|
|
114
|
+
return props.imagePosition === "after" ? "row-reverse" : "row";
|
|
115
|
+
}, function (props) {
|
|
100
116
|
return props.theme.height;
|
|
101
117
|
}, function (props) {
|
|
102
118
|
return props.theme.width;
|
|
@@ -104,35 +120,24 @@ var CardContainer = _styledComponents["default"].div(_templateObject2 || (_templ
|
|
|
104
120
|
var hasAction = _ref10.hasAction;
|
|
105
121
|
return hasAction ? "" : "unset";
|
|
106
122
|
});
|
|
123
|
+
|
|
107
124
|
var TagImage = _styledComponents["default"].img(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n height: ", ";\n width: ", ";\n object-fit: ", ";\n"])), function (_ref11) {
|
|
108
125
|
var imagePadding = _ref11.imagePadding;
|
|
109
|
-
return !imagePadding ? "100%" : "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
|
|
126
|
+
return !imagePadding ? "100%" : (0, _typeof2["default"])(imagePadding) !== "object" && "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
|
|
110
127
|
}, function (_ref12) {
|
|
111
128
|
var imagePadding = _ref12.imagePadding;
|
|
112
|
-
return !imagePadding ? "100%" : "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
|
|
129
|
+
return !imagePadding ? "100%" : (0, _typeof2["default"])(imagePadding) !== "object" && "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
|
|
113
130
|
}, function (_ref13) {
|
|
114
|
-
var
|
|
115
|
-
return
|
|
131
|
+
var imageCover = _ref13.imageCover;
|
|
132
|
+
return imageCover ? "cover" : "contain";
|
|
116
133
|
});
|
|
117
|
-
|
|
134
|
+
|
|
135
|
+
var ImageContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n justify-content: center;\n align-items: center;\n flex-shrink: 0;\n width: 35%;\n height: 100%;\n background-color: ", ";\n"])), function (_ref14) {
|
|
118
136
|
var imageBgColor = _ref14.imageBgColor;
|
|
119
137
|
return imageBgColor;
|
|
120
138
|
});
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}, function (_ref16) {
|
|
125
|
-
var contentPadding = _ref16.contentPadding;
|
|
126
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.top ? _variables.spaces[contentPadding.top] : "";
|
|
127
|
-
}, function (_ref17) {
|
|
128
|
-
var contentPadding = _ref17.contentPadding;
|
|
129
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.right ? _variables.spaces[contentPadding.right] : "";
|
|
130
|
-
}, function (_ref18) {
|
|
131
|
-
var contentPadding = _ref18.contentPadding;
|
|
132
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.bottom ? _variables.spaces[contentPadding.bottom] : "";
|
|
133
|
-
}, function (_ref19) {
|
|
134
|
-
var contentPadding = _ref19.contentPadding;
|
|
135
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.left ? _variables.spaces[contentPadding.left] : "";
|
|
136
|
-
});
|
|
139
|
+
|
|
140
|
+
var CardContent = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n flex-grow: 1;\n overflow: hidden;\n"])));
|
|
141
|
+
|
|
137
142
|
var _default = DxcCard;
|
|
138
143
|
exports["default"] = _default;
|