carbon-react 110.7.0 → 110.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -56,9 +56,16 @@ const StyledHeadingBackButton = styled(Link)`
56
56
  outline: 3px solid var(--colorsSemanticFocus500);
57
57
  }
58
58
 
59
+ &:hover {
60
+ ${StyledIcon} {
61
+ color: var(--colorsActionMinor600);
62
+ }
63
+ }
64
+
59
65
  ${StyledIcon} {
60
66
  margin-right: 0;
61
67
  display: inline-flex;
68
+ color: var(--colorsActionMinor500);
62
69
  }
63
70
  }
64
71
  `;
@@ -93,17 +100,12 @@ const StyledSubHeader = styled.div`
93
100
  `}
94
101
  `;
95
102
  const StyledHeadingIcon = styled(Icon)`
96
- color: var(--colorsActionMinor500);
97
103
  height: 30px;
98
104
 
99
105
  &:before,
100
106
  &${StyledIcon}:before {
101
107
  font-size: 24px;
102
108
  }
103
-
104
- &:hover {
105
- color: var(--colorsActionMinor600);
106
- }
107
109
  `;
108
110
  const StyledSeparator = styled.hr`
109
111
  border-top: 2px solid var(--colorsUtilityMajor100);
@@ -1,14 +1,11 @@
1
1
  import React from "react";
2
2
  import { IconType } from "components/icon/icon-type";
3
- export interface LinkProps extends React.AriaAttributes {
4
- /** The disabled state of the link. */
5
- disabled?: boolean;
3
+ import { StyledLinkProps } from "./link.style";
4
+ export interface LinkProps extends StyledLinkProps, React.AriaAttributes {
6
5
  /** An href for an anchor tag. */
7
6
  href?: string;
8
7
  /** An icon to display next to the link. */
9
8
  icon?: IconType;
10
- /** Which side of the link to the render the link. */
11
- iconAlign?: "left" | "right";
12
9
  /** Function called when the mouse is clicked. */
13
10
  onClick?: (ev: React.MouseEvent<HTMLAnchorElement> | React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLAnchorElement> | React.KeyboardEvent<HTMLButtonElement>) => void;
14
11
  /** Function called when a key is pressed. */
@@ -27,8 +24,6 @@ export interface LinkProps extends React.AriaAttributes {
27
24
  target?: string;
28
25
  /** Aria label for accessibility purposes */
29
26
  ariaLabel?: string;
30
- /** Allows to create skip link */
31
- isSkipLink?: boolean;
32
27
  /** allows to set rel property in <a> tag */
33
28
  rel?: string;
34
29
  }
@@ -23,6 +23,8 @@ const Link = /*#__PURE__*/React.forwardRef(({
23
23
  tooltipMessage,
24
24
  tooltipPosition,
25
25
  target,
26
+ variant = "default",
27
+ isDarkBackground,
26
28
  ...rest
27
29
  }, ref) => {
28
30
  const l = useLocale();
@@ -48,7 +50,6 @@ const Link = /*#__PURE__*/React.forwardRef(({
48
50
  return hasProperAlignment ? /*#__PURE__*/React.createElement(Icon, {
49
51
  type: icon,
50
52
  bgSize: "extra-small",
51
- color: "--colorsActionMajor500",
52
53
  disabled: disabled,
53
54
  ariaLabel: ariaLabel,
54
55
  tooltipMessage: tooltipMessage,
@@ -91,7 +92,9 @@ const Link = /*#__PURE__*/React.forwardRef(({
91
92
  disabled: disabled,
92
93
  className: className,
93
94
  iconAlign: iconAlign,
94
- hasContent: Boolean(children)
95
+ hasContent: Boolean(children),
96
+ variant: variant,
97
+ isDarkBackground: isDarkBackground
95
98
  }, tagComponent("link", rest), isSkipLink && {
96
99
  "data-element": "skip-link"
97
100
  }), createLinkBasedOnType());
@@ -152,6 +155,7 @@ Link.propTypes = {
152
155
  "href": PropTypes.string,
153
156
  "icon": PropTypes.oneOf(["add", "admin", "alert_on", "alert", "analysis", "arrow_down", "arrow_left_boxed", "arrow_left_right_small", "arrow_left_small", "arrow_left", "arrow_right_small", "arrow_right", "arrow_up", "arrow", "attach", "bank", "basket_with_squares", "basket", "bin", "block_arrow_right", "blocked_square", "blocked", "bold", "boxed_shapes", "bulk_destroy", "bullet_list_dotted", "bullet_list_numbers", "bullet_list", "business", "calendar_today", "calendar", "call", "camera", "card_view", "caret_down", "caret_large_down", "caret_large_left", "caret_large_right", "caret_large_up", "caret_left", "caret_right", "caret_up", "cart", "chart_bar", "chart_line", "chart_pie", "chat_notes", "chat", "chevron_down_thick", "chevron_down", "chevron_left_thick", "chevron_left", "chevron_right_thick", "chevron_right", "chevron_up_thick", "chevron_up", "circle_with_dots", "circles_connection", "clock", "close", "coins", "collaborate", "computer_clock", "connect", "contacts", "copy", "create", "credit_card_slash", "credit_card", "cross_circle", "cross", "csv", "delete", "delivery", "disconnect", "disputed", "document_right_align", "document_tick", "document_vertical_lines", "download", "draft", "drag_vertical", "drag", "dropdown", "duplicate", "edit", "edited", "ellipsis_horizontal", "ellipsis_vertical", "email_switch", "email", "entry", "envelope_dollar", "envelope_euro", "error_square", "error", "euro", "expand", "factory", "favourite_lined", "favourite", "fax", "feedback", "file_excel", "file_generic", "file_image", "file_pdf", "file_word", "files_leaning", "filter_new", "filter", "fit_height", "fit_width", "flag", "folder", "gift", "go", "graph", "grid", "help", "hide", "home", "image", "in_progress", "in_transit", "individual", "info", "italic", "key", "ledger_arrow_left", "ledger_arrow_right", "ledger", "lightbulb_off", "lightbulb_on", "link", "list_view", "location", "locked", "logout", "lookup", "marker", "message", "minus_large", "minus", "mobile", "money_bag", "none", "old_warning", "palm_tree", "pause_circle", "pause", "pdf", "people_switch", "people", "person_info", "person_tick", "person", "phone", "piggy_bank", "play_circle", "play", "plus_large", "plus", "pound", "print", "progress", "progressed", "question_hollow", "question_mark", "question", "refresh_clock", "refresh", "remove", "sage_coin", "save", "scan", "search", "services", "settings_old", "settings", "share", "shop", "sort_down", "sort_up", "spanner", "split_container", "split", "square_dot", "squares_nine", "stacked_boxes", "stacked_squares", "submitted", "sync", "tag", "talk", "three_boxes", "tick_circle", "tick_thick", "tick", "true_tick", "undo", "unlocked", "upload", "uploaded", "video", "view", "warning"]),
154
157
  "iconAlign": PropTypes.oneOf(["left", "right"]),
158
+ "isDarkBackground": PropTypes.bool,
155
159
  "isSkipLink": PropTypes.bool,
156
160
  "onClick": PropTypes.func,
157
161
  "onKeyDown": PropTypes.func,
@@ -159,7 +163,8 @@ Link.propTypes = {
159
163
  "rel": PropTypes.string,
160
164
  "target": PropTypes.string,
161
165
  "tooltipMessage": PropTypes.string,
162
- "tooltipPosition": PropTypes.oneOf(["bottom", "left", "right", "top"])
166
+ "tooltipPosition": PropTypes.oneOf(["bottom", "left", "right", "top"]),
167
+ "variant": PropTypes.oneOf(["default", "negative", "neutral"])
163
168
  };
164
169
  export { Link };
165
170
  Link.displayName = "Link";
@@ -1,2 +1,3 @@
1
1
  export declare const LINK_POSITIONS: string[];
2
2
  export declare const LINK_ALIGNMENTS: string[];
3
+ export declare const LINK_VARIANTS: string[];
@@ -1,2 +1,3 @@
1
1
  export const LINK_POSITIONS = ["bottom", "left", "right", "top"];
2
- export const LINK_ALIGNMENTS = ["left", "right"];
2
+ export const LINK_ALIGNMENTS = ["left", "right"];
3
+ export const LINK_VARIANTS = ["default", "negative", "neutral"];
@@ -1,7 +1,19 @@
1
- import { LinkProps } from "./link.component";
2
- interface StyledLinkProps extends Pick<LinkProps, "isSkipLink" | "iconAlign" | "disabled"> {
1
+ declare type Variants = "default" | "negative" | "neutral";
2
+ export interface StyledLinkProps {
3
+ /** The disabled state of the link. */
4
+ disabled?: boolean;
5
+ /** Which side of the link to the render the link. */
6
+ iconAlign?: "left" | "right";
7
+ /** Allows to create skip link */
8
+ isSkipLink?: boolean;
9
+ /** Sets the colour styling when component is rendered on a dark background */
10
+ isDarkBackground?: boolean;
11
+ /** Allows link styling to be updated for light or dark backgrounds */
12
+ variant?: Variants;
13
+ }
14
+ interface PrivateStyledLinkProps {
3
15
  hasContent: boolean;
4
16
  }
5
- declare const StyledLink: import("styled-components").StyledComponent<"span", any, StyledLinkProps, never>;
17
+ declare const StyledLink: import("styled-components").StyledComponent<"span", any, StyledLinkProps & PrivateStyledLinkProps, never>;
6
18
  declare const StyledContent: import("styled-components").StyledComponent<"span", any, {}, never>;
7
19
  export { StyledLink, StyledContent };
@@ -1,84 +1,174 @@
1
1
  import styled, { css } from "styled-components";
2
2
  import baseTheme from "../../style/themes/base";
3
3
  import StyledIcon from "../icon/icon.style";
4
+ const colorMap = {
5
+ light: variant => {
6
+ let color = "var(--colorsActionMajor500)";
7
+ let hoverColor = "var(--colorsActionMajor600)";
8
+
9
+ if (variant === "negative") {
10
+ color = "var(--colorsSemanticNegative500)";
11
+ hoverColor = "var(--colorsSemanticNegative600)";
12
+ } else if (variant === "neutral") {
13
+ color = "var(--colorsActionMajorYin090)";
14
+ }
15
+
16
+ return {
17
+ color,
18
+ hoverColor,
19
+ disabledColor: "var(--colorsActionMajorYin030)"
20
+ };
21
+ },
22
+ dark: variant => {
23
+ let color = "var(--colorsActionMajor350)";
24
+ let hoverColor = "var(--colorsActionMajor450)";
25
+
26
+ if (variant === "negative") {
27
+ color = "var(--colorsSemanticNegative350)";
28
+ hoverColor = "var(--colorsSemanticNegative450)";
29
+ } else if (variant === "neutral") {
30
+ color = "var(--colorsActionMinor100)";
31
+ }
32
+
33
+ return {
34
+ color,
35
+ hoverColor,
36
+ disabledColor: "var(--colorsActionMajorYang030)"
37
+ };
38
+ }
39
+ };
4
40
  const StyledLink = styled.span`
5
41
  ${({
6
42
  isSkipLink,
7
43
  theme,
8
44
  iconAlign,
9
45
  hasContent,
10
- disabled
11
- }) => css`
12
- display: inline-block;
13
-
14
- ${isSkipLink && css`
15
- a {
16
- position: absolute;
17
- padding-left: 24px;
18
- padding-right: 24px;
19
- line-height: 36px;
20
- left: -999em;
21
- z-index: ${theme.zIndex.aboveAll};
22
- box-shadow: inset 0 0 0 2px var(--colorsActionMajor500);
23
- border: 2px solid var(--colorsUtilityYang100);
24
- }
46
+ disabled,
47
+ variant,
48
+ isDarkBackground
49
+ }) => {
50
+ const colorMapKey = isDarkBackground ? "dark" : "light";
51
+ const {
52
+ color,
53
+ hoverColor,
54
+ disabledColor
55
+ } = colorMap[colorMapKey](variant);
56
+ return css`
57
+ display: inline-block;
25
58
 
26
- a:focus {
27
- top: 8px;
28
- left: 8px;
29
- }
30
- `}
59
+ ${isSkipLink && css`
60
+ a {
61
+ position: absolute;
62
+ padding-left: 24px;
63
+ padding-right: 24px;
64
+ line-height: 36px;
65
+ left: -999em;
66
+ z-index: ${theme.zIndex.aboveAll};
67
+ box-shadow: inset 0 0 0 2px var(--colorsActionMajor500);
68
+ border: 2px solid var(--colorsUtilityYang100);
69
+ font-size: 16px;
70
+ color: var(--colorsUtilityYin090);
31
71
 
32
- a,
33
- button {
34
- font-size: ${isSkipLink ? "16px" : "14px"};
35
- text-decoration: underline;
36
- color: ${isSkipLink ? "var(--colorsUtilityYin090)" : "var(--colorsActionMajor500)"};
37
- display: inline-block;
38
- ${StyledIcon} {
39
- display: inline-block;
40
- position: relative;
41
- vertical-align: middle;
42
- ${iconAlign === "left" && css`
43
- margin-right: ${hasContent ? "var(--spacing100)" : 0};
44
- `}
45
- ${iconAlign === "right" && css`
46
- margin-right: 0;
47
- margin-left: ${hasContent ? "var(--spacing100)" : 0};
48
- `}
49
- }
72
+ &:hover {
73
+ cursor: pointer;
74
+ color: var(--colorsUtilityYin090);
75
+
76
+ ${StyledIcon} {
77
+ color: var(--colorsActionMajor600);
78
+ }
79
+ }
80
+
81
+ &:focus {
82
+ background-color: var(--colorsUtilityYang100);
83
+ }
84
+ }
85
+
86
+ a:focus {
87
+ top: 8px;
88
+ left: 8px;
89
+ }
90
+ `}
50
91
 
51
- &:hover {
52
- cursor: pointer;
53
- color: ${isSkipLink ? "var(--colorsUtilityYin090)" : "var(--colorsActionMajor600)"};
92
+ ${!isSkipLink && css`
93
+ a,
94
+ button {
95
+ font-size: 14px;
96
+
97
+ ${!disabled && css`
98
+ color: ${color};
99
+ ${StyledIcon} {
100
+ color: ${color};
101
+ }
102
+
103
+ &:hover {
104
+ color: ${hoverColor};
105
+
106
+ ${StyledIcon} {
107
+ color: ${hoverColor};
108
+ }
109
+ }
110
+
111
+ &:focus {
112
+ background-color: var(--colorsSemanticFocus250);
113
+ }
114
+ `}
115
+
116
+ ${disabled && css`
117
+ color: ${disabledColor};
118
+ &:hover,
119
+ &:focus {
120
+ color: ${disabledColor};
121
+ }
122
+ `}
123
+ }
124
+ `}
125
+
126
+ a,
127
+ button {
128
+ text-decoration: underline;
129
+ display: inline-block;
54
130
 
55
131
  ${StyledIcon} {
56
- color: var(--colorsActionMajor600);
132
+ display: inline-block;
133
+ position: relative;
134
+ vertical-align: middle;
135
+ ${iconAlign === "left" && css`
136
+ margin-right: ${hasContent ? "var(--spacing100)" : 0};
137
+ `}
138
+ ${iconAlign === "right" && css`
139
+ margin-right: 0;
140
+ margin-left: ${hasContent ? "var(--spacing100)" : 0};
141
+ `}
57
142
  }
58
- }
59
143
 
60
- &:focus {
61
- color: var(--colorsActionMajorYin090);
62
- background-color: ${isSkipLink ? "var(--colorsUtilityYang100)" : "var(--colorsSemanticFocus250)"};
63
- outline: none;
64
- }
144
+ &:hover {
145
+ cursor: pointer;
146
+ }
65
147
 
66
- ${disabled && css`
67
- color: var(--colorsActionMajorYin030);
68
- &:hover,
69
148
  &:focus {
70
- cursor: not-allowed;
71
- color: var(--colorsActionMajorYin030);
149
+ color: var(--colorsActionMajorYin090);
150
+ outline: none;
151
+
152
+ ${StyledIcon} {
153
+ color: var(--colorsActionMajorYin090);
154
+ }
72
155
  }
73
- `}
74
- }
75
156
 
76
- button {
77
- background-color: transparent;
78
- border: none;
79
- padding: 0;
80
- }
81
- `}
157
+ ${disabled && css`
158
+ &:hover,
159
+ &:focus {
160
+ cursor: not-allowed;
161
+ }
162
+ `}
163
+ }
164
+
165
+ button {
166
+ background-color: transparent;
167
+ border: none;
168
+ padding: 0;
169
+ }
170
+ `;
171
+ }}
82
172
  `;
83
173
  StyledLink.defaultProps = {
84
174
  theme: baseTheme,
@@ -37,35 +37,37 @@ const StyledMenuItemWrapper = styled.a`
37
37
  ${!inFullscreenView && css`
38
38
  max-width: inherit;
39
39
 
40
- a,
41
- button {
42
- ${maxWidth && css`
43
- box-sizing: border-box;
44
- max-width: inherit;
45
- text-overflow: ellipsis;
46
- overflow: hidden;
47
- white-space: nowrap;
48
- vertical-align: bottom;
49
- `}
50
- }
51
-
52
- a:focus,
53
- button:focus {
54
- box-shadow: inset 0 0 0 var(--borderWidth300)
55
- var(--colorsSemanticFocus500);
56
- background-color: ${menuConfigVariants[menuType].background};
57
- color: ${menuConfigVariants[menuType].color};
58
- z-index: 1;
59
- position: relative;
60
- }
40
+ && {
41
+ a,
42
+ button {
43
+ ${maxWidth && css`
44
+ box-sizing: border-box;
45
+ max-width: inherit;
46
+ text-overflow: ellipsis;
47
+ overflow: hidden;
48
+ white-space: nowrap;
49
+ vertical-align: bottom;
50
+ `}
51
+ }
61
52
 
62
- a:hover,
63
- button:hover {
64
- background-color: var(--colorsComponentsMenuAutumnStandard600);
65
- color: var(--colorsComponentsMenuYang100);
53
+ a:focus,
54
+ button:focus {
55
+ box-shadow: inset 0 0 0 var(--borderWidth300)
56
+ var(--colorsSemanticFocus500);
57
+ background-color: ${menuConfigVariants[menuType].background};
58
+ color: ${menuConfigVariants[menuType].color};
59
+ z-index: 1;
60
+ position: relative;
61
+ }
66
62
 
67
- [data-component="icon"] {
63
+ a:hover,
64
+ button:hover {
65
+ background-color: var(--colorsComponentsMenuAutumnStandard600);
68
66
  color: var(--colorsComponentsMenuYang100);
67
+
68
+ [data-component="icon"] {
69
+ color: var(--colorsComponentsMenuYang100);
70
+ }
69
71
  }
70
72
  }
71
73
  `}
@@ -85,19 +87,21 @@ const StyledMenuItemWrapper = styled.a`
85
87
  text-align: left;
86
88
  }
87
89
 
88
- a,
89
- button,
90
- [data-component="icon"],
91
- ${StyledLink} a,
92
- ${StyledLink} button,
93
- ${StyledLink} [data-component="icon"] {
94
- font-weight: 700;
95
- text-decoration: none;
96
- color: ${menuConfigVariants[menuType].color};
97
- }
98
-
99
- ${IconStyle} {
100
- bottom: 1px;
90
+ && {
91
+ a,
92
+ button,
93
+ [data-component="icon"],
94
+ ${StyledLink} a,
95
+ ${StyledLink} button,
96
+ ${StyledLink} [data-component="icon"] {
97
+ font-weight: 700;
98
+ text-decoration: none;
99
+ color: ${menuConfigVariants[menuType].color};
100
+ }
101
+
102
+ ${IconStyle} {
103
+ bottom: 1px;
104
+ }
101
105
  }
102
106
 
103
107
  ${selected && css`