@atlaskit/button 16.1.2 → 16.1.6

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.
@@ -13,6 +13,8 @@ var _react = _interopRequireDefault(require("react"));
13
13
 
14
14
  var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
15
15
 
16
+ var _excluded = ["spacing"];
17
+
16
18
  function getSpinnerAppearance(_ref) {
17
19
  var appearance = _ref.appearance,
18
20
  isDisabled = _ref.isDisabled,
@@ -36,7 +38,7 @@ function getSpinnerAppearance(_ref) {
36
38
  function LoadingSpinner(_ref2) {
37
39
  var _ref2$spacing = _ref2.spacing,
38
40
  spacing = _ref2$spacing === void 0 ? 'default' : _ref2$spacing,
39
- rest = (0, _objectWithoutProperties2.default)(_ref2, ["spacing"]);
41
+ rest = (0, _objectWithoutProperties2.default)(_ref2, _excluded);
40
42
  var size = spacing === 'default' ? 'medium' : 'small';
41
43
  return /*#__PURE__*/_react.default.createElement(_spinner.default, {
42
44
  size: size,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/button",
3
- "version": "16.1.2",
3
+ "version": "16.1.6",
4
4
  "sideEffects": false
5
5
  }
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useCallback, useMemo, useState } from 'react';
3
- import GlobalTheme from '@atlaskit/theme/components';
3
+ import { useGlobalTheme } from '@atlaskit/theme/components';
4
4
  import ButtonBase from './shared/button-base';
5
5
  import { getCss } from './shared/css';
6
6
  import getIsOnlySingleIcon from './shared/get-is-only-single-icon';
@@ -8,12 +8,14 @@ import getIsOnlySingleIcon from './shared/get-is-only-single-icon';
8
8
  function noop() {}
9
9
 
10
10
  const isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
11
- const ButtonWithMode = /*#__PURE__*/React.forwardRef(function ButtonWithMode({
12
- mode,
11
+ const Button = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function Button({
13
12
  onMouseDown: providedOnMouseDown = noop,
14
13
  onMouseUp: providedOnMouseUp = noop,
15
14
  ...rest
16
15
  }, ref) {
16
+ const {
17
+ mode
18
+ } = useGlobalTheme();
17
19
  const appearance = rest.appearance || 'default';
18
20
  const spacing = rest.spacing || 'default';
19
21
  const shouldFitContainer = Boolean(rest.shouldFitContainer);
@@ -53,16 +55,6 @@ const ButtonWithMode = /*#__PURE__*/React.forwardRef(function ButtonWithMode({
53
55
  onMouseDown: onMouseDown,
54
56
  onMouseUp: onMouseUp
55
57
  }));
56
- });
57
- const Button = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function Button(props, ref) {
58
- return /*#__PURE__*/React.createElement(GlobalTheme.Consumer, null, ({
59
- mode
60
- }) => {
61
- return /*#__PURE__*/React.createElement(ButtonWithMode, _extends({}, props, {
62
- ref: ref,
63
- mode: mode
64
- }));
65
- });
66
58
  })); // Tools including enzyme rely on components having a display name
67
59
 
68
60
  Button.displayName = 'Button';
@@ -5,6 +5,7 @@ import React, { useCallback, useEffect, useRef } from 'react';
5
5
  import { jsx } from '@emotion/core';
6
6
  import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
7
7
  import useAutoFocus from '@atlaskit/ds-lib/use-auto-focus';
8
+ import { N500 } from '@atlaskit/theme/colors';
8
9
  import blockEvents from './block-events';
9
10
  import { getContentStyle, getFadingCss, getIconStyle, overlayCss } from './css';
10
11
 
@@ -69,7 +70,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
69
70
  action: 'clicked',
70
71
  componentName: 'button',
71
72
  packageName: "@atlaskit/button",
72
- packageVersion: "16.1.2",
73
+ packageVersion: "16.1.6",
73
74
  analyticsData: analyticsContext
74
75
  }); // Button currently calls preventDefault, which is not standard button behaviour
75
76
 
@@ -91,6 +92,21 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
91
92
  hasOverlay
92
93
  });
93
94
  const isInteractive = !isDisabled && !hasOverlay;
95
+ /** HACK: Spinner needs to have different colours in the "new" tokens design compared to the old design.
96
+ * For now, while we support both, these styles reach into Spinner when a theme is set, applies the right color.
97
+ * Ticket to remove: https://product-fabric.atlassian.net/browse/DSP-2067
98
+ */
99
+
100
+ var spinnerHackCss = {};
101
+
102
+ if (isSelected || isDisabled || appearance === 'warning') {
103
+ spinnerHackCss = {
104
+ '[data-theme] & svg': {
105
+ stroke: isSelected || isDisabled ? `var(--ds-text-subtle, ${N500})` : `var(--ds-text-warning-inverse, ${N500})`
106
+ }
107
+ };
108
+ }
109
+
94
110
  return jsx(Component, _extends({}, rest, {
95
111
  css: [buttonCss, isInteractive ? null : noPointerEventsOnChildrenCss],
96
112
  className: className,
@@ -122,6 +138,6 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
122
138
  spacing
123
139
  })]
124
140
  }, iconAfter) : null, overlay ? jsx("span", {
125
- css: overlayCss
141
+ css: [overlayCss, spinnerHackCss]
126
142
  }, overlay) : null);
127
143
  });