carbon-react 102.4.6 → 102.5.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.
@@ -19,140 +19,127 @@ function makeColors(color) {
19
19
  `;
20
20
  }
21
21
 
22
- var _default = ({
23
- colors,
24
- disabled
25
- }, isDisabled, destructive) => ({
22
+ var _default = (isDisabled, destructive) => ({
26
23
  primary: `
27
- background: ${colors.primary};
24
+ background: var(--colorsActionMajor500);
28
25
  border-color: transparent;
29
- color: ${colors.white};
26
+ ${makeColors("var(--colorsActionMajorYang100)")};
30
27
  &:hover {
31
- background: ${colors.secondary};
28
+ background: var(--colorsActionMajor600);
32
29
  }
33
30
 
34
31
  ${isDisabled ? `
35
- background: ${disabled.button};
36
- color: ${disabled.text};
32
+ background: var(--colorsActionDisabled500);
33
+ ${makeColors("var(--colorsYin030)")};
37
34
  &:hover {
38
- background: ${disabled.button};
39
- border-color: ${disabled.button};
40
- color: ${disabled.text};
35
+ background: var(--colorsActionDisabled500);
41
36
  }
42
37
  ` : ""}
43
38
 
44
- ${destructive ? `background: ${colors.error};
45
- border-color: transparent;
46
- color: ${colors.white};
39
+ ${destructive ? `background: var(--colorsSemanticNegative500);
40
+ ${makeColors("var(--colorsSemanticNegativeYang100)")};
47
41
  &:hover {
48
- background: ${colors.destructive.hover};
42
+ background: var(--colorsSemanticNegative600);
49
43
  }
50
44
 
51
45
  ${isDisabled ? `
52
- background: ${disabled.button};
53
- color: ${disabled.text};
46
+ background: var(--colorsActionDisabled500);
47
+ ${makeColors("var(--colorsYin030)")};
54
48
  &:hover {
55
- background: ${disabled.button};
56
- color: ${disabled.text};
49
+ background: var(--colorsActionDisabled500);
57
50
  }
58
51
  ` : ""}` : ""}
59
52
  `,
60
53
  secondary: `
61
54
  background: transparent;
62
- border-color: ${colors.primary};
63
- color: ${colors.primary};
55
+ border-color: var(--colorsActionMajor500);
56
+ ${makeColors("var(--colorsActionMajor500)")};
64
57
  &:hover {
65
- background: ${colors.secondary};
66
- border-color: ${colors.secondary};
67
- ${makeColors(colors.white)}
58
+ background: var(--colorsActionMajor600);
59
+ border-color: var(--colorsActionMajorTransparent);
60
+ ${makeColors("var(--colorsActionMajorYang100)")};
68
61
  }
69
62
 
70
63
  ${destructive ? `
71
- border-color: ${colors.error};
72
- ${makeColors(colors.error)}
73
- &:focus {
74
- ${makeColors(colors.white)}
75
- background: ${colors.destructive.hover};
76
- }
64
+ border-color: var(--colorsSemanticNegative500);
65
+ ${makeColors("var(--colorsSemanticNegative500)")}
77
66
  &:hover {
78
- ${makeColors(colors.white)}
79
- border-color: ${colors.destructive.hover};
80
- background: ${colors.destructive.hover};
67
+ background: var(--colorsSemanticNegative600);
68
+ border-color: var(--colorsSemanticNegativeTransparent);
69
+ ${makeColors("var(--colorsSemanticNegativeYang100)")};
81
70
  }
82
71
  ` : ""}
83
72
 
84
73
  ${isDisabled ? `
85
- border-color: ${disabled.button};
86
- color: ${disabled.text};
74
+ border-color: var(--colorsActionDisabled500);
75
+ ${makeColors("var(--colorsYin030)")};
87
76
  &:hover {
88
- background: transparent
89
- border-color: ${disabled.button};
90
- ${makeColors(disabled.text)}
77
+ background: transparent;
78
+ border-color: var(--colorsActionDisabled500);
79
+ ${makeColors("var(--colorsYin030)")};
91
80
  }
92
81
  ` : ""}
93
82
  `,
94
83
  tertiary: `
95
84
  background: transparent;
96
85
  border-color: transparent;
97
- color: ${colors.primary};
86
+ ${makeColors("var(--colorsActionMajor500)")};
98
87
  &:hover {
99
- ${makeColors(colors.secondary)}
88
+ background: var(--colorsActionMajor600);
89
+ ${makeColors("var(--colorsActionMajorYang100)")};
100
90
  }
101
91
 
102
92
  ${destructive ? `
103
- ${makeColors(colors.error)}
93
+ ${makeColors("var(--colorsSemanticNegative500)")};
104
94
  &:hover {
105
- ${makeColors(colors.destructive.hover)}
95
+ background: var(--colorsSemanticNegative600);
96
+ ${makeColors("var(--colorsSemanticNegativeYang100)")};
106
97
  }
107
98
  ` : ""}
108
99
 
109
100
  ${isDisabled ? `
110
- color: ${disabled.text};
101
+ ${makeColors("var(--colorsYin030)")};
111
102
  &:hover {
112
- ${makeColors(disabled.text)}
103
+ background: var(--colorsActionMajorTransparent);
104
+ ${makeColors("var(--colorsYin030)")};
113
105
  }
114
106
  ` : ""}
115
107
  `,
116
108
  dashed: `
117
109
  background: transparent;
118
- border: 2px solid ${colors.dashedBorder}
119
- border-style: dashed;
120
- color: ${colors.dashedButtonText};
110
+ border: 2px dashed var(--colorsActionMinor500);
111
+ ${makeColors("var(--colorsActionMinor500)")};
121
112
  &:hover {
122
- background-color: ${colors.dashedHoverBackground}
113
+ background-color: var(--colorsActionMinor200);
123
114
  }
124
115
 
125
116
  ${destructive ? `
126
- ${makeColors(colors.error)}
127
- &:hover {
128
- ${makeColors(colors.destructive.hover)}
129
- }
117
+ border-color: var(--colorsSemanticNegative500);
130
118
  ` : ""}
131
119
 
132
120
  ${isDisabled ? `
133
- border-color: ${disabled.button};
134
- color: ${disabled.text};
121
+ border-color: var(--colorsActionDisabled500);
122
+ ${makeColors("var(--colorsYin030)")};
135
123
  &:hover {
136
124
  background-color: transparent;
137
- ${makeColors(disabled.text)}
138
125
  }
139
126
  ` : ""}
140
127
  `,
141
128
  darkBackground: `
142
- background: ${colors.white};
129
+ background: var(--colorsActionMajorYang100);
143
130
  border-color: transparent;
144
- color: ${colors.primary};
131
+ ${makeColors("var(--colorsActionMajor500)")};
145
132
  &:hover {
146
- background: ${colors.secondary};
147
- ${makeColors(colors.white)}
133
+ background: var(--colorsActionMajor600);
134
+ ${makeColors("var(--colorsActionMajorYang100)")}
148
135
  }
149
136
 
150
137
  ${isDisabled ? `
151
- background: ${disabled.button};
152
- color: ${disabled.text};
138
+ background: var(--colorsActionDisabled500);
139
+ ${makeColors("var(--colorsYin030)")};
153
140
  &:hover {
154
- background: ${disabled.button};
155
- ${makeColors(disabled.text)}
141
+ background: var(--colorsActionDisabled500);
142
+ ${makeColors("var(--colorsYin030)")};
156
143
  }
157
144
  ` : ""}
158
145
  `
@@ -7,8 +7,6 @@ exports.default = exports.ButtonWithForwardRef = void 0;
7
7
 
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
 
10
- var _styledComponents = require("styled-components");
11
-
12
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
11
 
14
12
  var _propTypes2 = _interopRequireDefault(require("@styled-system/prop-types"));
@@ -19,8 +17,6 @@ var _button = _interopRequireWildcard(require("./button.style"));
19
17
 
20
18
  var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tags/tags"));
21
19
 
22
- var _base = _interopRequireDefault(require("../../style/themes/base"));
23
-
24
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
21
 
26
22
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -39,16 +35,15 @@ function renderChildren({
39
35
  disabled,
40
36
  buttonType,
41
37
  iconTooltipMessage,
42
- iconTooltipPosition,
43
- theme
38
+ iconTooltipPosition
44
39
  /* eslint-enable */
45
40
 
46
41
  }) {
47
42
  const iconColorMap = {
48
- primary: theme.colors.white,
49
- secondary: theme.colors.primary,
50
- tertiary: theme.colors.primary,
51
- darkBackground: theme.colors.primary
43
+ primary: "var(--colorsActionMajorYang100)",
44
+ secondary: "var(--colorsActionMajor500)",
45
+ tertiary: "var(--colorsActionMajor500)",
46
+ darkBackground: "var(--colorsActionMajor500)"
52
47
  };
53
48
  const iconProps = {
54
49
  "aria-hidden": true,
@@ -74,7 +69,6 @@ const renderStyledButton = buttonProps => {
74
69
  disabled,
75
70
  buttonType,
76
71
  iconType,
77
- theme,
78
72
  href,
79
73
  ref,
80
74
  m = 0,
@@ -136,8 +130,6 @@ const renderStyledButton = buttonProps => {
136
130
  };
137
131
 
138
132
  const Button = props => {
139
- const theme = (0, _react.useContext)(_styledComponents.ThemeContext) || _base.default;
140
-
141
133
  const {
142
134
  size,
143
135
  subtext
@@ -151,8 +143,7 @@ const Button = props => {
151
143
  } = props;
152
144
  const propsWithoutAs = { ...rest,
153
145
  buttonType: buttonType || as,
154
- ref: forwardRef || linkRef,
155
- theme
146
+ ref: forwardRef || linkRef
156
147
  };
157
148
 
158
149
  if (subtext.length > 0 && size !== "large") {
@@ -51,15 +51,6 @@ const StyledButton = _styledComponents.default.button`
51
51
  ${stylingForType}
52
52
  `}
53
53
 
54
- &&& {
55
- ${({
56
- mb,
57
- theme
58
- }) => (mb || mb === 0) && (0, _styledComponents.css)`
59
- margin-bottom: ${mb * theme.spacing}px;
60
- `}
61
- }
62
-
63
54
  ${({
64
55
  fullWidth
65
56
  }) => fullWidth && (0, _styledComponents.css)`
@@ -68,12 +59,11 @@ const StyledButton = _styledComponents.default.button`
68
59
 
69
60
  ${({
70
61
  iconOnly,
71
- iconPosition,
72
- theme
62
+ iconPosition
73
63
  }) => (0, _styledComponents.css)`
74
64
  ${_icon.default} {
75
- margin-left: ${!iconOnly && iconPosition === "after" ? `${theme.spacing}px` : "0px"};
76
- margin-right: ${!iconOnly && iconPosition === "before" ? `${theme.spacing}px` : "0px"};
65
+ margin-left: ${!iconOnly && iconPosition === "after" ? "var(--spacing100)" : "0px"};
66
+ margin-right: ${!iconOnly && iconPosition === "before" ? "var(--spacing100)" : "0px"};
77
67
  margin-bottom: ${iconOnly ? "1px" : "0px"};
78
68
  height: ${additionalIconStyle};
79
69
  svg {
@@ -123,7 +113,6 @@ function stylingForType({
123
113
  iconOnly,
124
114
  disabled,
125
115
  buttonType,
126
- theme,
127
116
  size,
128
117
  destructive
129
118
  }) {
@@ -133,18 +122,18 @@ function stylingForType({
133
122
  font-weight: 600;
134
123
  text-decoration: none;
135
124
  &:focus {
136
- outline: solid 3px ${theme.colors.focus};
125
+ outline: solid 3px var(--colorsSemanticFocus500);
137
126
  }
138
127
 
139
- ${(0, _buttonTypes.default)(theme, disabled, destructive)[buttonType]};
128
+ ${(0, _buttonTypes.default)(disabled, destructive)[buttonType]};
140
129
 
141
130
  ${size === "small" && (0, _styledComponents.css)`
142
- font-size: ${theme.text.size};
131
+ font-size: var(--fontSizes100);
143
132
  min-height: 32px;
144
133
  `}
145
134
 
146
135
  ${size === "medium" && (0, _styledComponents.css)`
147
- font-size: ${theme.text.size};
136
+ font-size: var(--fontSizes100);
148
137
  min-height: 40px;
149
138
  `}
150
139
 
@@ -171,15 +160,27 @@ StyledButton.propTypes = {
171
160
  /** The text the button displays */
172
161
  children: _propTypes.default.node.isRequired,
173
162
 
163
+ /** Apply destructive style to the button */
164
+ destructive: _propTypes.default.bool,
165
+
174
166
  /** Apply disabled state to the button */
175
167
  disabled: _propTypes.default.bool,
176
168
 
169
+ /** Apply fullWidth style to the button */
170
+ fullWidth: _propTypes.default.bool,
171
+
172
+ /** Apply iconOnly to display button with the icon only */
173
+ iconOnly: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.string]),
174
+
177
175
  /** Defines an Icon position within the button */
178
176
  iconPosition: _propTypes.default.oneOf([..._button.BUTTON_ICON_POSITIONS, ""]),
179
177
 
180
178
  /** Defines an Icon type within the button (see Icon for options) */
181
179
  iconType: _propTypes.default.oneOf([..._iconConfig.ICONS, ""]),
182
180
 
181
+ /** If provided, the text inside a button will not wrap */
182
+ noWrap: _propTypes.default.bool,
183
+
183
184
  /** Assigns a size to the button */
184
185
  size: _propTypes.default.oneOf(_button.BUTTON_SIZES),
185
186
 
@@ -77,6 +77,9 @@ const StyledIcon = _styledComponents.default.span`
77
77
  if (disabled) {
78
78
  finalColor = theme.icon.disabled;
79
79
  finalHoverColor = theme.icon.disabled;
80
+ } else if (typeof color === "string" && color.startsWith("var")) {
81
+ finalColor = color;
82
+ finalHoverColor = (0, _polished.shade)(0.2, theme.compatibility[color.replace("var(--", "").replace(")", "")]);
80
83
  } else if (color) {
81
84
  const {
82
85
  color: renderedColor
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "102.4.6",
3
+ "version": "102.5.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {