@dxc-technology/halstack-react 0.0.0-9e54008 → 0.0.0-9e83fd2

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.
@@ -1320,7 +1320,7 @@ declare const HalstackLanguageContext: React.Context<DeepPartial<{
1320
1320
  }>>;
1321
1321
  /**
1322
1322
  * This type is used to allow partial themes and labels objects to be passed to the HalstackProvider.
1323
- * This is an extension of the already extisting Partial type, which only allows one level of partiality.
1323
+ * This is an extension of the already existing Partial type, which only allows one level of partiality.
1324
1324
  */
1325
1325
  declare type DeepPartial<T> = {
1326
1326
  [P in keyof T]?: Partial<T[P]>;
@@ -305,7 +305,7 @@ var parseLabels = function parseLabels(labels) {
305
305
  };
306
306
  /**
307
307
  * This type is used to allow partial themes and labels objects to be passed to the HalstackProvider.
308
- * This is an extension of the already extisting Partial type, which only allows one level of partiality.
308
+ * This is an extension of the already existing Partial type, which only allows one level of partiality.
309
309
  */
310
310
 
311
311
 
@@ -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,31 +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
- type: type,
76
- mode: mode !== "primary" && mode !== "secondary" && mode !== "text" ? "primary" : mode,
60
+ "aria-label": title,
77
61
  disabled: disabled,
62
+ onClick: function onClick() {
63
+ _onClick();
64
+ },
78
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,
79
72
  backgroundType: backgroundType,
80
73
  size: size,
81
- margin: margin,
82
- onClick: function onClick() {
83
- _onClick();
84
- }
85
- }, label && iconPosition === "after" && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
86
- icon: icon,
87
- iconPosition: iconPosition
88
- }, label), icon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
89
- label: label,
90
- iconPosition: iconPosition
91
- }, 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", {
92
76
  src: icon
93
- }) : icon), label && iconPosition === "before" && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
94
- icon: icon,
95
- iconPosition: iconPosition
96
- }, label)));
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 ");
97
97
  };
98
98
 
99
- var Button = _styledComponents["default"].button(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n display: inline-flex;\n width: ", ";\n height: 40px;\n padding-left: ", ";\n padding-right: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n align-items: center;\n justify-content: center;\n box-shadow: 0 0 0 2px transparent;\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n letter-spacing: ", ";\n cursor: pointer;\n &:focus {\n outline: none;\n box-shadow: 0 0 0 2px\n ", ";\n }\n ", "\n"])), function (props) {
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) {
100
104
  return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
101
105
  }, function (props) {
102
106
  return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
@@ -106,16 +110,14 @@ var Button = _styledComponents["default"].button(_templateObject || (_templateOb
106
110
  return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
107
111
  }, function (props) {
108
112
  return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
109
- }, function (props) {
110
- return calculateWidth(props.margin, props.size);
111
- }, function (props) {
112
- return props.theme.paddingLeft;
113
- }, function (props) {
114
- return props.theme.paddingRight;
115
113
  }, function (props) {
116
114
  return props.theme.paddingTop;
117
115
  }, function (props) {
118
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)");
119
121
  }, function (props) {
120
122
  return props.theme.fontFamily;
121
123
  }, function (props) {
@@ -127,27 +129,16 @@ var Button = _styledComponents["default"].button(_templateObject || (_templateOb
127
129
  }, function (props) {
128
130
  return props.backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor;
129
131
  }, function (props) {
130
- var mode = props.mode,
131
- backgroundType = props.backgroundType,
132
- disabled = props.disabled;
133
- 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);
134
133
  });
135
134
 
136
- 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 margin-right: ", ";\n margin-left: ", ";\n"])), function (props) {
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) {
137
136
  return props.theme.labelFontLineHeight;
138
137
  }, function (props) {
139
138
  return props.theme.fontSize;
140
- }, function (props) {
141
- return !props.icon || props.iconPosition === "before" ? "8px" : "0px";
142
- }, function (props) {
143
- return !props.icon || props.iconPosition === "after" ? "8px" : "0px";
144
139
  });
145
140
 
146
- 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) {
147
- return !props.label ? "0px" : props.iconPosition === "after" && props.label !== "" && "8px" || "8px";
148
- }, function (props) {
149
- return !props.label ? "0px" : props.iconPosition === "before" && props.label !== "" && "8px" || "8px";
150
- });
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"])));
151
142
 
152
143
  var _default = DxcButton;
153
144
  exports["default"] = _default;
@@ -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://developer.apple.com/design/human-interface-guidelines/foundations/app-icons/images/icon-and-image-large-icon-settings_2x.png"
168
+ icon="https://www.freepnglogos.com/uploads/facebook-logo-design-1.png"
169
169
  />
170
170
  </ExampleContainer>
171
171
  <BackgroundColorProvider color="#333333">
@@ -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
  */
@@ -23,7 +23,7 @@ var CORE_TOKENS = {
23
23
  color_grey_700: "#666666",
24
24
  color_grey_800: "#4d4d4d",
25
25
  color_grey_900: "#333333",
26
- // Trasparent variants
26
+ // Transparent variants
27
27
  color_grey_50_a: "#00000005",
28
28
  color_grey_100_a: "#0000000d",
29
29
  color_grey_200_a: "#0000001a",
@@ -19,7 +19,7 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
19
19
 
20
20
  var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
21
21
 
22
- var _main = require("../main");
22
+ var _Flex = _interopRequireDefault(require("../flex/Flex"));
23
23
 
24
24
  var _templateObject, _templateObject2, _templateObject3, _templateObject4;
25
25
 
@@ -183,7 +183,7 @@ var Calendar = function Calendar(_ref) {
183
183
  }
184
184
  };
185
185
 
186
- return /*#__PURE__*/_react["default"].createElement(CalendarContainer, null, /*#__PURE__*/_react["default"].createElement(_main.DxcFlex, {
186
+ return /*#__PURE__*/_react["default"].createElement(CalendarContainer, null, /*#__PURE__*/_react["default"].createElement(_Flex["default"], {
187
187
  alignItems: "center",
188
188
  justifyContent: "space-between"
189
189
  }, weekDays.map(function (weekDay) {
@@ -15,7 +15,7 @@ var _react = _interopRequireDefault(require("react"));
15
15
 
16
16
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
17
17
 
18
- var _main = require("../main");
18
+ var _Flex = _interopRequireDefault(require("../flex/Flex"));
19
19
 
20
20
  var _useTheme = _interopRequireDefault(require("../useTheme"));
21
21
 
@@ -80,7 +80,7 @@ var FileItem = function FileItem(_ref) {
80
80
  }) : /*#__PURE__*/_react["default"].createElement(IconPreview, {
81
81
  error: error,
82
82
  "aria-label": getIconAriaLabel()
83
- }, preview)), /*#__PURE__*/_react["default"].createElement(FileItemContent, null, /*#__PURE__*/_react["default"].createElement(FileName, null, fileName), /*#__PURE__*/_react["default"].createElement(_main.DxcFlex, {
83
+ }, preview)), /*#__PURE__*/_react["default"].createElement(FileItemContent, null, /*#__PURE__*/_react["default"].createElement(FileName, null, fileName), /*#__PURE__*/_react["default"].createElement(_Flex["default"], {
84
84
  gap: "0.25rem"
85
85
  }, error && /*#__PURE__*/_react["default"].createElement(ErrorIcon, null, errorIcon), /*#__PURE__*/_react["default"].createElement(DeleteFileAction, {
86
86
  onClick: function onClick() {
package/footer/Footer.js CHANGED
@@ -27,7 +27,9 @@ var _BackgroundColorContext = require("../BackgroundColorContext");
27
27
 
28
28
  var _Icons = require("./Icons");
29
29
 
30
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14;
30
+ var _Flex = _interopRequireDefault(require("../flex/Flex"));
31
+
32
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10;
31
33
 
32
34
  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); }
33
35
 
@@ -56,57 +58,56 @@ var DxcFooter = function DxcFooter(_ref) {
56
58
  }
57
59
 
58
60
  return colorsTheme.footer.logo;
59
- }, [colorsTheme.footer.logo]);
60
- var socialLink = socialLinks === null || socialLinks === void 0 ? void 0 : socialLinks.map(function (link, index) {
61
+ }, [colorsTheme]);
62
+ return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
63
+ theme: colorsTheme.footer
64
+ }, /*#__PURE__*/_react["default"].createElement(FooterContainer, {
65
+ margin: margin
66
+ }, /*#__PURE__*/_react["default"].createElement(_Flex["default"], {
67
+ justifyContent: "space-between",
68
+ alignItems: "center",
69
+ wrap: "wrap",
70
+ gap: "1.5rem"
71
+ }, /*#__PURE__*/_react["default"].createElement(LogoContainer, null, footerLogo), /*#__PURE__*/_react["default"].createElement(_Flex["default"], null, socialLinks === null || socialLinks === void 0 ? void 0 : socialLinks.map(function (link, index) {
61
72
  return /*#__PURE__*/_react["default"].createElement(SocialAnchor, {
73
+ href: link.href,
62
74
  tabIndex: tabIndex,
75
+ title: link.title,
76
+ "aria-label": link.title,
63
77
  key: "social".concat(index).concat(link.href),
64
- index: index,
65
- href: link && link.href ? link.href : ""
66
- }, /*#__PURE__*/_react["default"].createElement(SocialIconContainer, null, typeof link.logo === "string" ? /*#__PURE__*/_react["default"].createElement(SocialIconImg, {
78
+ index: index
79
+ }, /*#__PURE__*/_react["default"].createElement(SocialIconContainer, null, typeof link.logo === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
67
80
  src: link.logo
68
81
  }) : link.logo));
69
- });
70
- var bottomLink = bottomLinks === null || bottomLinks === void 0 ? void 0 : bottomLinks.map(function (link, index) {
82
+ }))), /*#__PURE__*/_react["default"].createElement(ChildComponents, null, /*#__PURE__*/_react["default"].createElement(_BackgroundColorContext.BackgroundColorProvider, {
83
+ color: colorsTheme.footer.backgroundColor
84
+ }, children)), /*#__PURE__*/_react["default"].createElement(BottomContainer, null, /*#__PURE__*/_react["default"].createElement(BottomLinks, null, bottomLinks === null || bottomLinks === void 0 ? void 0 : bottomLinks.map(function (link, index) {
71
85
  return /*#__PURE__*/_react["default"].createElement("span", {
72
86
  key: "bottom".concat(index).concat(link.text)
73
87
  }, /*#__PURE__*/_react["default"].createElement(BottomLink, {
74
- tabIndex: tabIndex,
75
- href: link && link.href ? link.href : ""
76
- }, link && link.text ? link.text : ""), /*#__PURE__*/_react["default"].createElement(Point, null, "\xB7"));
77
- });
78
- return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
79
- theme: colorsTheme.footer
80
- }, /*#__PURE__*/_react["default"].createElement(FooterContainer, {
81
- margin: margin
82
- }, /*#__PURE__*/_react["default"].createElement(FooterHeader, null, /*#__PURE__*/_react["default"].createElement(LogoContainer, null, footerLogo), /*#__PURE__*/_react["default"].createElement(SocialLinkContainer, null, socialLink)), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(ChildComponents, null, /*#__PURE__*/_react["default"].createElement(_BackgroundColorContext.BackgroundColorProvider, {
83
- color: colorsTheme.footer.backgroundColor
84
- }, children)), /*#__PURE__*/_react["default"].createElement(FooterFooter, {
85
- className: "footerFooter"
86
- }, /*#__PURE__*/_react["default"].createElement(BottomLinks, null, bottomLink), /*#__PURE__*/_react["default"].createElement(Copyright, null, copyright || translatedLabels.footer.copyrightText(new Date().getFullYear()))))));
88
+ href: link.href,
89
+ tabIndex: tabIndex
90
+ }, link.text));
91
+ })), /*#__PURE__*/_react["default"].createElement(Copyright, null, copyright || translatedLabels.footer.copyrightText(new Date().getFullYear())))));
87
92
  };
88
93
 
89
- var FooterContainer = _styledComponents["default"].footer(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n @media (min-width: ", "rem) {\n padding: 24px 36px 24px 36px;\n }\n\n @media (max-width: ", "rem) {\n padding: 20px;\n }\n\n background-color: ", ";\n margin-top: ", ";\n width: 100%;\n box-sizing: border-box;\n min-height: ", ";\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n"])), _variables.responsiveSizes.small, _variables.responsiveSizes.small, function (props) {
90
- return props.theme.backgroundColor;
94
+ var FooterContainer = _styledComponents["default"].footer(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n width: 100%;\n min-height: ", ";\n margin-top: ", ";\n background-color: ", ";\n\n @media (min-width: ", "rem) {\n padding: 24px 36px 24px 36px;\n }\n @media (max-width: ", "rem) {\n padding: 20px;\n }\n"])), function (props) {
95
+ return props.theme.height;
91
96
  }, function (props) {
92
97
  return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
93
98
  }, function (props) {
94
- return props.theme.height;
95
- });
96
-
97
- var FooterHeader = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n justify-content: space-between;\n flex-wrap: wrap;\n row-gap: 24px;\n"])));
99
+ return props.theme.backgroundColor;
100
+ }, _variables.responsiveSizes.small, _variables.responsiveSizes.small);
98
101
 
99
- var FooterFooter = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n justify-content: space-between;\n align-items: flex-end;\n\n @media (min-width: ", "rem) {\n flex-direction: row;\n }\n\n @media (max-width: ", "rem) {\n flex-direction: column;\n align-items: center;\n }\n\n border-top: ", ";\n margin-top: 16px;\n"])), _variables.responsiveSizes.small, _variables.responsiveSizes.small, function (props) {
102
+ var BottomContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n justify-content: space-between;\n align-items: flex-end;\n\n @media (min-width: ", "rem) {\n flex-direction: row;\n }\n @media (max-width: ", "rem) {\n flex-direction: column;\n align-items: center;\n }\n\n border-top: ", ";\n margin-top: 16px;\n"])), _variables.responsiveSizes.small, _variables.responsiveSizes.small, function (props) {
100
103
  return "".concat(props.theme.bottomLinksDividerThickness, " ").concat(props.theme.bottomLinksDividerStyle, " ").concat(props.theme.bottomLinksDividerColor);
101
104
  });
102
105
 
103
- var BottomLinks = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n padding-top: ", ";\n display: inline-flex;\n flex-wrap: wrap;\n\n @media (min-width: ", "rem) {\n max-width: 60%;\n }\n\n @media (max-width: ", "rem) {\n max-width: 100%;\n width: 100%;\n }\n\n & > span:last-child span {\n display: none;\n }\n align-self: center;\n"])), function (props) {
104
- return props.theme.bottomLinksDividerSpacing;
105
- }, _variables.responsiveSizes.small, _variables.responsiveSizes.small);
106
-
107
- var ChildComponents = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n min-height: 16px;\n overflow: hidden;\n"])));
106
+ var ChildComponents = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n min-height: 16px;\n overflow: hidden;\n"])));
108
107
 
109
- var Copyright = _styledComponents["default"].div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n\n @media (min-width: ", "rem) {\n max-width: 40%;\n text-align: right;\n }\n\n @media (max-width: ", "rem) {\n max-width: 100%;\n width: 100%;\n text-align: left;\n }\n\n padding-top: ", ";\n"])), function (props) {
108
+ var Copyright = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n padding-top: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n\n @media (min-width: ", "rem) {\n max-width: 40%;\n text-align: right;\n }\n\n @media (max-width: ", "rem) {\n max-width: 100%;\n width: 100%;\n text-align: left;\n }\n"])), function (props) {
109
+ return props.theme.bottomLinksDividerSpacing;
110
+ }, function (props) {
110
111
  return props.theme.copyrightFontFamily;
111
112
  }, function (props) {
112
113
  return props.theme.copyrightFontSize;
@@ -116,31 +117,25 @@ var Copyright = _styledComponents["default"].div(_templateObject6 || (_templateO
116
117
  return props.theme.copyrightFontWeight;
117
118
  }, function (props) {
118
119
  return props.theme.copyrightFontColor;
119
- }, _variables.responsiveSizes.small, _variables.responsiveSizes.small, function (props) {
120
- return props.theme.bottomLinksDividerSpacing;
121
- });
120
+ }, _variables.responsiveSizes.small, _variables.responsiveSizes.small);
122
121
 
123
- var LogoContainer = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n max-height: ", ";\n width: ", ";\n"])), function (props) {
122
+ var LogoContainer = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n max-height: ", ";\n width: ", ";\n"])), function (props) {
124
123
  return props.theme.logoHeight;
125
124
  }, function (props) {
126
125
  return props.theme.logoWidth;
127
126
  });
128
127
 
129
- var LogoImg = _styledComponents["default"].img(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n max-height: ", ";\n width: ", ";\n"])), function (props) {
128
+ var LogoImg = _styledComponents["default"].img(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n max-height: ", ";\n width: ", ";\n"])), function (props) {
130
129
  return props.theme.logoHeight;
131
130
  }, function (props) {
132
131
  return props.theme.logoWidth;
133
132
  });
134
133
 
135
- var SocialLinkContainer = _styledComponents["default"].div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-self: center;\n"])));
136
-
137
- var SocialAnchor = _styledComponents["default"].a(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["\n & {\n display: inline-flex;\n margin-left: ", ";\n }\n"])), function (props) {
134
+ var SocialAnchor = _styledComponents["default"].a(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n margin-left: ", ";\n border-radius: 4px;\n\n &:focus {\n outline: 2px solid #0095ff;\n outline-offset: 2px;\n }\n"])), function (props) {
138
135
  return props.index === 0 ? "0px" : props.theme.socialLinksGutter;
139
136
  });
140
137
 
141
- var SocialIconImg = _styledComponents["default"].img(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2["default"])([""])));
142
-
143
- var SocialIconContainer = _styledComponents["default"].div(_templateObject12 || (_templateObject12 = (0, _taggedTemplateLiteral2["default"])(["\n & {\n display: inline-flex;\n height: ", ";\n width: ", ";\n color: ", ";\n }\n\n overflow: hidden;\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
138
+ var SocialIconContainer = _styledComponents["default"].div(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n height: ", ";\n width: ", ";\n color: ", ";\n overflow: hidden;\n\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
144
139
  return props.theme.socialLinksSize;
145
140
  }, function (props) {
146
141
  return props.theme.socialLinksSize;
@@ -148,11 +143,11 @@ var SocialIconContainer = _styledComponents["default"].div(_templateObject12 ||
148
143
  return props.theme.socialLinksColor;
149
144
  });
150
145
 
151
- var Point = _styledComponents["default"].span(_templateObject13 || (_templateObject13 = (0, _taggedTemplateLiteral2["default"])(["\n margin: 0px 10px;\n color: ", ";\n"])), function (props) {
152
- return props.theme.bottomLinksFontColor;
153
- });
146
+ var BottomLinks = _styledComponents["default"].div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n flex-wrap: wrap;\n align-self: center;\n padding-top: ", ";\n color: #fff;\n\n @media (min-width: ", "rem) {\n max-width: 60%;\n }\n @media (max-width: ", "rem) {\n max-width: 100%;\n width: 100%;\n }\n\n & > span:not(:first-child):before {\n content: \"\xB7\";\n padding: 0 0.5rem;\n }\n"])), function (props) {
147
+ return props.theme.bottomLinksDividerSpacing;
148
+ }, _variables.responsiveSizes.small, _variables.responsiveSizes.small);
154
149
 
155
- var BottomLink = _styledComponents["default"].a(_templateObject14 || (_templateObject14 = (0, _taggedTemplateLiteral2["default"])(["\n text-decoration: ", ";\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n"])), function (props) {
150
+ var BottomLink = _styledComponents["default"].a(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["\n text-decoration: ", ";\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n border-radius: 2px;\n\n &:focus {\n outline: 2px solid #0095ff;\n }\n"])), function (props) {
156
151
  return props.theme.bottomLinksTextDecoration;
157
152
  }, function (props) {
158
153
  return props.theme.bottomLinksFontColor;
@@ -26,6 +26,7 @@ const social = [
26
26
  </g>
27
27
  </svg>
28
28
  ),
29
+ title: "Linkedin",
29
30
  },
30
31
  {
31
32
  href: "https://twitter.com/dxctechnology",
@@ -37,6 +38,7 @@ const social = [
37
38
  />
38
39
  </svg>
39
40
  ),
41
+ title: "Twitter",
40
42
  },
41
43
  {
42
44
  href: "https://www.facebook.com/DXCTechnology/",
@@ -63,6 +65,7 @@ const social = [
63
65
  </g>
64
66
  </svg>
65
67
  ),
68
+ title: "Facebook",
66
69
  },
67
70
  ];
68
71
 
@@ -109,6 +112,14 @@ export const Chromatic = () => (
109
112
  </div>
110
113
  </DxcFooter>
111
114
  </ExampleContainer>
115
+ <ExampleContainer pseudoState="pseudo-focus">
116
+ <Title title="Focused bottom and social links" theme="light" level={4} />
117
+ <DxcFooter copyright="Copyright" socialLinks={social} bottomLinks={bottom}>
118
+ <div>
119
+ <a href="https://www.linkedin.com/company/dxctechnology">Linkedin</a>
120
+ </div>
121
+ </DxcFooter>
122
+ </ExampleContainer>
112
123
  <Title title="Margins" theme="light" level={2} />
113
124
  <ExampleContainer>
114
125
  <Title title="Xxsmall margin" theme="light" level={4} />
@@ -10,7 +10,8 @@ var _Footer = _interopRequireDefault(require("./Footer.tsx"));
10
10
 
11
11
  var social = [{
12
12
  href: "https://www.test.com/social",
13
- logo: "https://developer.apple.com/design/human-interface-guidelines/foundations/app-icons/images/icon-and-image-large-icon-settings_2x.png"
13
+ logo: "https://developer.apple.com/design/human-interface-guidelines/foundations/app-icons/images/icon-and-image-large-icon-settings_2x.png",
14
+ title: "test"
14
15
  }];
15
16
  var bottom = [{
16
17
  href: "https://www.test.com/bottom",
@@ -89,6 +90,7 @@ describe("Footer component tests", function () {
89
90
 
90
91
  var socialIcon = getAllByRole("link")[0];
91
92
  expect(socialIcon.getAttribute("href")).toBe("https://www.test.com/social");
93
+ expect(socialIcon.getAttribute("aria-label")).toBe("test");
92
94
  var bottomLink = getByText("bottom-link-text");
93
95
  expect(bottomLink.getAttribute("href")).toBe("https://www.test.com/bottom");
94
96
  expect(getByText("test-copyright")).toBeTruthy();
package/footer/types.d.ts CHANGED
@@ -8,24 +8,28 @@ declare type Size = {
8
8
  };
9
9
  declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
10
10
  declare type SocialLink = {
11
+ /**
12
+ * URL of the page the link goes to.
13
+ */
14
+ href: string;
11
15
  /**
12
16
  * Element used as the icon for the link.
13
17
  */
14
18
  logo: string | SVG;
15
19
  /**
16
- * URL of the page the link goes to.
20
+ * Value for the HTML properties title and aria-label.
17
21
  */
18
- href: string;
22
+ title: string;
19
23
  };
20
24
  declare type BottomLink = {
21
- /**
22
- * Text for the link.
23
- */
24
- text: string;
25
25
  /**
26
26
  * URL of the page the link goes to.
27
27
  */
28
28
  href: string;
29
+ /**
30
+ * Text for the link.
31
+ */
32
+ text: string;
29
33
  };
30
34
  declare type FooterPropsType = {
31
35
  /**
package/grid/Grid.d.ts CHANGED
@@ -2,6 +2,6 @@
2
2
  import GridPropsType, { GridItemProps } from "./types";
3
3
  declare const DxcGrid: {
4
4
  (props: GridPropsType): JSX.Element;
5
- GridItem: import("styled-components").StyledComponent<"div", any, GridItemProps, never>;
5
+ Item: import("styled-components").StyledComponent<"div", any, GridItemProps, never>;
6
6
  };
7
7
  export default DxcGrid;
package/grid/Grid.js CHANGED
@@ -86,6 +86,6 @@ var GridItem = _styledComponents["default"].div(_templateObject2 || (_templateOb
86
86
  return placeSelf && (typeof placeSelf === "string" ? "place-self: ".concat(placeSelf) : "align-self: ".concat((_placeSelf$alignSelf2 = placeSelf.alignSelf) !== null && _placeSelf$alignSelf2 !== void 0 ? _placeSelf$alignSelf2 : "", "; justify-self: ").concat((_placeSelf$justifySel2 = placeSelf.justifySelf) !== null && _placeSelf$justifySel2 !== void 0 ? _placeSelf$justifySel2 : "", ";"));
87
87
  });
88
88
 
89
- DxcGrid.GridItem = GridItem;
89
+ DxcGrid.Item = GridItem;
90
90
  var _default = DxcGrid;
91
91
  exports["default"] = _default;