carbon-react 114.14.0 → 114.14.1
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/esm/components/link/link.component.js +7 -2
- package/esm/components/link/link.style.d.ts +1 -0
- package/esm/components/link/link.style.js +3 -4
- package/lib/components/link/link.component.js +7 -1
- package/lib/components/link/link.style.d.ts +1 -0
- package/lib/components/link/link.style.js +3 -4
- package/package.json +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
|
-
import React, { useMemo } from "react";
|
|
3
|
+
import React, { useContext, useMemo } from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
import Icon from "../icon";
|
|
6
|
+
import MenuContext from "../menu/menu.context";
|
|
6
7
|
import Event from "../../__internal__/utils/helpers/events";
|
|
7
8
|
import { StyledLink, StyledContent } from "./link.style";
|
|
8
9
|
import tagComponent from "../../__internal__/utils/helpers/tags/tags";
|
|
@@ -29,6 +30,9 @@ const Link = /*#__PURE__*/React.forwardRef(({
|
|
|
29
30
|
...rest
|
|
30
31
|
}, ref) => {
|
|
31
32
|
const l = useLocale();
|
|
33
|
+
const {
|
|
34
|
+
inMenu
|
|
35
|
+
} = useContext(MenuContext);
|
|
32
36
|
|
|
33
37
|
const handleOnKeyDown = ev => {
|
|
34
38
|
if (onKeyDown) {
|
|
@@ -99,7 +103,8 @@ const Link = /*#__PURE__*/React.forwardRef(({
|
|
|
99
103
|
iconAlign: iconAlign,
|
|
100
104
|
hasContent: Boolean(children),
|
|
101
105
|
variant: variant,
|
|
102
|
-
isDarkBackground: isDarkBackground
|
|
106
|
+
isDarkBackground: isDarkBackground,
|
|
107
|
+
isMenuItem: inMenu
|
|
103
108
|
}, tagComponent("link", rest), isSkipLink && {
|
|
104
109
|
"data-element": "skip-link"
|
|
105
110
|
}), createLinkBasedOnType());
|
|
@@ -13,6 +13,7 @@ export interface StyledLinkProps {
|
|
|
13
13
|
}
|
|
14
14
|
interface PrivateStyledLinkProps {
|
|
15
15
|
hasContent: boolean;
|
|
16
|
+
isMenuItem?: boolean;
|
|
16
17
|
}
|
|
17
18
|
declare const StyledLink: import("styled-components").StyledComponent<"span", any, StyledLinkProps & PrivateStyledLinkProps, never>;
|
|
18
19
|
declare const StyledContent: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
@@ -45,7 +45,8 @@ const StyledLink = styled.span`
|
|
|
45
45
|
hasContent,
|
|
46
46
|
disabled,
|
|
47
47
|
variant,
|
|
48
|
-
isDarkBackground
|
|
48
|
+
isDarkBackground,
|
|
49
|
+
isMenuItem
|
|
49
50
|
}) => {
|
|
50
51
|
const colorMapKey = isDarkBackground ? "dark" : "light";
|
|
51
52
|
const {
|
|
@@ -54,8 +55,6 @@ const StyledLink = styled.span`
|
|
|
54
55
|
disabledColor
|
|
55
56
|
} = colorMap[colorMapKey](variant);
|
|
56
57
|
return css`
|
|
57
|
-
display: inline-block;
|
|
58
|
-
|
|
59
58
|
${isSkipLink && css`
|
|
60
59
|
a {
|
|
61
60
|
position: absolute;
|
|
@@ -126,7 +125,7 @@ const StyledLink = styled.span`
|
|
|
126
125
|
a,
|
|
127
126
|
button {
|
|
128
127
|
text-decoration: underline;
|
|
129
|
-
display: inline-block;
|
|
128
|
+
${isMenuItem && "display: inline-block;"}
|
|
130
129
|
|
|
131
130
|
${StyledIcon} {
|
|
132
131
|
display: inline-block;
|
|
@@ -11,6 +11,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
11
11
|
|
|
12
12
|
var _icon = _interopRequireDefault(require("../icon"));
|
|
13
13
|
|
|
14
|
+
var _menu = _interopRequireDefault(require("../menu/menu.context"));
|
|
15
|
+
|
|
14
16
|
var _events = _interopRequireDefault(require("../../__internal__/utils/helpers/events"));
|
|
15
17
|
|
|
16
18
|
var _link = require("./link.style");
|
|
@@ -49,6 +51,9 @@ const Link = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
49
51
|
...rest
|
|
50
52
|
}, ref) => {
|
|
51
53
|
const l = (0, _useLocale.default)();
|
|
54
|
+
const {
|
|
55
|
+
inMenu
|
|
56
|
+
} = (0, _react.useContext)(_menu.default);
|
|
52
57
|
|
|
53
58
|
const handleOnKeyDown = ev => {
|
|
54
59
|
if (onKeyDown) {
|
|
@@ -119,7 +124,8 @@ const Link = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
119
124
|
iconAlign: iconAlign,
|
|
120
125
|
hasContent: Boolean(children),
|
|
121
126
|
variant: variant,
|
|
122
|
-
isDarkBackground: isDarkBackground
|
|
127
|
+
isDarkBackground: isDarkBackground,
|
|
128
|
+
isMenuItem: inMenu
|
|
123
129
|
}, (0, _tags.default)("link", rest), isSkipLink && {
|
|
124
130
|
"data-element": "skip-link"
|
|
125
131
|
}), createLinkBasedOnType());
|
|
@@ -13,6 +13,7 @@ export interface StyledLinkProps {
|
|
|
13
13
|
}
|
|
14
14
|
interface PrivateStyledLinkProps {
|
|
15
15
|
hasContent: boolean;
|
|
16
|
+
isMenuItem?: boolean;
|
|
16
17
|
}
|
|
17
18
|
declare const StyledLink: import("styled-components").StyledComponent<"span", any, StyledLinkProps & PrivateStyledLinkProps, never>;
|
|
18
19
|
declare const StyledContent: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
@@ -61,7 +61,8 @@ const StyledLink = _styledComponents.default.span`
|
|
|
61
61
|
hasContent,
|
|
62
62
|
disabled,
|
|
63
63
|
variant,
|
|
64
|
-
isDarkBackground
|
|
64
|
+
isDarkBackground,
|
|
65
|
+
isMenuItem
|
|
65
66
|
}) => {
|
|
66
67
|
const colorMapKey = isDarkBackground ? "dark" : "light";
|
|
67
68
|
const {
|
|
@@ -70,8 +71,6 @@ const StyledLink = _styledComponents.default.span`
|
|
|
70
71
|
disabledColor
|
|
71
72
|
} = colorMap[colorMapKey](variant);
|
|
72
73
|
return (0, _styledComponents.css)`
|
|
73
|
-
display: inline-block;
|
|
74
|
-
|
|
75
74
|
${isSkipLink && (0, _styledComponents.css)`
|
|
76
75
|
a {
|
|
77
76
|
position: absolute;
|
|
@@ -142,7 +141,7 @@ const StyledLink = _styledComponents.default.span`
|
|
|
142
141
|
a,
|
|
143
142
|
button {
|
|
144
143
|
text-decoration: underline;
|
|
145
|
-
display: inline-block;
|
|
144
|
+
${isMenuItem && "display: inline-block;"}
|
|
146
145
|
|
|
147
146
|
${_icon.default} {
|
|
148
147
|
display: inline-block;
|