@dxc-technology/halstack-react 9.0.1 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HalstackContext.d.ts +2 -2
- package/HalstackContext.js +2 -2
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +2 -14
- package/accordion/Accordion.stories.tsx +3 -101
- package/accordion/types.d.ts +0 -12
- package/accordion-group/AccordionGroup.d.ts +4 -3
- package/accordion-group/AccordionGroup.js +21 -42
- package/accordion-group/AccordionGroup.stories.tsx +77 -76
- package/accordion-group/AccordionGroup.test.js +6 -16
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +43 -0
- package/accordion-group/types.d.ts +0 -12
- package/alert/Alert.js +1 -3
- package/bleed/Bleed.stories.tsx +1 -0
- package/box/Box.d.ts +1 -1
- package/box/Box.js +5 -22
- package/box/Box.stories.tsx +25 -53
- package/box/types.d.ts +0 -12
- package/bulleted-list/BulletedList.js +4 -2
- package/bulleted-list/BulletedList.stories.tsx +7 -1
- package/bulleted-list/types.d.ts +31 -4
- package/button/Button.d.ts +1 -1
- package/button/Button.js +45 -55
- package/button/Button.stories.tsx +4 -4
- package/button/Button.test.js +11 -0
- package/button/types.d.ts +4 -0
- package/card/Card.d.ts +1 -1
- package/card/Card.js +18 -35
- package/card/Card.stories.tsx +0 -29
- package/card/types.d.ts +1 -7
- package/chip/Chip.js +23 -36
- package/chip/Chip.stories.tsx +25 -17
- package/common/OpenSans.css +68 -80
- package/common/coreTokens.d.ts +146 -0
- package/common/coreTokens.js +167 -0
- package/common/variables.d.ts +1 -144
- package/common/variables.js +952 -1095
- package/date-input/Calendar.js +2 -2
- package/dialog/Dialog.d.ts +1 -1
- package/dialog/Dialog.js +4 -22
- package/dialog/Dialog.stories.tsx +52 -176
- package/dialog/types.d.ts +0 -13
- package/dropdown/DropdownMenu.js +5 -1
- package/file-input/FileItem.js +2 -2
- package/file-input/types.d.ts +1 -1
- package/flex/Flex.js +4 -2
- package/flex/Flex.stories.tsx +35 -26
- package/flex/types.d.ts +70 -5
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +43 -61
- package/footer/Footer.stories.tsx +12 -89
- package/footer/Footer.test.js +3 -1
- package/footer/types.d.ts +10 -12
- 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/grid/types.js +5 -0
- package/header/Header.d.ts +1 -1
- package/header/Header.js +3 -30
- package/header/Header.stories.tsx +7 -71
- package/header/types.d.ts +0 -14
- package/inset/Inset.stories.tsx +2 -1
- package/layout/ApplicationLayout.d.ts +4 -4
- package/layout/ApplicationLayout.js +7 -4
- package/layout/types.d.ts +2 -3
- package/link/Link.js +1 -1
- package/main.d.ts +2 -1
- package/main.js +8 -0
- package/nav-tabs/NavTabs.d.ts +2 -2
- package/nav-tabs/NavTabs.js +7 -10
- package/nav-tabs/NavTabs.stories.tsx +14 -0
- package/nav-tabs/Tab.js +22 -26
- package/nav-tabs/types.d.ts +8 -9
- package/package.json +1 -1
- package/paginator/Paginator.js +1 -1
- package/paginator/Paginator.test.js +13 -0
- package/radio-group/Radio.js +10 -10
- package/radio-group/RadioGroup.js +8 -10
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +51 -0
- package/sidenav/Sidenav.d.ts +2 -2
- package/sidenav/Sidenav.js +65 -93
- package/sidenav/Sidenav.stories.tsx +60 -60
- package/sidenav/types.d.ts +21 -18
- package/tabs/Tab.js +1 -2
- package/tabs/Tabs.js +10 -14
- package/text-input/TextInput.js +1 -1
- package/text-input/TextInput.stories.tsx +1 -1
- package/textarea/Textarea.js +0 -1
- package/textarea/Textarea.test.js +1 -3
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/useTheme.d.ts +1 -1
- package/utils/FocusLock.js +3 -4
- package/card/ice-cream.jpg +0 -0
package/box/Box.stories.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
import Title from "../../.storybook/components/Title";
|
|
3
3
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
4
4
|
import DxcBox from "./Box";
|
|
5
|
+
import DxcInset from "../inset/Inset";
|
|
5
6
|
import { HalstackProvider } from "../HalstackContext";
|
|
6
7
|
|
|
7
8
|
export default {
|
|
@@ -19,99 +20,70 @@ export const Chromatic = () => (
|
|
|
19
20
|
<>
|
|
20
21
|
<Title title="Display flex" theme="light" level={2} />
|
|
21
22
|
<ExampleContainer>
|
|
22
|
-
<DxcBox display="flex"
|
|
23
|
-
Box
|
|
23
|
+
<DxcBox display="flex">
|
|
24
|
+
<DxcInset space="2rem">Box</DxcInset>
|
|
24
25
|
</DxcBox>
|
|
25
26
|
</ExampleContainer>
|
|
26
27
|
<Title title="ShadowDepth" theme="light" level={2} />
|
|
27
28
|
<ExampleContainer>
|
|
28
29
|
<Title title="ShadowDepth 0" theme="light" level={4} />
|
|
29
|
-
<DxcBox shadowDepth={0} margin="medium"
|
|
30
|
-
Box
|
|
30
|
+
<DxcBox shadowDepth={0} margin="medium">
|
|
31
|
+
<DxcInset space="2rem">Box</DxcInset>
|
|
31
32
|
</DxcBox>
|
|
32
33
|
</ExampleContainer>
|
|
33
34
|
<ExampleContainer>
|
|
34
35
|
<Title title="ShadowDepth 1" theme="light" level={4} />
|
|
35
|
-
<DxcBox shadowDepth={1} margin="medium"
|
|
36
|
-
Box
|
|
36
|
+
<DxcBox shadowDepth={1} margin="medium">
|
|
37
|
+
<DxcInset space="2rem">Box</DxcInset>
|
|
37
38
|
</DxcBox>
|
|
38
39
|
</ExampleContainer>
|
|
39
40
|
<ExampleContainer>
|
|
40
41
|
<Title title="ShadowDepth 2" theme="light" level={4} />
|
|
41
|
-
<DxcBox shadowDepth={2} margin="medium"
|
|
42
|
-
Box
|
|
42
|
+
<DxcBox shadowDepth={2} margin="medium">
|
|
43
|
+
<DxcInset space="2rem">Box</DxcInset>
|
|
43
44
|
</DxcBox>
|
|
44
45
|
</ExampleContainer>
|
|
45
|
-
<Title title="Paddings" theme="light" level={2} />
|
|
46
|
-
<ExampleContainer>
|
|
47
|
-
<Title title="Xxsmall padding" theme="light" level={4} />
|
|
48
|
-
<DxcBox padding="xxsmall">Box</DxcBox>
|
|
49
|
-
</ExampleContainer>
|
|
50
|
-
<ExampleContainer>
|
|
51
|
-
<Title title="Xsmall padding" theme="light" level={4} />
|
|
52
|
-
<DxcBox padding="xsmall">Box</DxcBox>
|
|
53
|
-
</ExampleContainer>
|
|
54
|
-
<ExampleContainer>
|
|
55
|
-
<Title title="Small padding" theme="light" level={4} />
|
|
56
|
-
<DxcBox padding="small">Box</DxcBox>
|
|
57
|
-
</ExampleContainer>
|
|
58
|
-
<ExampleContainer>
|
|
59
|
-
<Title title="Medium padding" theme="light" level={4} />
|
|
60
|
-
<DxcBox padding="medium">Box</DxcBox>
|
|
61
|
-
</ExampleContainer>
|
|
62
|
-
<ExampleContainer>
|
|
63
|
-
<Title title="Large padding" theme="light" level={4} />
|
|
64
|
-
<DxcBox padding="large">Box</DxcBox>
|
|
65
|
-
</ExampleContainer>
|
|
66
|
-
<ExampleContainer>
|
|
67
|
-
<Title title="Xlarge padding" theme="light" level={4} />
|
|
68
|
-
<DxcBox padding="xlarge">Box</DxcBox>
|
|
69
|
-
</ExampleContainer>
|
|
70
|
-
<ExampleContainer>
|
|
71
|
-
<Title title="Xxlarge padding" theme="light" level={4} />
|
|
72
|
-
<DxcBox padding="xxlarge">Box</DxcBox>
|
|
73
|
-
</ExampleContainer>
|
|
74
46
|
<Title title="Margins" theme="light" level={2} />
|
|
75
47
|
<ExampleContainer>
|
|
76
48
|
<Title title="Xxsmall margin" theme="light" level={4} />
|
|
77
|
-
<DxcBox margin="xxsmall"
|
|
78
|
-
Box
|
|
49
|
+
<DxcBox margin="xxsmall">
|
|
50
|
+
<DxcInset space="2rem">Box</DxcInset>
|
|
79
51
|
</DxcBox>
|
|
80
52
|
</ExampleContainer>
|
|
81
53
|
<ExampleContainer>
|
|
82
54
|
<Title title="Xsmall margin" theme="light" level={4} />
|
|
83
|
-
<DxcBox margin="xsmall"
|
|
84
|
-
Box
|
|
55
|
+
<DxcBox margin="xsmall">
|
|
56
|
+
<DxcInset space="2rem">Box</DxcInset>
|
|
85
57
|
</DxcBox>
|
|
86
58
|
</ExampleContainer>
|
|
87
59
|
<ExampleContainer>
|
|
88
60
|
<Title title="Small margin" theme="light" level={4} />
|
|
89
|
-
<DxcBox margin="small"
|
|
90
|
-
Box
|
|
61
|
+
<DxcBox margin="small">
|
|
62
|
+
<DxcInset space="2rem">Box</DxcInset>
|
|
91
63
|
</DxcBox>
|
|
92
64
|
</ExampleContainer>
|
|
93
65
|
<ExampleContainer>
|
|
94
66
|
<Title title="Medium margin" theme="light" level={4} />
|
|
95
|
-
<DxcBox margin="medium"
|
|
96
|
-
Box
|
|
67
|
+
<DxcBox margin="medium">
|
|
68
|
+
<DxcInset space="2rem">Box</DxcInset>
|
|
97
69
|
</DxcBox>
|
|
98
70
|
</ExampleContainer>
|
|
99
71
|
<ExampleContainer>
|
|
100
72
|
<Title title="Large margin" theme="light" level={4} />
|
|
101
|
-
<DxcBox margin="large"
|
|
102
|
-
Box
|
|
73
|
+
<DxcBox margin="large">
|
|
74
|
+
<DxcInset space="2rem">Box</DxcInset>
|
|
103
75
|
</DxcBox>
|
|
104
76
|
</ExampleContainer>
|
|
105
77
|
<ExampleContainer>
|
|
106
78
|
<Title title="Xlarge margin" theme="light" level={4} />
|
|
107
|
-
<DxcBox margin="xlarge"
|
|
108
|
-
Box
|
|
79
|
+
<DxcBox margin="xlarge">
|
|
80
|
+
<DxcInset space="2rem">Box</DxcInset>
|
|
109
81
|
</DxcBox>
|
|
110
82
|
</ExampleContainer>
|
|
111
83
|
<ExampleContainer>
|
|
112
84
|
<Title title="Xxlarge margin" theme="light" level={4} />
|
|
113
|
-
<DxcBox margin="xxlarge"
|
|
114
|
-
Box
|
|
85
|
+
<DxcBox margin="xxlarge">
|
|
86
|
+
<DxcInset space="2rem">Box</DxcInset>
|
|
115
87
|
</DxcBox>
|
|
116
88
|
</ExampleContainer>
|
|
117
89
|
<Title title="Sizes" theme="light" level={2} />
|
|
@@ -138,8 +110,8 @@ export const Chromatic = () => (
|
|
|
138
110
|
<Title title="Opinionated theme" theme="light" level={2} />
|
|
139
111
|
<ExampleContainer>
|
|
140
112
|
<HalstackProvider theme={opinionatedTheme}>
|
|
141
|
-
<DxcBox display="flex"
|
|
142
|
-
Box
|
|
113
|
+
<DxcBox display="flex">
|
|
114
|
+
<DxcInset space="2rem">Box</DxcInset>
|
|
143
115
|
</DxcBox>
|
|
144
116
|
</HalstackProvider>
|
|
145
117
|
</ExampleContainer>
|
package/box/types.d.ts
CHANGED
|
@@ -6,12 +6,6 @@ declare type Margin = {
|
|
|
6
6
|
left?: Space;
|
|
7
7
|
right?: Space;
|
|
8
8
|
};
|
|
9
|
-
declare type Padding = {
|
|
10
|
-
top?: Space;
|
|
11
|
-
bottom?: Space;
|
|
12
|
-
left?: Space;
|
|
13
|
-
right?: Space;
|
|
14
|
-
};
|
|
15
9
|
declare type Props = {
|
|
16
10
|
/**
|
|
17
11
|
* The size of the shadow to be displayed around the box.
|
|
@@ -30,12 +24,6 @@ declare type Props = {
|
|
|
30
24
|
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
|
|
31
25
|
*/
|
|
32
26
|
margin?: Space | Margin;
|
|
33
|
-
/**
|
|
34
|
-
* @deprecated This prop will be removed shortly, consider using the Inset component for this purpose.
|
|
35
|
-
* Size of the padding to be applied to the custom area ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
|
|
36
|
-
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different padding sizes.
|
|
37
|
-
*/
|
|
38
|
-
padding?: Space | Padding;
|
|
39
27
|
/**
|
|
40
28
|
* Size of the component.
|
|
41
29
|
*/
|
|
@@ -57,7 +57,9 @@ var DxcBulletedList = function DxcBulletedList(_ref2) {
|
|
|
57
57
|
backgroundType: backgroundType
|
|
58
58
|
})) : type === "icon" ? /*#__PURE__*/_react["default"].createElement(Bullet, null, /*#__PURE__*/_react["default"].createElement(Icon, {
|
|
59
59
|
backgroundType: backgroundType
|
|
60
|
-
}, icon
|
|
60
|
+
}, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
61
|
+
src: icon
|
|
62
|
+
}) : icon)) : /*#__PURE__*/_react["default"].createElement(Bullet, null, /*#__PURE__*/_react["default"].createElement(Disc, {
|
|
61
63
|
backgroundType: backgroundType
|
|
62
64
|
})), /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
63
65
|
color: backgroundType && backgroundType === "dark" ? colorsTheme.bulletedList.fontColorOnDark : colorsTheme.bulletedList.fontColor
|
|
@@ -73,7 +75,7 @@ var Bullet = _styledComponents["default"].div(_templateObject2 || (_templateObje
|
|
|
73
75
|
|
|
74
76
|
var GeneralContent = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: grid;\n grid-template-columns: auto 1fr;\n align-items: center;\n"])));
|
|
75
77
|
|
|
76
|
-
var Icon = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n height: 1.5rem;\n width: auto;\n margin-right: ", ";\n align-content: center;\n color: ", ";\n
|
|
78
|
+
var Icon = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n height: 1.5rem;\n width: auto;\n margin-right: ", ";\n align-content: center;\n color: ", ";\n svg,\n img {\n height: ", ";\n width: ", ";\n }\n"])), function (props) {
|
|
77
79
|
return props.theme.bulletMarginRight;
|
|
78
80
|
}, function (props) {
|
|
79
81
|
return props.backgroundType && props.backgroundType === "dark" ? props.theme.fontColorOnDark : props.theme.fontColor;
|
|
@@ -20,12 +20,18 @@ const icon = (
|
|
|
20
20
|
export const Chromatic = () => (
|
|
21
21
|
<>
|
|
22
22
|
<ExampleContainer>
|
|
23
|
-
<Title title="Icon list" level={4} />
|
|
23
|
+
<Title title="Icon list (SVG)" level={4} />
|
|
24
24
|
<DxcBulletedList type="icon" icon={icon}>
|
|
25
25
|
<DxcBulletedList.Item>Code</DxcBulletedList.Item>
|
|
26
26
|
<DxcBulletedList.Item>Usage</DxcBulletedList.Item>
|
|
27
27
|
<DxcBulletedList.Item>Specifications</DxcBulletedList.Item>
|
|
28
28
|
</DxcBulletedList>
|
|
29
|
+
<Title title="Icon list (path)" level={4} />
|
|
30
|
+
<DxcBulletedList type="icon" icon="https://upload.wikimedia.org/wikipedia/commons/e/e0/Check_green_icon.svg">
|
|
31
|
+
<DxcBulletedList.Item>Code</DxcBulletedList.Item>
|
|
32
|
+
<DxcBulletedList.Item>Usage</DxcBulletedList.Item>
|
|
33
|
+
<DxcBulletedList.Item>Specifications</DxcBulletedList.Item>
|
|
34
|
+
</DxcBulletedList>
|
|
29
35
|
<Title title="Number list" level={4} />
|
|
30
36
|
<DxcBulletedList type="number">
|
|
31
37
|
<DxcBulletedList.Item>Code</DxcBulletedList.Item>
|
package/bulleted-list/types.d.ts
CHANGED
|
@@ -1,11 +1,38 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
declare type SVG = React.ReactNode &
|
|
3
|
-
declare 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
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
|
@@ -31,22 +31,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
31
31
|
|
|
32
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
33
|
|
|
34
|
-
var sizes = {
|
|
35
|
-
small: "42px",
|
|
36
|
-
medium: "120px",
|
|
37
|
-
large: "240px",
|
|
38
|
-
fillParent: "100%",
|
|
39
|
-
fitContent: "fit-content"
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
var calculateWidth = function calculateWidth(margin, size) {
|
|
43
|
-
if (size === "fillParent") {
|
|
44
|
-
return "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return sizes[size];
|
|
48
|
-
};
|
|
49
|
-
|
|
50
34
|
var DxcButton = function DxcButton(_ref) {
|
|
51
35
|
var _ref$label = _ref.label,
|
|
52
36
|
label = _ref$label === void 0 ? "" : _ref$label,
|
|
@@ -56,6 +40,7 @@ var DxcButton = function DxcButton(_ref) {
|
|
|
56
40
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
57
41
|
_ref$iconPosition = _ref.iconPosition,
|
|
58
42
|
iconPosition = _ref$iconPosition === void 0 ? "before" : _ref$iconPosition,
|
|
43
|
+
title = _ref.title,
|
|
59
44
|
_ref$type = _ref.type,
|
|
60
45
|
type = _ref$type === void 0 ? "button" : _ref$type,
|
|
61
46
|
icon = _ref.icon,
|
|
@@ -72,32 +57,50 @@ var DxcButton = function DxcButton(_ref) {
|
|
|
72
57
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
73
58
|
theme: colorsTheme.button
|
|
74
59
|
}, /*#__PURE__*/_react["default"].createElement(Button, {
|
|
75
|
-
|
|
76
|
-
mode: mode !== "primary" && mode !== "secondary" && mode !== "text" ? "primary" : mode,
|
|
60
|
+
"aria-label": title,
|
|
77
61
|
disabled: disabled,
|
|
78
|
-
|
|
62
|
+
onClick: function onClick() {
|
|
63
|
+
_onClick();
|
|
64
|
+
},
|
|
79
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,
|
|
80
72
|
backgroundType: backgroundType,
|
|
81
73
|
size: size,
|
|
82
|
-
margin: margin
|
|
83
|
-
|
|
84
|
-
_onClick();
|
|
85
|
-
}
|
|
86
|
-
}, label && iconPosition === "after" && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
|
|
87
|
-
icon: icon,
|
|
88
|
-
iconPosition: iconPosition
|
|
89
|
-
}, label), icon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
90
|
-
label: label,
|
|
91
|
-
iconPosition: iconPosition
|
|
92
|
-
}, 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", {
|
|
93
76
|
src: icon
|
|
94
|
-
}) : icon)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
77
|
+
}) : icon)));
|
|
78
|
+
};
|
|
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 ");
|
|
98
97
|
};
|
|
99
98
|
|
|
100
|
-
var Button = _styledComponents["default"].button(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n
|
|
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) {
|
|
101
104
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
102
105
|
}, function (props) {
|
|
103
106
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
|
|
@@ -107,16 +110,14 @@ var Button = _styledComponents["default"].button(_templateObject || (_templateOb
|
|
|
107
110
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
|
|
108
111
|
}, function (props) {
|
|
109
112
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
110
|
-
}, function (props) {
|
|
111
|
-
return calculateWidth(props.margin, props.size);
|
|
112
|
-
}, function (props) {
|
|
113
|
-
return props.theme.paddingLeft;
|
|
114
|
-
}, function (props) {
|
|
115
|
-
return props.theme.paddingRight;
|
|
116
113
|
}, function (props) {
|
|
117
114
|
return props.theme.paddingTop;
|
|
118
115
|
}, function (props) {
|
|
119
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)");
|
|
120
121
|
}, function (props) {
|
|
121
122
|
return props.theme.fontFamily;
|
|
122
123
|
}, function (props) {
|
|
@@ -128,27 +129,16 @@ var Button = _styledComponents["default"].button(_templateObject || (_templateOb
|
|
|
128
129
|
}, function (props) {
|
|
129
130
|
return props.backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor;
|
|
130
131
|
}, function (props) {
|
|
131
|
-
|
|
132
|
-
backgroundType = props.backgroundType,
|
|
133
|
-
disabled = props.disabled;
|
|
134
|
-
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);
|
|
135
133
|
});
|
|
136
134
|
|
|
137
|
-
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
|
|
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) {
|
|
138
136
|
return props.theme.labelFontLineHeight;
|
|
139
137
|
}, function (props) {
|
|
140
138
|
return props.theme.fontSize;
|
|
141
|
-
}, function (props) {
|
|
142
|
-
return !props.icon || props.iconPosition === "before" ? "8px" : "0px";
|
|
143
|
-
}, function (props) {
|
|
144
|
-
return !props.icon || props.iconPosition === "after" ? "8px" : "0px";
|
|
145
139
|
});
|
|
146
140
|
|
|
147
|
-
var IconContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n
|
|
148
|
-
return !props.label ? "0px" : props.iconPosition === "after" && props.label !== "" && "8px" || "8px";
|
|
149
|
-
}, function (props) {
|
|
150
|
-
return !props.label ? "0px" : props.iconPosition === "before" && props.label !== "" && "8px" || "8px";
|
|
151
|
-
});
|
|
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"])));
|
|
152
142
|
|
|
153
143
|
var _default = DxcButton;
|
|
154
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
|
@@ -32,4 +32,15 @@ describe("Button component tests", function () {
|
|
|
32
32
|
|
|
33
33
|
expect(onClick).toHaveBeenCalled();
|
|
34
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
|
+
});
|
|
35
46
|
});
|
package/button/types.d.ts
CHANGED
|
@@ -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
|
@@ -43,7 +43,6 @@ var DxcCard = function DxcCard(_ref) {
|
|
|
43
43
|
_ref$imageCover = _ref.imageCover,
|
|
44
44
|
imageCover = _ref$imageCover === void 0 ? false : _ref$imageCover,
|
|
45
45
|
margin = _ref.margin,
|
|
46
|
-
contentPadding = _ref.contentPadding,
|
|
47
46
|
_ref$tabIndex = _ref.tabIndex,
|
|
48
47
|
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex,
|
|
49
48
|
_ref$outlined = _ref.outlined,
|
|
@@ -56,15 +55,8 @@ var DxcCard = function DxcCard(_ref) {
|
|
|
56
55
|
isHovered = _useState2[0],
|
|
57
56
|
changeIsHovered = _useState2[1];
|
|
58
57
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}, /*#__PURE__*/_react["default"].createElement(TagImage, {
|
|
62
|
-
imagePadding: imagePadding,
|
|
63
|
-
imageCover: imageCover,
|
|
64
|
-
src: imageSrc
|
|
65
|
-
}));
|
|
66
|
-
|
|
67
|
-
return /*#__PURE__*/_react["default"].createElement(StyledDxcCard, {
|
|
58
|
+
return /*#__PURE__*/_react["default"].createElement(Card, {
|
|
59
|
+
hasAction: onClick || linkHref ? true : false,
|
|
68
60
|
margin: margin,
|
|
69
61
|
onMouseEnter: function onMouseEnter() {
|
|
70
62
|
return changeIsHovered(true);
|
|
@@ -73,7 +65,6 @@ var DxcCard = function DxcCard(_ref) {
|
|
|
73
65
|
return changeIsHovered(false);
|
|
74
66
|
},
|
|
75
67
|
onClick: onClick,
|
|
76
|
-
hasAction: onClick || linkHref,
|
|
77
68
|
tabIndex: onClick || linkHref ? tabIndex : -1,
|
|
78
69
|
as: linkHref && "a",
|
|
79
70
|
href: linkHref
|
|
@@ -82,13 +73,18 @@ var DxcCard = function DxcCard(_ref) {
|
|
|
82
73
|
}, /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
83
74
|
theme: colorsTheme.card
|
|
84
75
|
}, /*#__PURE__*/_react["default"].createElement(CardContainer, {
|
|
85
|
-
hasAction: onClick || linkHref
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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)))));
|
|
89
85
|
};
|
|
90
86
|
|
|
91
|
-
var
|
|
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) {
|
|
92
88
|
var hasAction = _ref2.hasAction;
|
|
93
89
|
return hasAction && "pointer" || "unset";
|
|
94
90
|
}, function (_ref3) {
|
|
@@ -111,10 +107,12 @@ var StyledDxcCard = _styledComponents["default"].div(_templateObject || (_templa
|
|
|
111
107
|
return margin && (0, _typeof2["default"])(margin) === "object" && margin.left ? _variables.spaces[margin.left] : "";
|
|
112
108
|
}, function (_ref9) {
|
|
113
109
|
var hasAction = _ref9.hasAction;
|
|
114
|
-
return hasAction && ":focus {\n
|
|
110
|
+
return hasAction && ":focus {\n outline: #0095ff auto 1px;\n }";
|
|
115
111
|
});
|
|
116
112
|
|
|
117
|
-
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) {
|
|
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) {
|
|
118
116
|
return props.theme.height;
|
|
119
117
|
}, function (props) {
|
|
120
118
|
return props.theme.width;
|
|
@@ -134,27 +132,12 @@ var TagImage = _styledComponents["default"].img(_templateObject3 || (_templateOb
|
|
|
134
132
|
return imageCover ? "cover" : "contain";
|
|
135
133
|
});
|
|
136
134
|
|
|
137
|
-
var ImageContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n
|
|
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) {
|
|
138
136
|
var imageBgColor = _ref14.imageBgColor;
|
|
139
137
|
return imageBgColor;
|
|
140
138
|
});
|
|
141
139
|
|
|
142
|
-
var CardContent = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n flex-grow: 1;\n
|
|
143
|
-
var contentPadding = _ref15.contentPadding;
|
|
144
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding) !== "object" ? _variables.spaces[contentPadding] : "0px";
|
|
145
|
-
}, function (_ref16) {
|
|
146
|
-
var contentPadding = _ref16.contentPadding;
|
|
147
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.top ? _variables.spaces[contentPadding.top] : "";
|
|
148
|
-
}, function (_ref17) {
|
|
149
|
-
var contentPadding = _ref17.contentPadding;
|
|
150
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.right ? _variables.spaces[contentPadding.right] : "";
|
|
151
|
-
}, function (_ref18) {
|
|
152
|
-
var contentPadding = _ref18.contentPadding;
|
|
153
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.bottom ? _variables.spaces[contentPadding.bottom] : "";
|
|
154
|
-
}, function (_ref19) {
|
|
155
|
-
var contentPadding = _ref19.contentPadding;
|
|
156
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.left ? _variables.spaces[contentPadding.left] : "";
|
|
157
|
-
});
|
|
140
|
+
var CardContent = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n flex-grow: 1;\n overflow: hidden;\n"])));
|
|
158
141
|
|
|
159
142
|
var _default = DxcCard;
|
|
160
143
|
exports["default"] = _default;
|