@dxc-technology/halstack-react 0.0.0-d3554d7 → 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 +5 -22
- package/HalstackContext.d.ts +1221 -0
- package/HalstackContext.js +310 -0
- package/README.md +47 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +116 -181
- package/accordion/Accordion.stories.tsx +103 -127
- package/accordion/Accordion.test.js +32 -33
- package/accordion/types.d.ts +9 -16
- package/accordion-group/AccordionGroup.d.ts +5 -4
- package/accordion-group/AccordionGroup.js +38 -107
- package/accordion-group/AccordionGroup.stories.tsx +95 -68
- package/accordion-group/AccordionGroup.test.js +55 -90
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +31 -0
- package/accordion-group/types.d.ts +15 -16
- 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 +23 -59
- package/alert/Alert.stories.tsx +28 -0
- package/alert/Alert.test.js +29 -46
- package/alert/types.d.ts +5 -5
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +142 -40
- package/badge/Badge.stories.tsx +210 -0
- package/badge/Badge.test.js +30 -0
- package/badge/types.d.ts +52 -2
- package/bleed/Bleed.js +14 -55
- package/bleed/Bleed.stories.tsx +95 -95
- package/bleed/types.d.ts +26 -2
- package/box/Box.d.ts +1 -1
- package/box/Box.js +30 -81
- package/box/Box.stories.tsx +38 -51
- package/box/Box.test.js +2 -7
- package/box/types.d.ts +3 -14
- package/bulleted-list/BulletedList.d.ts +7 -0
- package/bulleted-list/BulletedList.js +89 -0
- package/bulleted-list/BulletedList.stories.tsx +115 -0
- package/bulleted-list/types.d.ts +38 -0
- package/button/Button.d.ts +1 -1
- package/button/Button.js +62 -113
- package/button/Button.stories.tsx +160 -90
- package/button/Button.test.js +20 -17
- package/button/types.d.ts +12 -8
- package/card/Card.d.ts +1 -1
- package/card/Card.js +58 -102
- package/card/Card.stories.tsx +12 -42
- package/card/Card.test.js +11 -22
- package/card/types.d.ts +6 -11
- package/checkbox/Checkbox.d.ts +2 -2
- package/checkbox/Checkbox.js +144 -182
- package/checkbox/Checkbox.stories.tsx +166 -136
- package/checkbox/Checkbox.test.js +163 -29
- package/checkbox/types.d.ts +18 -6
- package/chip/Chip.js +39 -79
- package/chip/Chip.stories.tsx +121 -26
- package/chip/Chip.test.js +16 -31
- 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.d.ts +1 -0
- package/common/utils.js +6 -12
- package/common/variables.d.ts +1367 -0
- package/common/variables.js +1002 -1136
- 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.d.ts +4 -0
- package/date-input/Calendar.js +214 -0
- package/date-input/DateInput.js +171 -306
- package/date-input/DateInput.stories.tsx +203 -56
- package/date-input/DateInput.test.js +708 -369
- package/date-input/DatePicker.d.ts +4 -0
- package/date-input/DatePicker.js +115 -0
- package/date-input/Icons.d.ts +6 -0
- package/date-input/Icons.js +58 -0
- package/date-input/YearPicker.d.ts +4 -0
- package/date-input/YearPicker.js +100 -0
- package/date-input/types.d.ts +86 -22
- package/dialog/Dialog.d.ts +1 -1
- package/dialog/Dialog.js +68 -130
- package/dialog/Dialog.stories.tsx +320 -167
- package/dialog/Dialog.test.js +287 -20
- package/dialog/types.d.ts +18 -25
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +243 -304
- package/dropdown/Dropdown.stories.tsx +245 -56
- package/dropdown/Dropdown.test.js +575 -165
- package/dropdown/DropdownMenu.d.ts +4 -0
- package/dropdown/DropdownMenu.js +63 -0
- package/dropdown/DropdownMenuItem.d.ts +4 -0
- package/dropdown/DropdownMenuItem.js +67 -0
- package/dropdown/types.d.ts +32 -14
- package/file-input/FileInput.d.ts +2 -2
- package/file-input/FileInput.js +246 -357
- package/file-input/FileInput.stories.tsx +123 -12
- package/file-input/FileInput.test.js +369 -367
- package/file-input/FileItem.d.ts +4 -14
- package/file-input/FileItem.js +50 -99
- package/file-input/types.d.ts +25 -8
- package/flex/Flex.d.ts +4 -0
- package/flex/Flex.js +57 -0
- package/flex/Flex.stories.tsx +112 -0
- package/flex/types.d.ts +97 -0
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +70 -190
- package/footer/Footer.stories.tsx +60 -19
- package/footer/Footer.test.js +33 -57
- package/footer/Icons.d.ts +3 -2
- package/footer/Icons.js +67 -8
- package/footer/types.d.ts +25 -26
- 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/header/Header.d.ts +4 -3
- package/header/Header.js +99 -203
- package/header/Header.stories.tsx +152 -63
- package/header/Header.test.js +31 -28
- package/header/Icons.d.ts +2 -2
- package/header/Icons.js +4 -9
- package/header/types.d.ts +5 -19
- package/heading/Heading.js +10 -32
- package/heading/Heading.test.js +71 -88
- 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/inset/Inset.js +14 -55
- package/inset/Inset.stories.tsx +37 -36
- package/inset/types.d.ts +26 -2
- package/layout/ApplicationLayout.d.ts +16 -6
- package/layout/ApplicationLayout.js +84 -181
- package/layout/ApplicationLayout.stories.tsx +85 -94
- package/layout/Icons.d.ts +8 -0
- package/layout/Icons.js +51 -48
- package/layout/SidenavContext.d.ts +5 -0
- package/layout/SidenavContext.js +13 -0
- package/layout/types.d.ts +19 -35
- package/link/Link.d.ts +3 -2
- package/link/Link.js +61 -99
- package/link/Link.stories.tsx +155 -53
- package/link/Link.test.js +25 -53
- package/link/types.d.ts +15 -31
- package/main.d.ts +14 -13
- package/main.js +65 -101
- package/nav-tabs/NavTabs.d.ts +8 -0
- package/nav-tabs/NavTabs.js +93 -0
- package/nav-tabs/NavTabs.stories.tsx +276 -0
- package/nav-tabs/NavTabs.test.js +76 -0
- package/nav-tabs/Tab.d.ts +4 -0
- package/nav-tabs/Tab.js +118 -0
- package/nav-tabs/types.d.ts +52 -0
- package/nav-tabs/types.js +5 -0
- package/number-input/NumberInput.d.ts +7 -0
- package/number-input/NumberInput.js +27 -43
- package/number-input/NumberInput.stories.tsx +44 -28
- package/number-input/NumberInput.test.js +703 -381
- package/number-input/types.d.ts +28 -15
- package/package.json +46 -47
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +21 -47
- package/paginator/Paginator.js +34 -91
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +280 -211
- package/paginator/types.d.ts +3 -3
- package/paragraph/Paragraph.d.ts +5 -0
- package/paragraph/Paragraph.js +22 -0
- package/paragraph/Paragraph.stories.tsx +27 -0
- package/password-input/Icons.d.ts +6 -0
- package/password-input/Icons.js +35 -0
- package/password-input/PasswordInput.js +57 -123
- package/password-input/PasswordInput.stories.tsx +1 -33
- package/password-input/PasswordInput.test.js +162 -147
- package/password-input/types.d.ts +21 -17
- package/progress-bar/ProgressBar.js +65 -91
- package/progress-bar/ProgressBar.stories.tsx +93 -0
- package/progress-bar/ProgressBar.test.js +72 -44
- package/progress-bar/types.d.ts +3 -3
- package/quick-nav/QuickNav.d.ts +4 -0
- package/quick-nav/QuickNav.js +94 -0
- package/quick-nav/QuickNav.stories.tsx +356 -0
- package/quick-nav/types.d.ts +21 -0
- package/quick-nav/types.js +5 -0
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +59 -76
- package/radio-group/RadioGroup.js +72 -116
- package/radio-group/RadioGroup.stories.tsx +135 -17
- package/radio-group/RadioGroup.test.js +529 -467
- package/radio-group/types.d.ts +86 -9
- package/resultset-table/Icons.d.ts +7 -0
- package/resultset-table/Icons.js +47 -0
- package/{resultsetTable → resultset-table}/ResultsetTable.d.ts +1 -1
- package/resultset-table/ResultsetTable.js +165 -0
- package/{resultsetTable → resultset-table}/ResultsetTable.stories.tsx +69 -25
- package/{resultsetTable → resultset-table}/ResultsetTable.test.js +117 -118
- package/{resultsetTable → resultset-table}/types.d.ts +13 -7
- package/resultset-table/types.js +5 -0
- package/select/Icons.d.ts +10 -0
- package/select/Icons.js +89 -0
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +143 -0
- package/select/Option.d.ts +4 -0
- package/select/Option.js +87 -0
- package/select/Select.js +223 -502
- package/select/Select.stories.tsx +534 -145
- package/select/Select.test.js +2009 -1539
- package/select/types.d.ts +64 -25
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +47 -0
- package/sidenav/Sidenav.d.ts +6 -5
- package/sidenav/Sidenav.js +131 -71
- package/sidenav/Sidenav.stories.tsx +251 -151
- package/sidenav/Sidenav.test.js +26 -45
- package/sidenav/types.d.ts +52 -26
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +148 -180
- package/slider/Slider.test.js +198 -73
- package/slider/types.d.ts +11 -3
- package/spinner/Spinner.js +31 -75
- package/spinner/{Spinner.stories.jsx → Spinner.stories.tsx} +53 -27
- package/spinner/Spinner.test.js +26 -35
- 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.d.ts +2 -2
- package/switch/Switch.js +149 -114
- package/switch/Switch.stories.tsx +44 -67
- package/switch/Switch.test.js +146 -39
- package/switch/types.d.ts +13 -5
- package/table/Table.d.ts +1 -1
- package/table/Table.js +25 -32
- package/table/{Table.stories.jsx → Table.stories.tsx} +178 -1
- package/table/Table.test.js +3 -8
- package/table/types.d.ts +12 -6
- package/tabs/Tab.d.ts +4 -0
- package/tabs/Tab.js +116 -0
- package/tabs/Tabs.d.ts +1 -1
- package/tabs/Tabs.js +316 -145
- package/tabs/Tabs.stories.tsx +120 -14
- package/tabs/Tabs.test.js +238 -67
- package/tabs/types.d.ts +29 -15
- package/tag/Tag.js +41 -78
- package/tag/Tag.stories.tsx +25 -8
- package/tag/Tag.test.js +20 -31
- package/tag/types.d.ts +7 -7
- package/text-input/Icons.d.ts +8 -0
- package/text-input/Icons.js +56 -0
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +67 -0
- package/text-input/Suggestions.d.ts +4 -0
- package/text-input/Suggestions.js +84 -0
- package/text-input/TextInput.js +324 -548
- package/text-input/TextInput.stories.tsx +272 -281
- package/text-input/TextInput.test.js +1425 -1377
- package/text-input/types.d.ts +70 -24
- package/textarea/Textarea.js +82 -134
- package/textarea/Textarea.stories.tsx +174 -0
- package/textarea/Textarea.test.js +168 -198
- package/textarea/types.d.ts +27 -16
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +92 -105
- package/toggle-group/ToggleGroup.stories.tsx +53 -8
- package/toggle-group/ToggleGroup.test.js +78 -66
- package/toggle-group/types.d.ts +34 -17
- package/typography/Typography.d.ts +4 -0
- package/typography/Typography.js +23 -0
- package/typography/Typography.stories.tsx +198 -0
- package/typography/types.d.ts +18 -0
- package/typography/types.js +5 -0
- package/useTheme.d.ts +1119 -1
- package/useTheme.js +4 -11
- package/useTranslatedLabels.d.ts +85 -0
- package/useTranslatedLabels.js +14 -0
- package/utils/BaseTypography.d.ts +21 -0
- package/utils/BaseTypography.js +94 -0
- package/utils/FocusLock.d.ts +13 -0
- package/utils/FocusLock.js +124 -0
- package/wizard/Wizard.d.ts +1 -1
- package/wizard/Wizard.js +70 -101
- package/wizard/Wizard.stories.tsx +48 -19
- package/wizard/Wizard.test.js +73 -87
- package/wizard/types.d.ts +12 -8
- package/ThemeContext.d.ts +0 -10
- package/ThemeContext.js +0 -243
- package/card/ice-cream.jpg +0 -0
- package/common/RequiredComponent.js +0 -32
- package/list/List.d.ts +0 -4
- package/list/List.js +0 -47
- package/list/List.stories.tsx +0 -95
- package/list/types.d.ts +0 -7
- package/number-input/NumberInputContext.d.ts +0 -4
- package/number-input/NumberInputContext.js +0 -19
- package/number-input/numberInputContextTypes.d.ts +0 -19
- package/progress-bar/ProgressBar.stories.jsx +0 -58
- package/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -174
- package/radio/Radio.stories.tsx +0 -192
- package/radio/Radio.test.js +0 -71
- package/radio/types.d.ts +0 -54
- package/resultsetTable/ResultsetTable.js +0 -254
- package/row/Row.d.ts +0 -3
- package/row/Row.js +0 -127
- package/row/Row.stories.tsx +0 -237
- package/row/types.d.ts +0 -10
- package/slider/Slider.stories.tsx +0 -177
- package/stack/Stack.d.ts +0 -3
- package/stack/Stack.js +0 -97
- package/stack/Stack.stories.tsx +0 -164
- package/stack/types.d.ts +0 -9
- package/text/Text.d.ts +0 -7
- package/text/Text.js +0 -30
- package/text/Text.stories.tsx +0 -19
- package/textarea/Textarea.stories.jsx +0 -157
- /package/{list → action-icon}/types.js +0 -0
- /package/{radio → bulleted-list}/types.js +0 -0
- /package/{resultsetTable → container}/types.js +0 -0
- /package/{row → flex}/types.js +0 -0
- /package/{stack → grid}/types.js +0 -0
- /package/{number-input/numberInputContextTypes.js → image/types.js} +0 -0
package/link/Link.js
CHANGED
|
@@ -1,81 +1,71 @@
|
|
|
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
|
-
var
|
|
17
|
-
|
|
11
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
18
14
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
19
|
-
|
|
20
|
-
var _variables = require("../common/variables.js");
|
|
21
|
-
|
|
15
|
+
var _variables = require("../common/variables");
|
|
22
16
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
23
|
-
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
inheritColor = _ref$inheritColor === void 0 ? false : _ref$inheritColor,
|
|
33
|
-
_ref$disabled = _ref.disabled,
|
|
34
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
35
|
-
icon = _ref.icon,
|
|
36
|
-
_ref$iconPosition = _ref.iconPosition,
|
|
37
|
-
iconPosition = _ref$iconPosition === void 0 ? "before" : _ref$iconPosition,
|
|
38
|
-
_ref$href = _ref.href,
|
|
39
|
-
href = _ref$href === void 0 ? "" : _ref$href,
|
|
40
|
-
_ref$newWindow = _ref.newWindow,
|
|
41
|
-
newWindow = _ref$newWindow === void 0 ? false : _ref$newWindow,
|
|
42
|
-
onClick = _ref.onClick,
|
|
43
|
-
_ref$text = _ref.text,
|
|
44
|
-
text = _ref$text === void 0 ? "" : _ref$text,
|
|
45
|
-
margin = _ref.margin,
|
|
46
|
-
_ref$tabIndex = _ref.tabIndex,
|
|
47
|
-
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
48
|
-
var colorsTheme = (0, _useTheme["default"])();
|
|
49
|
-
|
|
50
|
-
var linkContent = /*#__PURE__*/_react["default"].createElement(LinkText, {
|
|
51
|
-
iconPosition: iconPosition
|
|
52
|
-
}, text, icon && /*#__PURE__*/_react["default"].createElement(LinkIconContainer, {
|
|
17
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
18
|
+
var _excluded = ["inheritColor", "disabled", "icon", "iconPosition", "href", "newWindow", "onClick", "margin", "tabIndex", "children"];
|
|
19
|
+
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); }
|
|
20
|
+
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; }
|
|
21
|
+
var LinkContent = /*#__PURE__*/_react["default"].memo(function (_ref) {
|
|
22
|
+
var iconPosition = _ref.iconPosition,
|
|
23
|
+
icon = _ref.icon,
|
|
24
|
+
children = _ref.children;
|
|
25
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, iconPosition === "after" && children, icon && /*#__PURE__*/_react["default"].createElement(LinkIconContainer, {
|
|
53
26
|
iconPosition: iconPosition
|
|
54
27
|
}, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement(LinkIcon, {
|
|
55
28
|
src: icon
|
|
56
|
-
}) : icon));
|
|
57
|
-
|
|
29
|
+
}) : icon), iconPosition === "before" && children);
|
|
30
|
+
});
|
|
31
|
+
var DxcLink = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
32
|
+
var _ref2$inheritColor = _ref2.inheritColor,
|
|
33
|
+
inheritColor = _ref2$inheritColor === void 0 ? false : _ref2$inheritColor,
|
|
34
|
+
_ref2$disabled = _ref2.disabled,
|
|
35
|
+
disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
|
|
36
|
+
icon = _ref2.icon,
|
|
37
|
+
_ref2$iconPosition = _ref2.iconPosition,
|
|
38
|
+
iconPosition = _ref2$iconPosition === void 0 ? "before" : _ref2$iconPosition,
|
|
39
|
+
_ref2$href = _ref2.href,
|
|
40
|
+
href = _ref2$href === void 0 ? "" : _ref2$href,
|
|
41
|
+
_ref2$newWindow = _ref2.newWindow,
|
|
42
|
+
newWindow = _ref2$newWindow === void 0 ? false : _ref2$newWindow,
|
|
43
|
+
onClick = _ref2.onClick,
|
|
44
|
+
margin = _ref2.margin,
|
|
45
|
+
_ref2$tabIndex = _ref2.tabIndex,
|
|
46
|
+
tabIndex = _ref2$tabIndex === void 0 ? 0 : _ref2$tabIndex,
|
|
47
|
+
children = _ref2.children,
|
|
48
|
+
otherProps = (0, _objectWithoutProperties2["default"])(_ref2, _excluded);
|
|
49
|
+
var colorsTheme = (0, _useTheme["default"])();
|
|
58
50
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
59
51
|
theme: colorsTheme.link
|
|
60
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
61
|
-
|
|
62
|
-
}, onClick ? /*#__PURE__*/_react["default"].createElement(StyledButton, {
|
|
63
|
-
type: "button",
|
|
64
|
-
onClick: !disabled && onClick,
|
|
65
|
-
margin: margin,
|
|
66
|
-
disabled: disabled,
|
|
67
|
-
inheritColor: inheritColor
|
|
68
|
-
}, linkContent) : /*#__PURE__*/_react["default"].createElement(StyledLink, {
|
|
52
|
+
}, /*#__PURE__*/_react["default"].createElement(StyledLink, (0, _extends2["default"])({
|
|
53
|
+
as: href ? "a" : "button",
|
|
69
54
|
tabIndex: tabIndex,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
55
|
+
onClick: !disabled ? onClick : undefined,
|
|
56
|
+
href: !disabled && href ? href : undefined,
|
|
57
|
+
target: href ? newWindow ? "_blank" : "_self" : undefined,
|
|
73
58
|
disabled: disabled,
|
|
74
|
-
inheritColor: inheritColor
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
59
|
+
inheritColor: inheritColor,
|
|
60
|
+
margin: margin,
|
|
61
|
+
ref: ref
|
|
62
|
+
}, otherProps), /*#__PURE__*/_react["default"].createElement(LinkContent, {
|
|
63
|
+
iconPosition: iconPosition,
|
|
64
|
+
icon: icon,
|
|
65
|
+
children: children
|
|
66
|
+
})));
|
|
67
|
+
});
|
|
68
|
+
var StyledLink = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n align-items: baseline;\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n background: none;\n border: none;\n padding: 0;\n cursor: pointer;\n font-size: ", ";\n font-weight: ", ";\n font-style: ", ";\n font-family: ", ";\n text-decoration-color: transparent;\n width: fit-content;\n ", "\n ", "\n color: ", ";\n ", "\n &:visited {\n color: ", ";\n &:hover {\n ", "\n }\n }\n &:hover {\n ", "\n }\n &:focus {\n border-radius: 2px;\n outline: 2px solid ", ";\n ", "\n }\n &:active {\n ", "\n }\n"])), function (props) {
|
|
79
69
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
80
70
|
}, function (props) {
|
|
81
71
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
|
|
@@ -85,36 +75,26 @@ var DxcLinkContainer = _styledComponents["default"].div(_templateObject || (_tem
|
|
|
85
75
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
|
|
86
76
|
}, function (props) {
|
|
87
77
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
var StyledLink = _styledComponents["default"].a(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n ", "\n\n text-decoration-color: transparent;\n ", "\n\n &:visited {\n color: ", ";\n &:hover {\n ", "\n }\n }\n &:hover {\n ", "\n }\n &:focus {\n border-radius: 2px;\n outline: 2px solid ", ";\n ", "\n }\n &:active {\n ", "\n }\n"])), function (props) {
|
|
91
|
-
return props.inheritColor ? "inherit" : !props.disabled ? props.theme.fontColor : props.theme.disabledColor;
|
|
92
|
-
}, function (props) {
|
|
93
|
-
return props.disabled ? "pointer-events: none;" : "";
|
|
94
|
-
}, function (props) {
|
|
95
|
-
return "padding-bottom: ".concat(props.theme.underlineSpacing, ";\n border-bottom: ").concat(props.theme.underlineThickness, " ").concat(props.theme.underlineStyle, " transparent;");
|
|
96
78
|
}, function (props) {
|
|
97
|
-
return
|
|
98
|
-
}, function (props) {
|
|
99
|
-
return "color: ".concat(props.theme.visitedFontColor, ";\n border-bottom-color: ").concat(props.theme.visitedUnderlineColor, ";");
|
|
79
|
+
return props.theme.fontSize;
|
|
100
80
|
}, function (props) {
|
|
101
|
-
return
|
|
81
|
+
return props.theme.fontWeight;
|
|
102
82
|
}, function (props) {
|
|
103
|
-
return props.theme.
|
|
83
|
+
return props.theme.fontStyle;
|
|
104
84
|
}, function (props) {
|
|
105
|
-
return props.
|
|
85
|
+
return props.theme.fontFamily;
|
|
106
86
|
}, function (props) {
|
|
107
|
-
return "color: ".concat(props.theme.activeFontColor, " !important;\n border-bottom-color: ").concat(props.theme.activeUnderlineColor, " !important;");
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
var StyledButton = _styledComponents["default"].button(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n background: none;\n border: none;\n padding: 0;\n cursor: pointer;\n font-family: inherit;\n text-decoration-color: transparent;\n\n ", "\n ", "\n color: ", ";\n ", "\n\n &:hover {\n ", "\n }\n &:focus {\n border-radius: 2px;\n outline: 2px solid ", ";\n ", "\n }\n &:active {\n ", "\n }\n"])), function (props) {
|
|
111
87
|
return "padding-bottom: ".concat(props.theme.underlineSpacing, ";\n border-bottom: ").concat(props.theme.underlineThickness, " ").concat(props.theme.underlineStyle, " transparent;");
|
|
112
88
|
}, function (props) {
|
|
113
89
|
return props.disabled && "cursor: default;";
|
|
114
90
|
}, function (props) {
|
|
115
|
-
return props.inheritColor ? "inherit" : !props.disabled ? props.theme.fontColor : props.theme.
|
|
91
|
+
return props.inheritColor ? "inherit" : !props.disabled ? props.theme.fontColor : props.theme.disabledFontColor;
|
|
116
92
|
}, function (props) {
|
|
117
93
|
return props.disabled ? "pointer-events: none;" : "";
|
|
94
|
+
}, function (props) {
|
|
95
|
+
return !props.inheritColor && !props.disabled ? props.theme.visitedFontColor : "";
|
|
96
|
+
}, function (props) {
|
|
97
|
+
return "color: ".concat(props.theme.visitedFontColor, ";\n border-bottom-color: ").concat(props.theme.visitedUnderlineColor, ";");
|
|
118
98
|
}, function (props) {
|
|
119
99
|
return "color: ".concat(props.theme.hoverFontColor, ";\n border-bottom-color: ").concat(props.theme.hoverUnderlineColor, ";\n cursor: pointer;");
|
|
120
100
|
}, function (props) {
|
|
@@ -124,30 +104,12 @@ var StyledButton = _styledComponents["default"].button(_templateObject3 || (_tem
|
|
|
124
104
|
}, function (props) {
|
|
125
105
|
return "color: ".concat(props.theme.activeFontColor, " !important;\n border-bottom-color: ").concat(props.theme.activeUnderlineColor, " !important;");
|
|
126
106
|
});
|
|
127
|
-
|
|
128
|
-
var
|
|
129
|
-
return props.theme.fontSize;
|
|
130
|
-
}, function (props) {
|
|
131
|
-
return props.theme.fontWeight;
|
|
132
|
-
}, function (props) {
|
|
133
|
-
return props.theme.fontStyle;
|
|
134
|
-
}, function (props) {
|
|
135
|
-
return props.theme.fontFamily;
|
|
136
|
-
}, function (props) {
|
|
137
|
-
return props.iconPosition === "after" ? "row" : "row-reverse";
|
|
138
|
-
}, function (props) {
|
|
139
|
-
return props.iconPosition === "after" ? "flex-start" : "flex-end";
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
var LinkIcon = _styledComponents["default"].img(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])([""])));
|
|
143
|
-
|
|
144
|
-
var LinkIconContainer = _styledComponents["default"].div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n height: ", ";\n ", ";\n overflow: hidden;\n\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
|
|
107
|
+
var LinkIcon = _styledComponents["default"].img(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])([""])));
|
|
108
|
+
var LinkIconContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n height: ", ";\n ", ";\n overflow: hidden;\n align-self: center;\n\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
|
|
145
109
|
return props.theme.iconSize;
|
|
146
110
|
}, function (props) {
|
|
147
111
|
return props.theme.iconSize;
|
|
148
112
|
}, function (props) {
|
|
149
113
|
return "".concat(props.iconPosition === "before" ? "margin-right" : "margin-left", ": ").concat(props.theme.iconSpacing);
|
|
150
114
|
});
|
|
151
|
-
|
|
152
|
-
var _default = DxcLink;
|
|
153
|
-
exports["default"] = _default;
|
|
115
|
+
var _default = exports["default"] = DxcLink;
|
package/link/Link.stories.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
import DxcLink from "./Link";
|
|
3
3
|
import Title from "../../.storybook/components/Title";
|
|
4
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
|
+
import { HalstackProvider } from "../HalstackContext";
|
|
5
6
|
|
|
6
7
|
export default {
|
|
7
8
|
title: "Link",
|
|
@@ -9,7 +10,7 @@ export default {
|
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
const icon = (
|
|
12
|
-
<svg viewBox="0 0 24 24"
|
|
13
|
+
<svg viewBox="0 0 24 24" enableBackground="new 0 0 24 24" fill="currentColor">
|
|
13
14
|
<g id="Bounding_Box">
|
|
14
15
|
<rect fill="none" width="24" height="24" />
|
|
15
16
|
</g>
|
|
@@ -19,133 +20,234 @@ const icon = (
|
|
|
19
20
|
</svg>
|
|
20
21
|
);
|
|
21
22
|
|
|
23
|
+
const opinionatedTheme = {
|
|
24
|
+
link: {
|
|
25
|
+
baseColor: "#5f249f",
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
22
29
|
export const Chromatic = () => (
|
|
23
30
|
<>
|
|
24
31
|
<Title title="With anchor" theme="light" level={2} />
|
|
25
32
|
<ExampleContainer>
|
|
26
33
|
<Title title="Disabled" theme="light" level={4} />
|
|
27
|
-
<DxcLink
|
|
34
|
+
<DxcLink disabled>Test</DxcLink>
|
|
28
35
|
<Title title="Icon before" theme="light" level={4} />
|
|
29
|
-
<DxcLink
|
|
36
|
+
<DxcLink href="https://www.google.com" icon={icon} iconPosition="before">
|
|
37
|
+
Test
|
|
38
|
+
</DxcLink>
|
|
30
39
|
<Title title="Icon after" theme="light" level={4} />
|
|
31
40
|
<DxcLink
|
|
32
|
-
text="Test"
|
|
33
41
|
href="https://www.youtube.com/"
|
|
34
42
|
icon="https://iconape.com/wp-content/files/yd/367773/svg/logo-linkedin-logo-icon-png-svg.png"
|
|
35
43
|
iconPosition="after"
|
|
36
|
-
|
|
44
|
+
>
|
|
45
|
+
Test
|
|
46
|
+
</DxcLink>
|
|
37
47
|
</ExampleContainer>
|
|
38
48
|
<ExampleContainer pseudoState="pseudo-hover">
|
|
39
49
|
<Title title="With link hovered" theme="light" level={4} />
|
|
40
|
-
<DxcLink
|
|
50
|
+
<DxcLink href="https://www.dxc.com">Test</DxcLink>
|
|
41
51
|
</ExampleContainer>
|
|
42
52
|
<ExampleContainer pseudoState="pseudo-focus">
|
|
43
53
|
<Title title="With link focused" theme="light" level={4} />
|
|
44
|
-
<DxcLink
|
|
54
|
+
<DxcLink href="https://www.dxc.com">Test</DxcLink>
|
|
45
55
|
</ExampleContainer>
|
|
46
56
|
<ExampleContainer pseudoState="pseudo-active">
|
|
47
57
|
<Title title="With link active" theme="light" level={4} />
|
|
48
|
-
<DxcLink
|
|
58
|
+
<DxcLink href="https://www.dxc.com">Test</DxcLink>
|
|
49
59
|
</ExampleContainer>
|
|
50
60
|
<ExampleContainer pseudoState="pseudo-visited">
|
|
51
61
|
<Title title="With link visited" theme="light" level={4} />
|
|
52
|
-
<DxcLink
|
|
62
|
+
<DxcLink href="https://www.amazon.com">Test</DxcLink>
|
|
53
63
|
</ExampleContainer>
|
|
54
64
|
<ExampleContainer>
|
|
55
65
|
<Title title="Inherit color" theme="light" level={4} />
|
|
56
|
-
This is a <DxcLink
|
|
66
|
+
This is a <DxcLink inheritColor>Test</DxcLink>.
|
|
57
67
|
</ExampleContainer>
|
|
58
68
|
<ExampleContainer pseudoState="pseudo-focus">
|
|
59
69
|
<Title title="With brackets and focus" theme="light" level={4} />
|
|
60
|
-
This is a (
|
|
70
|
+
This is a (
|
|
71
|
+
<DxcLink inheritColor href="https://www.google.com">
|
|
72
|
+
Test
|
|
73
|
+
</DxcLink>
|
|
74
|
+
).
|
|
61
75
|
</ExampleContainer>
|
|
62
76
|
<ExampleContainer pseudoState="pseudo-hover">
|
|
63
77
|
<Title title="Long text with hover" theme="light" level={4} />
|
|
64
|
-
Lorem
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
78
|
+
Lorem{" "}
|
|
79
|
+
<DxcLink href="https://www.google.com" icon={icon}>
|
|
80
|
+
Test
|
|
81
|
+
</DxcLink>{" "}
|
|
82
|
+
ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
|
83
|
+
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
84
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
|
|
85
|
+
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit{" "}
|
|
86
|
+
<DxcLink href="https://www.google.com" icon={icon} iconPosition="after">
|
|
87
|
+
Test
|
|
88
|
+
</DxcLink>{" "}
|
|
89
|
+
anim id est laborum.
|
|
69
90
|
</ExampleContainer>
|
|
70
91
|
<ExampleContainer pseudoState="pseudo-focus">
|
|
71
92
|
<Title title="Long text with focus" theme="light" level={4} />
|
|
72
|
-
Lorem <DxcLink
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
93
|
+
Lorem <DxcLink href="https://www.google.com">Test</DxcLink> ipsum dolor sit amet, consectetur adipiscing elit, sed
|
|
94
|
+
do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation
|
|
95
|
+
ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit
|
|
96
|
+
esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
|
|
97
|
+
officia deserunt mollit anim id est laborum.
|
|
77
98
|
</ExampleContainer>
|
|
78
99
|
<Title title="With button" theme="light" level={2} />
|
|
79
100
|
<ExampleContainer>
|
|
80
101
|
<Title title="Disabled" theme="light" level={4} />
|
|
81
|
-
<DxcLink
|
|
102
|
+
<DxcLink onClick={() => {}} disabled>
|
|
103
|
+
Test
|
|
104
|
+
</DxcLink>
|
|
82
105
|
<Title title="Icon before" theme="light" level={4} />
|
|
83
|
-
<DxcLink
|
|
106
|
+
<DxcLink onClick={() => {}} icon={icon} iconPosition="before">
|
|
107
|
+
Test
|
|
108
|
+
</DxcLink>
|
|
84
109
|
<Title title="Icon after" theme="light" level={4} />
|
|
85
|
-
<DxcLink
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
href="https://www.youtube.com/"
|
|
89
|
-
icon={icon}
|
|
90
|
-
iconPosition="after"
|
|
91
|
-
></DxcLink>
|
|
110
|
+
<DxcLink onClick={() => {}} icon={icon} iconPosition="after">
|
|
111
|
+
Test
|
|
112
|
+
</DxcLink>
|
|
92
113
|
</ExampleContainer>
|
|
93
114
|
<ExampleContainer pseudoState="pseudo-hover">
|
|
94
115
|
<Title title="With link hovered" theme="light" level={4} />
|
|
95
|
-
<DxcLink
|
|
116
|
+
<DxcLink onClick={() => {}}>Test</DxcLink>
|
|
96
117
|
</ExampleContainer>
|
|
97
118
|
<ExampleContainer pseudoState="pseudo-focus">
|
|
98
119
|
<Title title="With link focused" theme="light" level={4} />
|
|
99
|
-
<DxcLink
|
|
120
|
+
<DxcLink onClick={() => {}}>Test</DxcLink>
|
|
100
121
|
</ExampleContainer>
|
|
101
122
|
<ExampleContainer pseudoState="pseudo-active">
|
|
102
123
|
<Title title="With link active" theme="light" level={4} />
|
|
103
|
-
<DxcLink
|
|
124
|
+
<DxcLink onClick={() => {}}>Test</DxcLink>
|
|
104
125
|
</ExampleContainer>
|
|
105
126
|
<ExampleContainer pseudoState="pseudo-visited">
|
|
106
127
|
<Title title="With link visited" theme="light" level={4} />
|
|
107
|
-
<DxcLink
|
|
128
|
+
<DxcLink onClick={() => {}}>Test</DxcLink>
|
|
108
129
|
</ExampleContainer>
|
|
109
130
|
<ExampleContainer>
|
|
110
131
|
<Title title="Inherit color" theme="light" level={4} />
|
|
111
|
-
This is a
|
|
132
|
+
This is a{" "}
|
|
133
|
+
<DxcLink onClick={() => {}} inheritColor>
|
|
134
|
+
Test
|
|
135
|
+
</DxcLink>
|
|
136
|
+
.
|
|
112
137
|
</ExampleContainer>
|
|
113
138
|
<ExampleContainer pseudoState="pseudo-focus">
|
|
114
139
|
<Title title="With brackets and focus" theme="light" level={4} />
|
|
115
|
-
This is a (
|
|
140
|
+
This is a (
|
|
141
|
+
<DxcLink onClick={() => {}} inheritColor>
|
|
142
|
+
Test
|
|
143
|
+
</DxcLink>
|
|
144
|
+
).
|
|
116
145
|
</ExampleContainer>
|
|
117
146
|
<ExampleContainer pseudoState="pseudo-hover">
|
|
118
147
|
<Title title="Long text with hover" theme="light" level={4} />
|
|
119
|
-
Lorem
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
148
|
+
Lorem{" "}
|
|
149
|
+
<DxcLink onClick={() => {}} href="https://www.google.com">
|
|
150
|
+
Test
|
|
151
|
+
</DxcLink>{" "}
|
|
152
|
+
ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
|
153
|
+
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
154
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
|
|
155
|
+
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
|
124
156
|
</ExampleContainer>
|
|
125
157
|
<ExampleContainer pseudoState="pseudo-focus">
|
|
126
158
|
<Title title="Long text with focus" theme="light" level={4} />
|
|
127
|
-
Lorem
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
159
|
+
Lorem{" "}
|
|
160
|
+
<DxcLink onClick={() => {}} href="https://www.google.com">
|
|
161
|
+
Test
|
|
162
|
+
</DxcLink>{" "}
|
|
163
|
+
ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
|
164
|
+
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
165
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
|
|
166
|
+
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
|
132
167
|
</ExampleContainer>
|
|
133
168
|
<Title title="Margins" theme="light" level={2} />
|
|
134
169
|
<ExampleContainer>
|
|
135
170
|
<Title title="Xxsmall margin" theme="light" level={4} />
|
|
136
|
-
<DxcLink
|
|
171
|
+
<DxcLink margin="xxsmall" href="https://www.facebook.com/">
|
|
172
|
+
Test
|
|
173
|
+
</DxcLink>
|
|
137
174
|
<Title title="Xsmall margin" theme="light" level={4} />
|
|
138
|
-
<DxcLink
|
|
175
|
+
<DxcLink margin="xsmall" href="https://www.linkedin.com/">
|
|
176
|
+
Test
|
|
177
|
+
</DxcLink>
|
|
139
178
|
<Title title="Small margin" theme="light" level={4} />
|
|
140
|
-
<DxcLink
|
|
179
|
+
<DxcLink margin="small" href="https://www.linkedin.com/">
|
|
180
|
+
Test
|
|
181
|
+
</DxcLink>
|
|
141
182
|
<Title title="Medium margin" theme="light" level={4} />
|
|
142
|
-
<DxcLink
|
|
183
|
+
<DxcLink margin="medium" href="https://www.linkedin.com/">
|
|
184
|
+
Test
|
|
185
|
+
</DxcLink>
|
|
143
186
|
<Title title="Large margin" theme="light" level={4} />
|
|
144
|
-
<DxcLink
|
|
187
|
+
<DxcLink margin="large" href="https://www.linkedin.com/">
|
|
188
|
+
Test
|
|
189
|
+
</DxcLink>
|
|
145
190
|
<Title title="Xlarge margin" theme="light" level={4} />
|
|
146
|
-
<DxcLink
|
|
191
|
+
<DxcLink margin="xlarge" href="https://www.linkedin.com/">
|
|
192
|
+
Test
|
|
193
|
+
</DxcLink>
|
|
147
194
|
<Title title="Xxlarge margin" theme="light" level={4} />
|
|
148
|
-
<DxcLink
|
|
195
|
+
<DxcLink margin="xxlarge" href="https://www.linkedin.com/">
|
|
196
|
+
Test
|
|
197
|
+
</DxcLink>
|
|
198
|
+
</ExampleContainer>
|
|
199
|
+
<Title title="Opinionated theme" theme="light" level={2} />
|
|
200
|
+
<ExampleContainer>
|
|
201
|
+
<Title title="Disabled" theme="light" level={4} />
|
|
202
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
203
|
+
<DxcLink disabled>Test</DxcLink>
|
|
204
|
+
</HalstackProvider>
|
|
205
|
+
</ExampleContainer>
|
|
206
|
+
<ExampleContainer>
|
|
207
|
+
<Title title="Icon before" theme="light" level={4} />
|
|
208
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
209
|
+
<DxcLink href="https://www.google.com" icon={icon} iconPosition="before">
|
|
210
|
+
Test
|
|
211
|
+
</DxcLink>
|
|
212
|
+
</HalstackProvider>
|
|
213
|
+
</ExampleContainer>
|
|
214
|
+
<ExampleContainer>
|
|
215
|
+
<Title title="Disabled" theme="light" level={4} />
|
|
216
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
217
|
+
<DxcLink disabled>Test</DxcLink>
|
|
218
|
+
</HalstackProvider>
|
|
219
|
+
</ExampleContainer>
|
|
220
|
+
<ExampleContainer>
|
|
221
|
+
<Title title="Icon after" theme="light" level={4} />{" "}
|
|
222
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
223
|
+
<DxcLink onClick={() => {}} icon={icon} iconPosition="after">
|
|
224
|
+
Test
|
|
225
|
+
</DxcLink>
|
|
226
|
+
</HalstackProvider>
|
|
227
|
+
</ExampleContainer>
|
|
228
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
229
|
+
<Title title="With link hovered" theme="light" level={4} />
|
|
230
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
231
|
+
<DxcLink onClick={() => {}}>Test</DxcLink>
|
|
232
|
+
</HalstackProvider>
|
|
233
|
+
</ExampleContainer>
|
|
234
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
235
|
+
<Title title="With link focused" theme="light" level={4} />
|
|
236
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
237
|
+
<DxcLink onClick={() => {}}>Test</DxcLink>
|
|
238
|
+
</HalstackProvider>
|
|
239
|
+
</ExampleContainer>
|
|
240
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
241
|
+
<Title title="With link active" theme="light" level={4} />
|
|
242
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
243
|
+
<DxcLink onClick={() => {}}>Test</DxcLink>
|
|
244
|
+
</HalstackProvider>
|
|
245
|
+
</ExampleContainer>
|
|
246
|
+
<ExampleContainer pseudoState="pseudo-visited">
|
|
247
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
248
|
+
<Title title="With link visited" theme="light" level={4} />
|
|
249
|
+
<DxcLink href="https://www.google.com">Test</DxcLink>
|
|
250
|
+
</HalstackProvider>
|
|
149
251
|
</ExampleContainer>
|
|
150
252
|
</>
|
|
151
253
|
);
|
package/link/Link.test.js
CHANGED
|
@@ -1,91 +1,63 @@
|
|
|
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
|
-
var _Link = _interopRequireDefault(require("./Link"));
|
|
10
|
-
|
|
6
|
+
var _Link = _interopRequireDefault(require("./Link.tsx"));
|
|
11
7
|
describe("Link component tests", function () {
|
|
12
8
|
test("Link renders with correct text", function () {
|
|
13
|
-
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Link["default"],
|
|
14
|
-
|
|
15
|
-
})),
|
|
16
|
-
getByText = _render.getByText;
|
|
17
|
-
|
|
9
|
+
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Link["default"], null, "Link")),
|
|
10
|
+
getByText = _render.getByText;
|
|
18
11
|
expect(getByText("Link")).toBeTruthy();
|
|
19
12
|
});
|
|
20
13
|
test("Link renders with correct href", function () {
|
|
21
14
|
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Link["default"], {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
getByRole = _render2.getByRole;
|
|
26
|
-
|
|
15
|
+
href: "/testPage"
|
|
16
|
+
}, "Link")),
|
|
17
|
+
getByRole = _render2.getByRole;
|
|
27
18
|
expect(getByRole("link").getAttribute("href")).toEqual("/testPage");
|
|
28
19
|
});
|
|
29
20
|
test("Link renders with correct disabled state", function () {
|
|
30
21
|
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Link["default"], {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
getByText = _render3.getByText;
|
|
36
|
-
|
|
22
|
+
href: "/testPage",
|
|
23
|
+
disabled: true
|
|
24
|
+
}, "Link")),
|
|
25
|
+
getByText = _render3.getByText;
|
|
37
26
|
expect(getByText("Link").hasAttribute("href")).toBeFalsy();
|
|
38
|
-
|
|
39
27
|
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Link["default"], {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
disabled: true
|
|
45
|
-
})),
|
|
46
|
-
getByTextLinkButton = _render4.getByText;
|
|
47
|
-
|
|
28
|
+
onClick: function onClick() {},
|
|
29
|
+
disabled: true
|
|
30
|
+
}, "LinkButton")),
|
|
31
|
+
getByTextLinkButton = _render4.getByText;
|
|
48
32
|
expect(getByTextLinkButton("LinkButton").hasAttribute("onclick")).toBeFalsy();
|
|
49
33
|
});
|
|
50
34
|
test("Link open new tab", function () {
|
|
51
35
|
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Link["default"], {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
getByRole = _render5.getByRole;
|
|
57
|
-
|
|
36
|
+
href: "/testPage",
|
|
37
|
+
newWindow: true
|
|
38
|
+
}, "Link")),
|
|
39
|
+
getByRole = _render5.getByRole;
|
|
58
40
|
expect(getByRole("link").getAttribute("target")).toEqual("_blank");
|
|
59
41
|
});
|
|
60
42
|
test("Link onClick called", function () {
|
|
61
43
|
var onClick = jest.fn();
|
|
62
|
-
|
|
63
44
|
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Link["default"], {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
getByText = _render6.getByText;
|
|
68
|
-
|
|
45
|
+
onClick: onClick
|
|
46
|
+
}, "Link")),
|
|
47
|
+
getByText = _render6.getByText;
|
|
69
48
|
var link = getByText("Link");
|
|
70
|
-
|
|
71
49
|
_react2.fireEvent.click(link);
|
|
72
|
-
|
|
73
50
|
expect(onClick).toHaveBeenCalled();
|
|
74
51
|
});
|
|
75
52
|
test("Disabled link onClick not called", function () {
|
|
76
53
|
var onClick = jest.fn();
|
|
77
|
-
|
|
78
54
|
var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Link["default"], {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
getByText = _render7.getByText;
|
|
84
|
-
|
|
55
|
+
onClick: onClick,
|
|
56
|
+
disabled: true
|
|
57
|
+
}, "Link")),
|
|
58
|
+
getByText = _render7.getByText;
|
|
85
59
|
var link = getByText("Link");
|
|
86
|
-
|
|
87
60
|
_react2.fireEvent.click(link);
|
|
88
|
-
|
|
89
61
|
expect(onClick).toHaveBeenCalledTimes(0);
|
|
90
62
|
});
|
|
91
63
|
});
|