carbon-react 123.10.2 → 123.11.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.
@@ -6,8 +6,10 @@ export interface BadgeProps {
6
6
  children: React.ReactNode;
7
7
  /** The number rendered in the badge component */
8
8
  counter?: string | number;
9
+ /** Prop to specify the colour of the component */
10
+ color?: string;
9
11
  /** Callback fired when badge is clicked */
10
12
  onClick?: (ev: React.MouseEvent<HTMLElement>) => void;
11
13
  }
12
- export declare const Badge: ({ "aria-label": ariaLabel, children, counter, onClick, }: BadgeProps) => React.JSX.Element;
14
+ export declare const Badge: ({ "aria-label": ariaLabel, children, counter, color, onClick, }: BadgeProps) => React.JSX.Element;
13
15
  export default Badge;
@@ -6,6 +6,7 @@ export const Badge = ({
6
6
  "aria-label": ariaLabel,
7
7
  children,
8
8
  counter = 0,
9
+ color = "--colorsActionMajor500",
9
10
  onClick
10
11
  }) => {
11
12
  const shouldDisplayCounter = counter > 0;
@@ -19,7 +20,8 @@ export const Badge = ({
19
20
  };
20
21
  if (shouldDisplayCounter) {
21
22
  return /*#__PURE__*/React.createElement(StyledBadge, _extends({
22
- "data-component": "badge"
23
+ "data-component": "badge",
24
+ color: color
23
25
  }, props), onClick && /*#__PURE__*/React.createElement(StyledCrossIcon, {
24
26
  "data-element": "badge-cross-icon",
25
27
  type: "cross"
@@ -1,8 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  declare const StyledBadgeWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
3
3
  declare const StyledCounter: import("styled-components").StyledComponent<"div", any, {}, never>;
4
+ interface StyledBadgeProps {
5
+ color: string;
6
+ }
4
7
  declare const StyledBadge: import("styled-components").StyledComponent<"span", any, {
5
8
  as: import("react").ForwardRefExoticComponent<import("../button").ButtonProps & import("react").RefAttributes<HTMLButtonElement>> | undefined;
6
- }, "as">;
9
+ } & StyledBadgeProps, "as">;
7
10
  declare const StyledCrossIcon: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../icon").IconProps & import("react").RefAttributes<HTMLSpanElement>>, any, {}, never>;
8
11
  export { StyledBadge, StyledBadgeWrapper, StyledCrossIcon, StyledCounter };
@@ -2,6 +2,8 @@ import styled, { css } from "styled-components";
2
2
  import StyledIcon from "../icon/icon.style";
3
3
  import Button from "../button";
4
4
  import Icon from "../icon";
5
+ import baseTheme from "../../style/themes/base";
6
+ import { toColor } from "../../style/utils/color";
5
7
  const commonStyles = `
6
8
  overflow: hidden;
7
9
  border-radius: var(--borderRadiusCircle);
@@ -34,15 +36,23 @@ const StyledBadge = styled.span.attrs(({
34
36
  width: 22px;
35
37
  min-height: 22px;
36
38
  border: solid 2px transparent;
37
- border-color: var(--colorsActionMajor500);
38
- color: var(--colorsActionMajor500);
39
+
40
+ ${({
41
+ color,
42
+ theme
43
+ }) => css`
44
+ border-color: ${toColor(theme, color)};
45
+ color: ${toColor(theme, color)};
46
+ `};
39
47
 
40
48
  ::-moz-focus-inner {
41
49
  border: none;
42
50
  }
43
51
 
44
52
  ${({
45
- onClick
53
+ onClick,
54
+ color,
55
+ theme
46
56
  }) => css`
47
57
  ${onClick && `
48
58
  ${commonStyles}
@@ -54,9 +64,12 @@ const StyledBadge = styled.span.attrs(({
54
64
  border: none;
55
65
  }
56
66
 
67
+ border-color: ${toColor(theme, color)};
68
+ color: ${toColor(theme, color)};
69
+
57
70
  &:hover,
58
71
  &:focus {
59
- background: var(--colorsActionMajor500);
72
+ background: ${toColor(theme, color)};
60
73
  border: none;
61
74
  ${StyledCounter} {
62
75
  display: none;
@@ -81,4 +94,7 @@ const StyledCrossIcon = styled(Icon)`
81
94
  margin: 0;
82
95
  display: none;
83
96
  `;
97
+ StyledBadge.defaultProps = {
98
+ theme: baseTheme
99
+ };
84
100
  export { StyledBadge, StyledBadgeWrapper, StyledCrossIcon, StyledCounter };
@@ -10,6 +10,7 @@ const StyledTitleContent = styled.span`
10
10
  display: inline-block;
11
11
  line-height: 20px;
12
12
  margin: 0;
13
+ position: relative;
13
14
 
14
15
  ${({
15
16
  hasCustomLayout,
@@ -109,6 +110,7 @@ const StyledTitleContent = styled.span`
109
110
  ${(warning || info) && css`
110
111
  outline: 1px solid;
111
112
  outline-offset: -1px;
113
+ z-index: 2;
112
114
 
113
115
  ${info && !warning && css`
114
116
  outline-color: var(--colorsSemanticInfo500);
@@ -157,6 +159,7 @@ const StyledTitleContent = styled.span`
157
159
  ${error && css`
158
160
  outline: 2px solid var(--colorsSemanticNegative500);
159
161
  outline-offset: -2px;
162
+ z-index: 2;
160
163
 
161
164
  ${position === "top" && css`
162
165
  border-bottom-color: transparent;
@@ -319,7 +322,7 @@ const tabTitleStyles = css`
319
322
  ${({
320
323
  theme
321
324
  }) => `${!theme.focusRedesignOptOut ? addFocusStyling() : /* istanbul ignore next */oldFocusStyling}`}
322
- z-index: 2;
325
+ z-index: 3;
323
326
 
324
327
  ${isInSidebar && css`
325
328
  outline-offset: -3px;
@@ -6,8 +6,10 @@ export interface BadgeProps {
6
6
  children: React.ReactNode;
7
7
  /** The number rendered in the badge component */
8
8
  counter?: string | number;
9
+ /** Prop to specify the colour of the component */
10
+ color?: string;
9
11
  /** Callback fired when badge is clicked */
10
12
  onClick?: (ev: React.MouseEvent<HTMLElement>) => void;
11
13
  }
12
- export declare const Badge: ({ "aria-label": ariaLabel, children, counter, onClick, }: BadgeProps) => React.JSX.Element;
14
+ export declare const Badge: ({ "aria-label": ariaLabel, children, counter, color, onClick, }: BadgeProps) => React.JSX.Element;
13
15
  export default Badge;
@@ -13,6 +13,7 @@ const Badge = ({
13
13
  "aria-label": ariaLabel,
14
14
  children,
15
15
  counter = 0,
16
+ color = "--colorsActionMajor500",
16
17
  onClick
17
18
  }) => {
18
19
  const shouldDisplayCounter = counter > 0;
@@ -26,7 +27,8 @@ const Badge = ({
26
27
  };
27
28
  if (shouldDisplayCounter) {
28
29
  return /*#__PURE__*/_react.default.createElement(_badge.StyledBadge, _extends({
29
- "data-component": "badge"
30
+ "data-component": "badge",
31
+ color: color
30
32
  }, props), onClick && /*#__PURE__*/_react.default.createElement(_badge.StyledCrossIcon, {
31
33
  "data-element": "badge-cross-icon",
32
34
  type: "cross"
@@ -1,8 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  declare const StyledBadgeWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
3
3
  declare const StyledCounter: import("styled-components").StyledComponent<"div", any, {}, never>;
4
+ interface StyledBadgeProps {
5
+ color: string;
6
+ }
4
7
  declare const StyledBadge: import("styled-components").StyledComponent<"span", any, {
5
8
  as: import("react").ForwardRefExoticComponent<import("../button").ButtonProps & import("react").RefAttributes<HTMLButtonElement>> | undefined;
6
- }, "as">;
9
+ } & StyledBadgeProps, "as">;
7
10
  declare const StyledCrossIcon: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../icon").IconProps & import("react").RefAttributes<HTMLSpanElement>>, any, {}, never>;
8
11
  export { StyledBadge, StyledBadgeWrapper, StyledCrossIcon, StyledCounter };
@@ -8,6 +8,8 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
8
8
  var _icon = _interopRequireDefault(require("../icon/icon.style"));
9
9
  var _button = _interopRequireDefault(require("../button"));
10
10
  var _icon2 = _interopRequireDefault(require("../icon"));
11
+ var _base = _interopRequireDefault(require("../../style/themes/base"));
12
+ var _color = require("../../style/utils/color");
11
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
14
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
15
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof 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; }
@@ -45,15 +47,23 @@ const StyledBadge = _styledComponents.default.span.attrs(({
45
47
  width: 22px;
46
48
  min-height: 22px;
47
49
  border: solid 2px transparent;
48
- border-color: var(--colorsActionMajor500);
49
- color: var(--colorsActionMajor500);
50
+
51
+ ${({
52
+ color,
53
+ theme
54
+ }) => (0, _styledComponents.css)`
55
+ border-color: ${(0, _color.toColor)(theme, color)};
56
+ color: ${(0, _color.toColor)(theme, color)};
57
+ `};
50
58
 
51
59
  ::-moz-focus-inner {
52
60
  border: none;
53
61
  }
54
62
 
55
63
  ${({
56
- onClick
64
+ onClick,
65
+ color,
66
+ theme
57
67
  }) => (0, _styledComponents.css)`
58
68
  ${onClick && `
59
69
  ${commonStyles}
@@ -65,9 +75,12 @@ const StyledBadge = _styledComponents.default.span.attrs(({
65
75
  border: none;
66
76
  }
67
77
 
78
+ border-color: ${(0, _color.toColor)(theme, color)};
79
+ color: ${(0, _color.toColor)(theme, color)};
80
+
68
81
  &:hover,
69
82
  &:focus {
70
- background: var(--colorsActionMajor500);
83
+ background: ${(0, _color.toColor)(theme, color)};
71
84
  border: none;
72
85
  ${StyledCounter} {
73
86
  display: none;
@@ -93,4 +106,7 @@ const StyledCrossIcon = (0, _styledComponents.default)(_icon2.default)`
93
106
  margin: 0;
94
107
  display: none;
95
108
  `;
96
- exports.StyledCrossIcon = StyledCrossIcon;
109
+ exports.StyledCrossIcon = StyledCrossIcon;
110
+ StyledBadge.defaultProps = {
111
+ theme: _base.default
112
+ };
@@ -19,6 +19,7 @@ const StyledTitleContent = _styledComponents.default.span`
19
19
  display: inline-block;
20
20
  line-height: 20px;
21
21
  margin: 0;
22
+ position: relative;
22
23
 
23
24
  ${({
24
25
  hasCustomLayout,
@@ -118,6 +119,7 @@ const StyledTitleContent = _styledComponents.default.span`
118
119
  ${(warning || info) && (0, _styledComponents.css)`
119
120
  outline: 1px solid;
120
121
  outline-offset: -1px;
122
+ z-index: 2;
121
123
 
122
124
  ${info && !warning && (0, _styledComponents.css)`
123
125
  outline-color: var(--colorsSemanticInfo500);
@@ -166,6 +168,7 @@ const StyledTitleContent = _styledComponents.default.span`
166
168
  ${error && (0, _styledComponents.css)`
167
169
  outline: 2px solid var(--colorsSemanticNegative500);
168
170
  outline-offset: -2px;
171
+ z-index: 2;
169
172
 
170
173
  ${position === "top" && (0, _styledComponents.css)`
171
174
  border-bottom-color: transparent;
@@ -329,7 +332,7 @@ const tabTitleStyles = (0, _styledComponents.css)`
329
332
  ${({
330
333
  theme
331
334
  }) => `${!theme.focusRedesignOptOut ? (0, _addFocusStyling.default)() : /* istanbul ignore next */oldFocusStyling}`}
332
- z-index: 2;
335
+ z-index: 3;
333
336
 
334
337
  ${isInSidebar && (0, _styledComponents.css)`
335
338
  outline-offset: -3px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "123.10.2",
3
+ "version": "123.11.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",