@dxc-technology/halstack-react 0.0.0-d3ac293 → 0.0.0-d3df47e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BackgroundColorContext.d.ts +1 -10
- package/BackgroundColorContext.js +4 -21
- package/HalstackContext.d.ts +24 -139
- package/HalstackContext.js +11 -36
- package/README.md +47 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +26 -83
- package/accordion/Accordion.stories.tsx +2 -114
- package/accordion/Accordion.test.js +18 -33
- package/accordion/types.d.ts +5 -17
- package/accordion-group/AccordionGroup.d.ts +4 -3
- package/accordion-group/AccordionGroup.js +27 -75
- package/accordion-group/AccordionGroup.stories.tsx +78 -77
- package/accordion-group/AccordionGroup.test.js +43 -71
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +31 -0
- package/accordion-group/types.d.ts +6 -18
- package/action-icon/ActionIcon.d.ts +4 -0
- package/action-icon/ActionIcon.js +47 -0
- package/action-icon/ActionIcon.stories.tsx +41 -0
- package/action-icon/ActionIcon.test.js +64 -0
- package/action-icon/types.d.ts +26 -0
- package/alert/Alert.js +17 -56
- package/alert/Alert.test.js +28 -45
- package/alert/types.d.ts +5 -5
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +142 -42
- package/badge/Badge.stories.tsx +210 -0
- package/badge/Badge.test.js +30 -0
- package/badge/types.d.ts +52 -3
- package/bleed/Bleed.js +13 -21
- package/bleed/Bleed.stories.tsx +1 -0
- package/bleed/types.d.ts +2 -2
- package/box/Box.d.ts +1 -1
- package/box/Box.js +16 -55
- package/box/Box.stories.tsx +25 -53
- package/box/Box.test.js +1 -6
- package/box/types.d.ts +3 -15
- package/bulleted-list/BulletedList.js +19 -53
- package/bulleted-list/BulletedList.stories.tsx +8 -93
- package/bulleted-list/types.d.ts +32 -5
- package/button/Button.d.ts +1 -1
- package/button/Button.js +66 -100
- package/button/Button.stories.tsx +9 -90
- package/button/Button.test.js +19 -16
- package/button/types.d.ts +8 -4
- package/card/Card.d.ts +1 -1
- package/card/Card.js +47 -88
- package/card/Card.stories.tsx +12 -42
- package/card/Card.test.js +10 -21
- package/card/types.d.ts +6 -12
- package/checkbox/Checkbox.js +85 -120
- package/checkbox/Checkbox.stories.tsx +16 -54
- package/checkbox/Checkbox.test.js +107 -63
- package/checkbox/types.d.ts +8 -4
- package/chip/Chip.js +34 -68
- package/chip/Chip.stories.tsx +25 -17
- package/chip/Chip.test.js +15 -28
- package/chip/types.d.ts +4 -4
- package/common/OpenSans.css +68 -80
- package/common/coreTokens.d.ts +237 -0
- package/common/coreTokens.js +184 -0
- package/common/utils.js +2 -8
- package/common/variables.d.ts +24 -282
- package/common/variables.js +860 -1125
- package/container/Container.d.ts +4 -0
- package/container/Container.js +194 -0
- package/container/Container.stories.tsx +214 -0
- package/container/types.d.ts +74 -0
- package/date-input/Calendar.js +15 -59
- package/date-input/DateInput.js +50 -96
- package/date-input/DateInput.stories.tsx +11 -30
- package/date-input/DateInput.test.js +674 -701
- package/date-input/DatePicker.js +11 -42
- package/date-input/Icons.d.ts +6 -6
- package/date-input/Icons.js +6 -23
- package/date-input/YearPicker.js +8 -34
- package/date-input/types.d.ts +27 -21
- package/dialog/Dialog.d.ts +1 -1
- package/dialog/Dialog.js +15 -60
- package/dialog/Dialog.stories.tsx +215 -169
- package/dialog/Dialog.test.js +125 -187
- package/dialog/types.d.ts +18 -26
- package/dropdown/Dropdown.js +39 -93
- package/dropdown/Dropdown.test.js +391 -378
- package/dropdown/DropdownMenu.js +13 -20
- package/dropdown/DropdownMenuItem.js +5 -19
- package/dropdown/types.d.ts +17 -19
- package/file-input/FileInput.js +180 -249
- package/file-input/FileInput.stories.tsx +1 -1
- package/file-input/FileInput.test.js +356 -354
- package/file-input/FileItem.js +14 -41
- package/file-input/types.d.ts +10 -10
- package/flex/Flex.js +27 -39
- 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 +69 -116
- package/footer/Footer.stories.tsx +38 -95
- package/footer/Footer.test.js +21 -33
- package/footer/Icons.d.ts +3 -2
- package/footer/Icons.js +66 -7
- package/footer/types.d.ts +25 -27
- package/grid/Grid.d.ts +7 -0
- package/grid/Grid.js +76 -0
- package/grid/Grid.stories.tsx +219 -0
- package/grid/types.d.ts +115 -0
- package/grid/types.js +5 -0
- package/header/Header.d.ts +4 -3
- package/header/Header.js +33 -116
- package/header/Header.stories.tsx +7 -71
- package/header/Header.test.js +12 -25
- package/header/Icons.d.ts +2 -2
- package/header/Icons.js +2 -7
- package/header/types.d.ts +5 -20
- package/heading/Heading.js +9 -31
- package/heading/Heading.test.js +70 -87
- package/heading/types.d.ts +7 -7
- package/image/Image.d.ts +4 -0
- package/image/Image.js +70 -0
- package/image/Image.stories.tsx +127 -0
- package/image/types.d.ts +72 -0
- package/image/types.js +5 -0
- package/inset/Inset.js +13 -21
- 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 +28 -65
- package/layout/ApplicationLayout.stories.tsx +1 -1
- package/layout/Icons.d.ts +8 -5
- package/layout/Icons.js +51 -59
- package/layout/SidenavContext.d.ts +1 -1
- package/layout/SidenavContext.js +3 -9
- package/layout/types.d.ts +5 -6
- package/link/Link.js +23 -44
- package/link/Link.test.js +23 -41
- package/link/types.d.ts +14 -14
- package/main.d.ts +7 -4
- package/main.js +32 -58
- package/nav-tabs/NavTabs.d.ts +2 -2
- package/nav-tabs/NavTabs.js +22 -54
- package/nav-tabs/NavTabs.stories.tsx +21 -5
- package/nav-tabs/NavTabs.test.js +38 -44
- package/nav-tabs/Tab.js +40 -72
- package/nav-tabs/types.d.ts +14 -15
- package/number-input/NumberInput.d.ts +7 -0
- package/number-input/NumberInput.js +26 -35
- package/number-input/NumberInput.stories.tsx +42 -26
- package/number-input/NumberInput.test.js +700 -412
- package/number-input/types.d.ts +11 -5
- package/package.json +30 -28
- package/paginator/Icons.d.ts +5 -5
- package/paginator/Icons.js +5 -19
- package/paginator/Paginator.js +17 -47
- package/paginator/Paginator.test.js +229 -199
- package/paginator/types.d.ts +3 -3
- package/paragraph/Paragraph.d.ts +2 -3
- package/paragraph/Paragraph.js +3 -19
- package/paragraph/Paragraph.stories.tsx +0 -17
- package/password-input/Icons.d.ts +6 -0
- package/password-input/Icons.js +35 -0
- package/password-input/PasswordInput.js +57 -126
- package/password-input/PasswordInput.stories.tsx +1 -33
- package/password-input/PasswordInput.test.js +157 -140
- package/password-input/types.d.ts +8 -7
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +21 -53
- package/progress-bar/{ProgressBar.stories.jsx → ProgressBar.stories.tsx} +1 -1
- package/progress-bar/ProgressBar.test.js +35 -52
- package/progress-bar/types.d.ts +4 -3
- package/quick-nav/QuickNav.js +4 -27
- package/quick-nav/QuickNav.stories.tsx +1 -1
- package/quick-nav/types.d.ts +10 -10
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +31 -63
- package/radio-group/RadioGroup.js +45 -93
- package/radio-group/RadioGroup.stories.tsx +10 -10
- package/radio-group/RadioGroup.test.js +504 -470
- package/radio-group/types.d.ts +8 -8
- package/resultset-table/Icons.d.ts +7 -0
- package/{resultsetTable → resultset-table}/Icons.js +1 -5
- package/{resultsetTable → resultset-table}/ResultsetTable.d.ts +1 -1
- package/{resultsetTable → resultset-table}/ResultsetTable.js +33 -63
- package/{resultsetTable → resultset-table}/ResultsetTable.stories.tsx +19 -0
- package/{resultsetTable → resultset-table}/ResultsetTable.test.js +72 -92
- package/{resultsetTable → resultset-table}/types.d.ts +13 -7
- package/resultset-table/types.js +5 -0
- package/select/Icons.d.ts +7 -7
- package/select/Icons.js +1 -5
- package/select/Listbox.js +13 -39
- package/select/Option.js +17 -27
- package/select/Select.js +92 -166
- package/select/Select.stories.tsx +3 -3
- package/select/Select.test.js +1946 -1804
- package/select/types.d.ts +14 -15
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +47 -0
- package/sidenav/Sidenav.d.ts +2 -2
- package/sidenav/Sidenav.js +80 -150
- package/sidenav/Sidenav.stories.tsx +60 -60
- package/sidenav/Sidenav.test.js +3 -10
- package/sidenav/types.d.ts +31 -28
- package/slider/Slider.js +68 -126
- package/slider/Slider.test.js +107 -103
- package/slider/types.d.ts +4 -4
- package/spinner/Spinner.js +28 -72
- package/spinner/{Spinner.stories.jsx → Spinner.stories.tsx} +28 -28
- package/spinner/Spinner.test.js +25 -34
- package/spinner/types.d.ts +3 -3
- package/status-light/StatusLight.d.ts +4 -0
- package/status-light/StatusLight.js +51 -0
- package/status-light/StatusLight.stories.tsx +74 -0
- package/status-light/StatusLight.test.js +25 -0
- package/status-light/types.d.ts +17 -0
- package/status-light/types.js +5 -0
- package/switch/Switch.js +49 -97
- package/switch/Switch.stories.tsx +0 -34
- package/switch/Switch.test.js +51 -96
- package/switch/types.d.ts +4 -4
- package/table/Table.d.ts +1 -1
- package/table/Table.js +23 -30
- package/table/{Table.stories.jsx → Table.stories.tsx} +98 -0
- package/table/Table.test.js +1 -6
- package/table/types.d.ts +12 -6
- package/tabs/Tab.js +19 -36
- package/tabs/Tabs.js +61 -144
- package/tabs/Tabs.stories.tsx +1 -1
- package/tabs/Tabs.test.js +65 -121
- package/tabs/types.d.ts +19 -19
- package/tag/Tag.js +26 -58
- package/tag/Tag.test.js +19 -30
- package/tag/types.d.ts +7 -7
- package/text-input/Icons.d.ts +5 -5
- package/text-input/Icons.js +1 -5
- package/text-input/Suggestion.js +11 -28
- package/text-input/Suggestions.d.ts +1 -1
- package/text-input/Suggestions.js +15 -65
- package/text-input/TextInput.js +217 -318
- package/text-input/TextInput.stories.tsx +48 -152
- package/text-input/TextInput.test.js +1210 -1194
- package/text-input/types.d.ts +25 -17
- package/textarea/Textarea.js +68 -111
- package/textarea/{Textarea.stories.jsx → Textarea.stories.tsx} +58 -100
- package/textarea/Textarea.test.js +151 -182
- package/textarea/types.d.ts +9 -5
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +91 -105
- package/toggle-group/ToggleGroup.stories.tsx +7 -4
- package/toggle-group/ToggleGroup.test.js +68 -87
- package/toggle-group/types.d.ts +26 -17
- package/typography/Typography.js +4 -13
- package/typography/types.d.ts +1 -1
- package/useTheme.d.ts +21 -136
- package/useTheme.js +1 -8
- package/useTranslatedLabels.js +1 -7
- package/utils/BaseTypography.d.ts +2 -2
- package/utils/BaseTypography.js +16 -30
- package/utils/FocusLock.js +28 -43
- package/wizard/Wizard.js +15 -50
- package/wizard/Wizard.test.js +53 -80
- package/wizard/types.d.ts +8 -9
- package/card/ice-cream.jpg +0 -0
- package/number-input/NumberInputContext.d.ts +0 -4
- package/number-input/NumberInputContext.js +0 -19
- package/number-input/numberInputContextTypes.d.ts +0 -19
- package/resultsetTable/Icons.d.ts +0 -7
- package/slider/Slider.stories.tsx +0 -240
- /package/{resultsetTable → action-icon}/types.js +0 -0
- /package/{number-input/numberInputContextTypes.js → container/types.js} +0 -0
package/button/types.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
+
type Margin = {
|
|
4
4
|
top?: Space;
|
|
5
5
|
bottom?: Space;
|
|
6
6
|
left?: Space;
|
|
7
7
|
right?: Space;
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
10
|
+
type Props = {
|
|
11
11
|
/**
|
|
12
12
|
* Text to be placed in the button.
|
|
13
13
|
*/
|
|
@@ -24,6 +24,10 @@ declare 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,70 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports["default"] = void 0;
|
|
11
|
-
|
|
12
9
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
-
|
|
14
10
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
15
|
-
|
|
16
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
|
-
|
|
18
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
-
|
|
20
13
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
21
|
-
|
|
22
14
|
var _variables = require("../common/variables");
|
|
23
|
-
|
|
24
15
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
|
-
|
|
26
16
|
var _Box = _interopRequireDefault(require("../box/Box"));
|
|
27
|
-
|
|
28
17
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
-
|
|
18
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
19
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
34
20
|
var DxcCard = function DxcCard(_ref) {
|
|
35
21
|
var imageSrc = _ref.imageSrc,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
children = _ref.children;
|
|
22
|
+
_ref$imageBgColor = _ref.imageBgColor,
|
|
23
|
+
imageBgColor = _ref$imageBgColor === void 0 ? "black" : _ref$imageBgColor,
|
|
24
|
+
imagePadding = _ref.imagePadding,
|
|
25
|
+
_ref$imagePosition = _ref.imagePosition,
|
|
26
|
+
imagePosition = _ref$imagePosition === void 0 ? "before" : _ref$imagePosition,
|
|
27
|
+
linkHref = _ref.linkHref,
|
|
28
|
+
onClick = _ref.onClick,
|
|
29
|
+
_ref$imageCover = _ref.imageCover,
|
|
30
|
+
imageCover = _ref$imageCover === void 0 ? false : _ref$imageCover,
|
|
31
|
+
margin = _ref.margin,
|
|
32
|
+
_ref$tabIndex = _ref.tabIndex,
|
|
33
|
+
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex,
|
|
34
|
+
_ref$outlined = _ref.outlined,
|
|
35
|
+
outlined = _ref$outlined === void 0 ? true : _ref$outlined,
|
|
36
|
+
children = _ref.children;
|
|
52
37
|
var colorsTheme = (0, _useTheme["default"])();
|
|
53
|
-
|
|
54
38
|
var _useState = (0, _react.useState)(false),
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
imageBgColor: imageBgColor
|
|
61
|
-
}, /*#__PURE__*/_react["default"].createElement(TagImage, {
|
|
62
|
-
imagePadding: imagePadding,
|
|
63
|
-
cover: imageCover,
|
|
64
|
-
src: imageSrc
|
|
65
|
-
}));
|
|
66
|
-
|
|
67
|
-
return /*#__PURE__*/_react["default"].createElement(StyledDxcCard, {
|
|
39
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
40
|
+
isHovered = _useState2[0],
|
|
41
|
+
changeIsHovered = _useState2[1];
|
|
42
|
+
return /*#__PURE__*/_react["default"].createElement(Card, {
|
|
43
|
+
hasAction: onClick || linkHref ? true : false,
|
|
68
44
|
margin: margin,
|
|
69
45
|
onMouseEnter: function onMouseEnter() {
|
|
70
46
|
return changeIsHovered(true);
|
|
@@ -73,7 +49,6 @@ var DxcCard = function DxcCard(_ref) {
|
|
|
73
49
|
return changeIsHovered(false);
|
|
74
50
|
},
|
|
75
51
|
onClick: onClick,
|
|
76
|
-
hasAction: onClick || linkHref,
|
|
77
52
|
tabIndex: onClick || linkHref ? tabIndex : -1,
|
|
78
53
|
as: linkHref && "a",
|
|
79
54
|
href: linkHref
|
|
@@ -82,14 +57,17 @@ var DxcCard = function DxcCard(_ref) {
|
|
|
82
57
|
}, /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
83
58
|
theme: colorsTheme.card
|
|
84
59
|
}, /*#__PURE__*/_react["default"].createElement(CardContainer, {
|
|
85
|
-
hasAction: onClick || linkHref,
|
|
86
|
-
imagePosition: imagePosition
|
|
87
|
-
}, imageSrc &&
|
|
88
|
-
|
|
89
|
-
},
|
|
60
|
+
hasAction: onClick || linkHref ? true : false,
|
|
61
|
+
imagePosition: imageSrc ? imagePosition : "none"
|
|
62
|
+
}, imageSrc && /*#__PURE__*/_react["default"].createElement(ImageContainer, {
|
|
63
|
+
imageBgColor: imageBgColor
|
|
64
|
+
}, /*#__PURE__*/_react["default"].createElement(TagImage, {
|
|
65
|
+
imagePadding: imagePadding,
|
|
66
|
+
imageCover: imageCover,
|
|
67
|
+
src: imageSrc
|
|
68
|
+
})), /*#__PURE__*/_react["default"].createElement(CardContent, null, children)))));
|
|
90
69
|
};
|
|
91
|
-
|
|
92
|
-
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 text-decoration: none;\n\n ", "\n"])), function (_ref2) {
|
|
70
|
+
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) {
|
|
93
71
|
var hasAction = _ref2.hasAction;
|
|
94
72
|
return hasAction && "pointer" || "unset";
|
|
95
73
|
}, function (_ref3) {
|
|
@@ -100,22 +78,23 @@ var StyledDxcCard = _styledComponents["default"].div(_templateObject || (_templa
|
|
|
100
78
|
return margin && (0, _typeof2["default"])(margin) !== "object" ? _variables.spaces[margin] : "0px";
|
|
101
79
|
}, function (_ref5) {
|
|
102
80
|
var margin = _ref5.margin;
|
|
103
|
-
return margin && margin.top ? _variables.spaces[margin.top] : "";
|
|
81
|
+
return margin && (0, _typeof2["default"])(margin) === "object" && margin.top ? _variables.spaces[margin.top] : "";
|
|
104
82
|
}, function (_ref6) {
|
|
105
83
|
var margin = _ref6.margin;
|
|
106
|
-
return margin && margin.right ? _variables.spaces[margin.right] : "";
|
|
84
|
+
return margin && (0, _typeof2["default"])(margin) === "object" && margin.right ? _variables.spaces[margin.right] : "";
|
|
107
85
|
}, function (_ref7) {
|
|
108
86
|
var margin = _ref7.margin;
|
|
109
|
-
return margin && margin.bottom ? _variables.spaces[margin.bottom] : "";
|
|
87
|
+
return margin && (0, _typeof2["default"])(margin) === "object" && margin.bottom ? _variables.spaces[margin.bottom] : "";
|
|
110
88
|
}, function (_ref8) {
|
|
111
89
|
var margin = _ref8.margin;
|
|
112
|
-
return margin && margin.left ? _variables.spaces[margin.left] : "";
|
|
90
|
+
return margin && (0, _typeof2["default"])(margin) === "object" && margin.left ? _variables.spaces[margin.left] : "";
|
|
113
91
|
}, function (_ref9) {
|
|
114
92
|
var hasAction = _ref9.hasAction;
|
|
115
|
-
return hasAction && ":focus {\n
|
|
93
|
+
return hasAction && ":focus {\n outline: #0095ff auto 1px;\n }";
|
|
116
94
|
});
|
|
117
|
-
|
|
118
|
-
|
|
95
|
+
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) {
|
|
96
|
+
return props.imagePosition === "after" ? "row-reverse" : "row";
|
|
97
|
+
}, function (props) {
|
|
119
98
|
return props.theme.height;
|
|
120
99
|
}, function (props) {
|
|
121
100
|
return props.theme.width;
|
|
@@ -123,39 +102,19 @@ var CardContainer = _styledComponents["default"].div(_templateObject2 || (_templ
|
|
|
123
102
|
var hasAction = _ref10.hasAction;
|
|
124
103
|
return hasAction ? "" : "unset";
|
|
125
104
|
});
|
|
126
|
-
|
|
127
105
|
var TagImage = _styledComponents["default"].img(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n height: ", ";\n width: ", ";\n object-fit: ", ";\n"])), function (_ref11) {
|
|
128
106
|
var imagePadding = _ref11.imagePadding;
|
|
129
|
-
return !imagePadding ? "100%" : "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
|
|
107
|
+
return !imagePadding ? "100%" : (0, _typeof2["default"])(imagePadding) !== "object" && "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
|
|
130
108
|
}, function (_ref12) {
|
|
131
109
|
var imagePadding = _ref12.imagePadding;
|
|
132
|
-
return !imagePadding ? "100%" : "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
|
|
110
|
+
return !imagePadding ? "100%" : (0, _typeof2["default"])(imagePadding) !== "object" && "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
|
|
133
111
|
}, function (_ref13) {
|
|
134
|
-
var
|
|
135
|
-
return
|
|
112
|
+
var imageCover = _ref13.imageCover;
|
|
113
|
+
return imageCover ? "cover" : "contain";
|
|
136
114
|
});
|
|
137
|
-
|
|
138
|
-
var ImageContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (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 (_ref14) {
|
|
115
|
+
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) {
|
|
139
116
|
var imageBgColor = _ref14.imageBgColor;
|
|
140
117
|
return imageBgColor;
|
|
141
118
|
});
|
|
142
|
-
|
|
143
|
-
var
|
|
144
|
-
var contentPadding = _ref15.contentPadding;
|
|
145
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding) !== "object" ? _variables.spaces[contentPadding] : "0px";
|
|
146
|
-
}, function (_ref16) {
|
|
147
|
-
var contentPadding = _ref16.contentPadding;
|
|
148
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.top ? _variables.spaces[contentPadding.top] : "";
|
|
149
|
-
}, function (_ref17) {
|
|
150
|
-
var contentPadding = _ref17.contentPadding;
|
|
151
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.right ? _variables.spaces[contentPadding.right] : "";
|
|
152
|
-
}, function (_ref18) {
|
|
153
|
-
var contentPadding = _ref18.contentPadding;
|
|
154
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.bottom ? _variables.spaces[contentPadding.bottom] : "";
|
|
155
|
-
}, function (_ref19) {
|
|
156
|
-
var contentPadding = _ref19.contentPadding;
|
|
157
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.left ? _variables.spaces[contentPadding.left] : "";
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
var _default = DxcCard;
|
|
161
|
-
exports["default"] = _default;
|
|
119
|
+
var CardContent = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n flex-grow: 1;\n overflow: hidden;\n"])));
|
|
120
|
+
var _default = exports["default"] = DxcCard;
|
package/card/Card.stories.tsx
CHANGED
|
@@ -2,7 +2,6 @@ import React from "react";
|
|
|
2
2
|
import Title from "../../.storybook/components/Title";
|
|
3
3
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
4
4
|
import DxcCard from "./Card";
|
|
5
|
-
import imagePath from "./ice-cream.jpg";
|
|
6
5
|
import { userEvent, within } from "@storybook/testing-library";
|
|
7
6
|
|
|
8
7
|
export default {
|
|
@@ -38,104 +37,75 @@ const Card = () => (
|
|
|
38
37
|
</ExampleContainer>
|
|
39
38
|
<Title title="Default with image" theme="light" level={4} />
|
|
40
39
|
<ExampleContainer>
|
|
41
|
-
<DxcCard imageSrc=
|
|
40
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300">Default</DxcCard>
|
|
42
41
|
</ExampleContainer>
|
|
43
42
|
<Title title="Default image with background color" theme="light" level={4} />
|
|
44
43
|
<ExampleContainer>
|
|
45
|
-
<DxcCard imageSrc=
|
|
44
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imageBgColor="yellow">
|
|
46
45
|
Background color
|
|
47
46
|
</DxcCard>
|
|
48
47
|
</ExampleContainer>
|
|
49
48
|
<Title title="Default image with position after" theme="light" level={4} />
|
|
50
49
|
<ExampleContainer>
|
|
51
|
-
<DxcCard imageSrc=
|
|
50
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePosition="after">
|
|
52
51
|
Position after
|
|
53
52
|
</DxcCard>
|
|
54
53
|
</ExampleContainer>
|
|
55
54
|
<Title title="Image cover" theme="light" level={4} />
|
|
56
55
|
<ExampleContainer>
|
|
57
|
-
<DxcCard imageSrc=
|
|
56
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imageCover>
|
|
58
57
|
Image cover
|
|
59
58
|
</DxcCard>
|
|
60
59
|
</ExampleContainer>
|
|
61
60
|
<Title title="Image cover with position after" theme="light" level={4} />
|
|
62
61
|
<ExampleContainer>
|
|
63
|
-
<DxcCard imageSrc=
|
|
62
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imageCover imagePosition="after">
|
|
64
63
|
Image cover with position after
|
|
65
64
|
</DxcCard>
|
|
66
65
|
</ExampleContainer>
|
|
67
66
|
<Title title="Image padding" theme="light" level={2} />
|
|
68
67
|
<ExampleContainer>
|
|
69
68
|
<Title title="Xxsmall" theme="light" level={4} />
|
|
70
|
-
<DxcCard imageSrc=
|
|
69
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePadding="xxsmall" imageCover>
|
|
71
70
|
Xxsmall
|
|
72
71
|
</DxcCard>
|
|
73
72
|
</ExampleContainer>
|
|
74
73
|
<ExampleContainer>
|
|
75
74
|
<Title title="Xsmall" theme="light" level={4} />
|
|
76
|
-
<DxcCard imageSrc=
|
|
75
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePadding="xsmall" imageCover>
|
|
77
76
|
Xsmall
|
|
78
77
|
</DxcCard>
|
|
79
78
|
</ExampleContainer>
|
|
80
79
|
<ExampleContainer>
|
|
81
80
|
<Title title="Small" theme="light" level={4} />
|
|
82
|
-
<DxcCard imageSrc=
|
|
81
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePadding="small" imageCover>
|
|
83
82
|
Small
|
|
84
83
|
</DxcCard>
|
|
85
84
|
</ExampleContainer>
|
|
86
85
|
<ExampleContainer>
|
|
87
86
|
<Title title="Medium" theme="light" level={4} />
|
|
88
|
-
<DxcCard imageSrc=
|
|
87
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePadding="medium" imageCover>
|
|
89
88
|
Medium
|
|
90
89
|
</DxcCard>
|
|
91
90
|
</ExampleContainer>
|
|
92
91
|
<ExampleContainer>
|
|
93
92
|
<Title title="Large" theme="light" level={4} />
|
|
94
|
-
<DxcCard imageSrc=
|
|
93
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePadding="large" imageCover>
|
|
95
94
|
Large
|
|
96
95
|
</DxcCard>
|
|
97
96
|
</ExampleContainer>
|
|
98
97
|
<ExampleContainer>
|
|
99
98
|
<Title title="Xlarge" theme="light" level={4} />
|
|
100
|
-
<DxcCard imageSrc=
|
|
99
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePadding="xlarge" imageCover>
|
|
101
100
|
Xlarge
|
|
102
101
|
</DxcCard>
|
|
103
102
|
</ExampleContainer>
|
|
104
103
|
<ExampleContainer>
|
|
105
104
|
<Title title="Xxlarge" theme="light" level={4} />
|
|
106
|
-
<DxcCard imageSrc=
|
|
105
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePadding="xxlarge" imageCover>
|
|
107
106
|
Xxlarge
|
|
108
107
|
</DxcCard>
|
|
109
108
|
</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
109
|
<Title title="Margin" theme="light" level={2} />
|
|
140
110
|
<ExampleContainer>
|
|
141
111
|
<Title title="Xxsmall" theme="light" level={4} />
|
package/card/Card.test.js
CHANGED
|
@@ -1,50 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _react = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
5
|
var _react2 = require("@testing-library/react");
|
|
8
|
-
|
|
9
6
|
var _Card = _interopRequireDefault(require("./Card.tsx"));
|
|
10
|
-
|
|
11
7
|
describe("Card component tests", function () {
|
|
12
8
|
test("Card renders with correct content", function () {
|
|
13
9
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Card["default"], null, "test-card")),
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
getByText = _render.getByText;
|
|
16
11
|
expect(getByText("test-card")).toBeTruthy();
|
|
17
12
|
});
|
|
18
13
|
test("Card renders with correct href", function () {
|
|
19
14
|
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Card["default"], {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
linkHref: "/testPage"
|
|
16
|
+
}, "test-card")),
|
|
17
|
+
getByRole = _render2.getByRole;
|
|
24
18
|
var card = getByRole("link");
|
|
25
19
|
expect(card.getAttribute("href")).toEqual("/testPage");
|
|
26
20
|
});
|
|
27
21
|
test("Card renders with correct image", function () {
|
|
28
22
|
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Card["default"], {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
imageSrc: "/testImage"
|
|
24
|
+
}, "test-card")),
|
|
25
|
+
getByRole = _render3.getByRole;
|
|
33
26
|
var card = getByRole("img");
|
|
34
27
|
expect(card.getAttribute("src")).toEqual("/testImage");
|
|
35
28
|
});
|
|
36
29
|
test("OnClick function is called", function () {
|
|
37
30
|
var onClick = jest.fn();
|
|
38
|
-
|
|
39
31
|
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Card["default"], {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
onClick: onClick
|
|
33
|
+
}, "test-card")),
|
|
34
|
+
getByText = _render4.getByText;
|
|
44
35
|
var card = getByText("test-card");
|
|
45
|
-
|
|
46
36
|
_react2.fireEvent.click(card);
|
|
47
|
-
|
|
48
37
|
expect(onClick).toHaveBeenCalled();
|
|
49
38
|
});
|
|
50
39
|
});
|
package/card/types.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
+
type Size = {
|
|
4
4
|
top?: Space;
|
|
5
5
|
bottom?: Space;
|
|
6
6
|
left?: Space;
|
|
7
7
|
right?: Space;
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
type Props = {
|
|
10
10
|
/**
|
|
11
11
|
* URL of the image that will be placed in the card component.
|
|
12
12
|
* In case of omission, the image container will not appear and
|
|
@@ -47,21 +47,15 @@ declare type Props = {
|
|
|
47
47
|
*/
|
|
48
48
|
margin?: Space | Size;
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
51
|
-
* Size of the padding to be applied to the content area ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
|
|
52
|
-
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different padding sizes.
|
|
53
|
-
*/
|
|
54
|
-
contentPadding?: Space | Size;
|
|
55
|
-
/**
|
|
56
|
-
* Value of the tabindex given when there is an href.
|
|
50
|
+
* Value of the tabindex attribute applied when the component is clickable.
|
|
57
51
|
*/
|
|
58
52
|
tabIndex?: number;
|
|
59
53
|
/**
|
|
60
|
-
*
|
|
54
|
+
* Determines whether or not the component should have an outline.
|
|
61
55
|
*/
|
|
62
56
|
outlined?: boolean;
|
|
63
57
|
/**
|
|
64
|
-
* Custom content that will be placed
|
|
58
|
+
* Custom content that will be placed inside the component.
|
|
65
59
|
*/
|
|
66
60
|
children?: React.ReactNode;
|
|
67
61
|
};
|