@atlaskit/status 1.0.2 → 1.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/status
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`af2dcdc462f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/af2dcdc462f) - [ux] Instrumented `@atlaskit/status` with the new theming package, `@atlaskit/tokens`.
8
+
9
+ New tokens will be visible only in applications configured to use the new Tokens API (currently in alpha).
10
+ These changes are intended to be interoperable with the legacy theme implementation. Legacy dark mode users should expect no visual or breaking changes.
11
+
12
+ ### Patch Changes
13
+
14
+ - [`fb47a6a79ef`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fb47a6a79ef) - ED-14672 Removed styled-component from status, replaced by emotion.
15
+ - Updated dependencies
16
+
3
17
  ## 1.0.2
4
18
 
5
19
  ### Patch Changes
@@ -41,6 +41,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
41
41
 
42
42
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
43
43
 
44
+ /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
44
45
  var colorToLozengeAppearanceMap = {
45
46
  neutral: 'default',
46
47
  purple: 'new',
@@ -49,6 +50,8 @@ var colorToLozengeAppearanceMap = {
49
50
  yellow: 'moved',
50
51
  green: 'success'
51
52
  };
53
+ /* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
54
+
52
55
  var DEFAULT_APPEARANCE = 'default';
53
56
  var MAX_WIDTH = 200;
54
57
 
@@ -33,7 +33,7 @@ var _react = _interopRequireWildcard(require("react"));
33
33
 
34
34
  var _reactIntlNext = require("react-intl-next");
35
35
 
36
- var _styledComponents = _interopRequireDefault(require("styled-components"));
36
+ var _react2 = require("@emotion/react");
37
37
 
38
38
  var _colorPalette = _interopRequireDefault(require("./internal/color-palette"));
39
39
 
@@ -49,7 +49,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
49
49
 
50
50
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
51
51
 
52
- var FieldTextWrapper = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n margin: 0 ", "px;\n"])), (0, _constants.gridSize)());
52
+ var fieldTextWrapperStyles = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n margin: 0 ", "px;\n"])), (0, _constants.gridSize)());
53
53
 
54
54
  var Picker = /*#__PURE__*/function (_PureComponent) {
55
55
  (0, _inherits2.default)(Picker, _PureComponent);
@@ -99,9 +99,10 @@ var Picker = /*#__PURE__*/function (_PureComponent) {
99
99
  intl = _this$props.intl; // Using <React.Fragment> instead of [] to workaround Enzyme
100
100
  // (https://github.com/airbnb/enzyme/issues/1149)
101
101
 
102
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(FieldTextWrapper, {
102
+ return (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)("div", {
103
+ css: fieldTextWrapperStyles,
103
104
  key: this.fieldTextWrapperKey
104
- }, /*#__PURE__*/_react.default.createElement(_textfield.default, {
105
+ }, (0, _react2.jsx)(_textfield.default, {
105
106
  value: text,
106
107
  isCompact: true,
107
108
  ref: this.handleInputRef,
@@ -110,7 +111,7 @@ var Picker = /*#__PURE__*/function (_PureComponent) {
110
111
  spellCheck: false,
111
112
  autoComplete: "off",
112
113
  "aria-label": intl.formatMessage(_i18n.messages.statusInputLabel)
113
- })), /*#__PURE__*/_react.default.createElement(_colorPalette.default, {
114
+ })), (0, _react2.jsx)(_colorPalette.default, {
114
115
  key: this.colorPaletteKey,
115
116
  onClick: onColorClick,
116
117
  onHover: onColorHover,
@@ -17,9 +17,11 @@ var _constants = require("@atlaskit/theme/constants");
17
17
 
18
18
  var colors = _interopRequireWildcard(require("@atlaskit/theme/colors"));
19
19
 
20
+ var _tokens = require("@atlaskit/tokens");
21
+
20
22
  var _react = _interopRequireWildcard(require("react"));
21
23
 
22
- var _styledComponents = _interopRequireDefault(require("styled-components"));
24
+ var _react2 = require("@emotion/react");
23
25
 
24
26
  var _color = _interopRequireDefault(require("./color"));
25
27
 
@@ -30,10 +32,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
30
32
  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; }
31
33
 
32
34
  // color value, label, background, borderColor
33
- var palette = [['neutral', colors.N40, colors.N400], ['purple', colors.P50, colors.P400], ['blue', colors.B50, colors.B400], ['red', colors.R50, colors.R400], ['yellow', colors.Y75, colors.Y400], ['green', colors.G50, colors.G400]];
34
-
35
- var ColorPaletteWrapper = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n margin: ", "px ", "px 0 ", "px;\n /* Firefox bug fix: https://product-fabric.atlassian.net/browse/ED-1789 */\n display: flex;\n flex-wrap: wrap;\n"])), (0, _constants.gridSize)(), (0, _constants.gridSize)(), (0, _constants.gridSize)());
36
-
35
+ var palette = [['neutral', (0, _tokens.token)('color.background.neutral', colors.N40), (0, _tokens.token)('color.text', colors.N400)], ['purple', (0, _tokens.token)('color.background.discovery', colors.P50), (0, _tokens.token)('color.text.discovery', colors.P400)], ['blue', (0, _tokens.token)('color.background.information', colors.B50), (0, _tokens.token)('color.text.information', colors.B400)], ['red', (0, _tokens.token)('color.background.danger', colors.R50), (0, _tokens.token)('color.text.danger', colors.R400)], ['yellow', (0, _tokens.token)('color.background.warning', colors.Y75), (0, _tokens.token)('color.text.warning', colors.Y400)], ['green', (0, _tokens.token)('color.background.success', colors.G50), (0, _tokens.token)('color.text.success', colors.G400)]];
36
+ var colorPaletteWrapperStyles = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n margin: ", "px ", "px 0 ", "px;\n /* Firefox bug fix: https://product-fabric.atlassian.net/browse/ED-1789 */\n display: flex;\n flex-wrap: wrap;\n"])), (0, _constants.gridSize)(), (0, _constants.gridSize)(), (0, _constants.gridSize)());
37
37
  var VK_LEFT = 37; //ArrowLeft
38
38
 
39
39
  var VK_RIGHT = 39; //ArrowRight
@@ -85,33 +85,43 @@ var _default = function _default(_ref) {
85
85
  newRef === null || newRef === void 0 ? void 0 : newRef.focus();
86
86
  onClick(newColorValue);
87
87
  }, [selectedColor, onClick, colorRefs]);
88
- return /*#__PURE__*/_react.default.createElement(ColorPaletteWrapper, {
89
- className: className,
90
- role: "radiogroup",
91
- style: {
92
- maxWidth: cols * 32
93
- },
94
- onKeyDown: memoizedHandleKeyDown
95
- }, palette.map(function (_ref4, i) {
96
- var _ref5 = (0, _slicedToArray2.default)(_ref4, 3),
97
- colorValue = _ref5[0],
98
- backgroundColor = _ref5[1],
99
- borderColor = _ref5[2];
100
-
101
- return /*#__PURE__*/_react.default.createElement(_color.default, {
102
- key: colorValue,
103
- value: colorValue,
104
- backgroundColor: backgroundColor,
105
- borderColor: borderColor,
106
- onClick: onClick,
107
- onHover: onHover,
108
- isSelected: colorValue === selectedColor,
109
- tabIndex: colorValue === selectedColor ? 0 : -1,
110
- setRef: function setRef(el) {
111
- return colorRefs.current[i] = el;
112
- }
113
- });
114
- }));
88
+ return (
89
+ /**
90
+ We need to disable below eslint rule becuase of role "radiogroup". This role was added
91
+ in https://a11y-internal.atlassian.net/browse/AK-832 to fix accessibility issue.
92
+ When we migrated to emotion from styled component, we started getting this error.
93
+ Task added in https://product-fabric.atlassian.net/wiki/spaces/E/pages/3182068181/Potential+improvements#Moderate-changes.
94
+ */
95
+ // eslint-disable-next-line jsx-a11y/interactive-supports-focus
96
+ (0, _react2.jsx)("div", {
97
+ css: colorPaletteWrapperStyles,
98
+ className: className,
99
+ role: "radiogroup",
100
+ style: {
101
+ maxWidth: cols * 32
102
+ },
103
+ onKeyDown: memoizedHandleKeyDown
104
+ }, palette.map(function (_ref4, i) {
105
+ var _ref5 = (0, _slicedToArray2.default)(_ref4, 3),
106
+ colorValue = _ref5[0],
107
+ backgroundColor = _ref5[1],
108
+ borderColor = _ref5[2];
109
+
110
+ return (0, _react2.jsx)(_color.default, {
111
+ key: colorValue,
112
+ value: colorValue,
113
+ backgroundColor: backgroundColor,
114
+ borderColor: borderColor,
115
+ onClick: onClick,
116
+ onHover: onHover,
117
+ isSelected: colorValue === selectedColor,
118
+ tabIndex: colorValue === selectedColor ? 0 : -1,
119
+ setRef: function setRef(el) {
120
+ return colorRefs.current[i] = el;
121
+ }
122
+ });
123
+ }))
124
+ );
115
125
  };
116
126
 
117
127
  exports.default = _default;
@@ -29,11 +29,13 @@ var _done = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/done"));
29
29
 
30
30
  var _colors = require("@atlaskit/theme/colors");
31
31
 
32
+ var _tokens = require("@atlaskit/tokens");
33
+
32
34
  var _react = _interopRequireWildcard(require("react"));
33
35
 
34
36
  var _reactIntlNext = require("react-intl-next");
35
37
 
36
- var _styledComponents = _interopRequireDefault(require("styled-components"));
38
+ var _react2 = require("@emotion/react");
37
39
 
38
40
  var _constants = require("../constants");
39
41
 
@@ -49,9 +51,8 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
49
51
 
50
52
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
51
53
 
52
- var Button = _styledComponents.default.button(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n height: 24px;\n width: 24px;\n background: ", ";\n padding: 0;\n border-radius: 4px;\n border: 1px solid ", ";\n cursor: pointer;\n display: block;\n box-sizing: border-box;\n overflow: hidden;\n"])), _colors.N900, _colors.N0);
53
-
54
- var ButtonWrapper = _styledComponents.default.span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n border: 1px solid transparent;\n margin: 0 2px;\n font-size: 0;\n display: flex;\n align-items: center;\n padding: 1px;\n border-radius: 6px;\n &:hover {\n border: 1px solid ", ";\n }\n"])), _colors.N50);
54
+ var buttonStyles = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n height: 24px;\n width: 24px;\n background: ", ";\n padding: 0;\n border-radius: 4px;\n border: 1px solid ", ";\n cursor: pointer;\n display: block;\n box-sizing: border-box;\n overflow: hidden;\n"])), (0, _tokens.token)('color.background.neutral', _colors.N900), (0, _tokens.token)('color.border', _colors.N0));
55
+ var buttonWrapperStyles = (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n border: 1px solid transparent;\n margin: 0 2px;\n font-size: 0;\n display: flex;\n align-items: center;\n padding: 1px;\n border-radius: 6px;\n &:hover {\n border: 1px solid ", ";\n }\n"])), (0, _tokens.token)('color.border', _colors.N50));
55
56
 
56
57
  var Color = /*#__PURE__*/function (_PureComponent) {
57
58
  (0, _inherits2.default)(Color, _PureComponent);
@@ -109,22 +110,29 @@ var Color = /*#__PURE__*/function (_PureComponent) {
109
110
  value = _this$props2.value,
110
111
  setRef = _this$props2.setRef;
111
112
  var borderStyle = "1px solid ".concat(borderColor);
112
- return /*#__PURE__*/_react.default.createElement(ButtonWrapper, null, /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _i18n.messages["".concat(value, "Color")], function (labels) {
113
- return /*#__PURE__*/_react.default.createElement(Button, {
113
+ return (0, _react2.jsx)("span", {
114
+ css: buttonWrapperStyles
115
+ }, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _i18n.messages["".concat(value, "Color")], function (labels) {
116
+ return (0, _react2.jsx)("button", {
117
+ css: buttonStyles,
114
118
  onClick: _this2.onClick,
115
119
  onMouseEnter: _this2.onMouseEnter,
116
120
  onMouseLeave: _this2.onMouseLeave,
117
121
  onMouseDown: _this2.onMouseDown,
118
122
  tabIndex: tabIndex,
119
123
  className: "".concat(isSelected ? 'selected' : ''),
120
- title: labels[0],
121
- "aria-checked": isSelected,
124
+ title: labels[0] // button element does not support aria-selected.
125
+ // For button selected (to be precise pressed) or not
126
+ // use aria-pressed as per
127
+ // https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/button_role#associated_aria_roles_states_and_properties
128
+ ,
129
+ "aria-pressed": isSelected,
122
130
  style: {
123
131
  backgroundColor: backgroundColor || 'transparent',
124
132
  border: borderStyle
125
133
  },
126
- innerRef: setRef
127
- }, isSelected && /*#__PURE__*/_react.default.createElement(_done.default, {
134
+ ref: setRef
135
+ }, isSelected && (0, _react2.jsx)(_done.default, {
128
136
  primaryColor: borderColor,
129
137
  label: labels[0]
130
138
  }));
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/status",
3
- "version": "1.0.2"
3
+ "version": "1.1.0"
4
4
  }
@@ -5,6 +5,8 @@ import Lozenge from '@atlaskit/lozenge';
5
5
  import { withAnalyticsEvents } from '@atlaskit/analytics-next';
6
6
  import { createStatusAnalyticsAndFire } from './analytics';
7
7
  import { ANALYTICS_HOVER_DELAY } from './constants';
8
+
9
+ /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
8
10
  const colorToLozengeAppearanceMap = {
9
11
  neutral: 'default',
10
12
  purple: 'new',
@@ -13,6 +15,8 @@ const colorToLozengeAppearanceMap = {
13
15
  yellow: 'moved',
14
16
  green: 'success'
15
17
  };
18
+ /* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
19
+
16
20
  const DEFAULT_APPEARANCE = 'default';
17
21
  const MAX_WIDTH = 200;
18
22
 
@@ -1,13 +1,14 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ /** @jsx jsx */
2
4
  import TextField from '@atlaskit/textfield';
3
5
  import { gridSize } from '@atlaskit/theme/constants';
4
- import React from 'react';
6
+ import React, { PureComponent } from 'react';
5
7
  import { injectIntl } from 'react-intl-next';
6
- import { PureComponent } from 'react';
7
- import styled from 'styled-components';
8
+ import { css, jsx } from '@emotion/react';
8
9
  import ColorPalette from './internal/color-palette';
9
10
  import { messages } from './i18n';
10
- const FieldTextWrapper = styled.div`
11
+ const fieldTextWrapperStyles = css`
11
12
  margin: 0 ${gridSize()}px;
12
13
  `;
13
14
 
@@ -50,9 +51,10 @@ class Picker extends PureComponent {
50
51
  } = this.props; // Using <React.Fragment> instead of [] to workaround Enzyme
51
52
  // (https://github.com/airbnb/enzyme/issues/1149)
52
53
 
53
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FieldTextWrapper, {
54
+ return jsx(React.Fragment, null, jsx("div", {
55
+ css: fieldTextWrapperStyles,
54
56
  key: this.fieldTextWrapperKey
55
- }, /*#__PURE__*/React.createElement(TextField, {
57
+ }, jsx(TextField, {
56
58
  value: text,
57
59
  isCompact: true,
58
60
  ref: this.handleInputRef,
@@ -61,7 +63,7 @@ class Picker extends PureComponent {
61
63
  spellCheck: false,
62
64
  autoComplete: "off",
63
65
  "aria-label": intl.formatMessage(messages.statusInputLabel)
64
- })), /*#__PURE__*/React.createElement(ColorPalette, {
66
+ })), jsx(ColorPalette, {
65
67
  key: this.colorPaletteKey,
66
68
  onClick: onColorClick,
67
69
  onHover: onColorHover,
@@ -1,11 +1,13 @@
1
+ /** @jsx jsx */
1
2
  import { gridSize } from '@atlaskit/theme/constants';
2
3
  import * as colors from '@atlaskit/theme/colors';
4
+ import { token } from '@atlaskit/tokens';
3
5
  import React, { useEffect, useRef, useCallback } from 'react';
4
- import styled from 'styled-components';
6
+ import { css, jsx } from '@emotion/react';
5
7
  import Color from './color'; // color value, label, background, borderColor
6
8
 
7
- const palette = [['neutral', colors.N40, colors.N400], ['purple', colors.P50, colors.P400], ['blue', colors.B50, colors.B400], ['red', colors.R50, colors.R400], ['yellow', colors.Y75, colors.Y400], ['green', colors.G50, colors.G400]];
8
- const ColorPaletteWrapper = styled.div`
9
+ const palette = [['neutral', token('color.background.neutral', colors.N40), token('color.text', colors.N400)], ['purple', token('color.background.discovery', colors.P50), token('color.text.discovery', colors.P400)], ['blue', token('color.background.information', colors.B50), token('color.text.information', colors.B400)], ['red', token('color.background.danger', colors.R50), token('color.text.danger', colors.R400)], ['yellow', token('color.background.warning', colors.Y75), token('color.text.warning', colors.Y400)], ['green', token('color.background.success', colors.G50), token('color.text.success', colors.G400)]];
10
+ const colorPaletteWrapperStyles = css`
9
11
  margin: ${gridSize()}px ${gridSize()}px 0 ${gridSize()}px;
10
12
  /* Firefox bug fix: https://product-fabric.atlassian.net/browse/ED-1789 */
11
13
  display: flex;
@@ -57,24 +59,34 @@ export default (({
57
59
  newRef === null || newRef === void 0 ? void 0 : newRef.focus();
58
60
  onClick(newColorValue);
59
61
  }, [selectedColor, onClick, colorRefs]);
60
- return /*#__PURE__*/React.createElement(ColorPaletteWrapper, {
61
- className: className,
62
- role: "radiogroup",
63
- style: {
64
- maxWidth: cols * 32
65
- },
66
- onKeyDown: memoizedHandleKeyDown
67
- }, palette.map(([colorValue, backgroundColor, borderColor], i) => {
68
- return /*#__PURE__*/React.createElement(Color, {
69
- key: colorValue,
70
- value: colorValue,
71
- backgroundColor: backgroundColor,
72
- borderColor: borderColor,
73
- onClick: onClick,
74
- onHover: onHover,
75
- isSelected: colorValue === selectedColor,
76
- tabIndex: colorValue === selectedColor ? 0 : -1,
77
- setRef: el => colorRefs.current[i] = el
78
- });
79
- }));
62
+ return (
63
+ /**
64
+ We need to disable below eslint rule becuase of role "radiogroup". This role was added
65
+ in https://a11y-internal.atlassian.net/browse/AK-832 to fix accessibility issue.
66
+ When we migrated to emotion from styled component, we started getting this error.
67
+ Task added in https://product-fabric.atlassian.net/wiki/spaces/E/pages/3182068181/Potential+improvements#Moderate-changes.
68
+ */
69
+ // eslint-disable-next-line jsx-a11y/interactive-supports-focus
70
+ jsx("div", {
71
+ css: colorPaletteWrapperStyles,
72
+ className: className,
73
+ role: "radiogroup",
74
+ style: {
75
+ maxWidth: cols * 32
76
+ },
77
+ onKeyDown: memoizedHandleKeyDown
78
+ }, palette.map(([colorValue, backgroundColor, borderColor], i) => {
79
+ return jsx(Color, {
80
+ key: colorValue,
81
+ value: colorValue,
82
+ backgroundColor: backgroundColor,
83
+ borderColor: borderColor,
84
+ onClick: onClick,
85
+ onHover: onHover,
86
+ isSelected: colorValue === selectedColor,
87
+ tabIndex: colorValue === selectedColor ? 0 : -1,
88
+ setRef: el => colorRefs.current[i] = el
89
+ });
90
+ }))
91
+ );
80
92
  });
@@ -1,25 +1,27 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ /** @jsx jsx */
2
4
  import EditorDoneIcon from '@atlaskit/icon/glyph/editor/done';
3
5
  import { N900, N0, N50 } from '@atlaskit/theme/colors';
4
- import React from 'react';
5
- import { PureComponent } from 'react';
6
+ import { token } from '@atlaskit/tokens';
7
+ import React, { PureComponent } from 'react';
6
8
  import { FormattedMessage } from 'react-intl-next';
7
- import styled from 'styled-components';
9
+ import { css, jsx } from '@emotion/react';
8
10
  import { ANALYTICS_HOVER_DELAY } from '../constants';
9
11
  import { messages } from '../i18n';
10
- const Button = styled.button`
12
+ const buttonStyles = css`
11
13
  height: 24px;
12
14
  width: 24px;
13
- background: ${N900};
15
+ background: ${token('color.background.neutral', N900)};
14
16
  padding: 0;
15
17
  border-radius: 4px;
16
- border: 1px solid ${N0};
18
+ border: 1px solid ${token('color.border', N0)};
17
19
  cursor: pointer;
18
20
  display: block;
19
21
  box-sizing: border-box;
20
22
  overflow: hidden;
21
23
  `;
22
- const ButtonWrapper = styled.span`
24
+ const buttonWrapperStyles = css`
23
25
  border: 1px solid transparent;
24
26
  margin: 0 2px;
25
27
  font-size: 0;
@@ -28,7 +30,7 @@ const ButtonWrapper = styled.span`
28
30
  padding: 1px;
29
31
  border-radius: 6px;
30
32
  &:hover {
31
- border: 1px solid ${N50};
33
+ border: 1px solid ${token('color.border', N50)};
32
34
  }
33
35
  `;
34
36
  export default class Color extends PureComponent {
@@ -78,21 +80,28 @@ export default class Color extends PureComponent {
78
80
  setRef
79
81
  } = this.props;
80
82
  const borderStyle = `1px solid ${borderColor}`;
81
- return /*#__PURE__*/React.createElement(ButtonWrapper, null, /*#__PURE__*/React.createElement(FormattedMessage, messages[`${value}Color`], labels => /*#__PURE__*/React.createElement(Button, {
83
+ return jsx("span", {
84
+ css: buttonWrapperStyles
85
+ }, jsx(FormattedMessage, messages[`${value}Color`], labels => jsx("button", {
86
+ css: buttonStyles,
82
87
  onClick: this.onClick,
83
88
  onMouseEnter: this.onMouseEnter,
84
89
  onMouseLeave: this.onMouseLeave,
85
90
  onMouseDown: this.onMouseDown,
86
91
  tabIndex: tabIndex,
87
92
  className: `${isSelected ? 'selected' : ''}`,
88
- title: labels[0],
89
- "aria-checked": isSelected,
93
+ title: labels[0] // button element does not support aria-selected.
94
+ // For button selected (to be precise pressed) or not
95
+ // use aria-pressed as per
96
+ // https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/button_role#associated_aria_roles_states_and_properties
97
+ ,
98
+ "aria-pressed": isSelected,
90
99
  style: {
91
100
  backgroundColor: backgroundColor || 'transparent',
92
101
  border: borderStyle
93
102
  },
94
- innerRef: setRef
95
- }, isSelected && /*#__PURE__*/React.createElement(EditorDoneIcon, {
103
+ ref: setRef
104
+ }, isSelected && jsx(EditorDoneIcon, {
96
105
  primaryColor: borderColor,
97
106
  label: labels[0]
98
107
  }))));
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/status",
3
- "version": "1.0.2"
3
+ "version": "1.1.0"
4
4
  }
@@ -16,6 +16,8 @@ import Lozenge from '@atlaskit/lozenge';
16
16
  import { withAnalyticsEvents } from '@atlaskit/analytics-next';
17
17
  import { createStatusAnalyticsAndFire } from './analytics';
18
18
  import { ANALYTICS_HOVER_DELAY } from './constants';
19
+
20
+ /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
19
21
  var colorToLozengeAppearanceMap = {
20
22
  neutral: 'default',
21
23
  purple: 'new',
@@ -24,6 +26,8 @@ var colorToLozengeAppearanceMap = {
24
26
  yellow: 'moved',
25
27
  green: 'success'
26
28
  };
29
+ /* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
30
+
27
31
  var DEFAULT_APPEARANCE = 'default';
28
32
  var MAX_WIDTH = 200;
29
33
 
@@ -13,15 +13,15 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
13
13
 
14
14
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
15
15
 
16
+ /** @jsx jsx */
16
17
  import TextField from '@atlaskit/textfield';
17
18
  import { gridSize } from '@atlaskit/theme/constants';
18
- import React from 'react';
19
+ import React, { PureComponent } from 'react';
19
20
  import { injectIntl } from 'react-intl-next';
20
- import { PureComponent } from 'react';
21
- import styled from 'styled-components';
21
+ import { css, jsx } from '@emotion/react';
22
22
  import ColorPalette from './internal/color-palette';
23
23
  import { messages } from './i18n';
24
- var FieldTextWrapper = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n margin: 0 ", "px;\n"])), gridSize());
24
+ var fieldTextWrapperStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n margin: 0 ", "px;\n"])), gridSize());
25
25
 
26
26
  var Picker = /*#__PURE__*/function (_PureComponent) {
27
27
  _inherits(Picker, _PureComponent);
@@ -77,9 +77,10 @@ var Picker = /*#__PURE__*/function (_PureComponent) {
77
77
  intl = _this$props.intl; // Using <React.Fragment> instead of [] to workaround Enzyme
78
78
  // (https://github.com/airbnb/enzyme/issues/1149)
79
79
 
80
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FieldTextWrapper, {
80
+ return jsx(React.Fragment, null, jsx("div", {
81
+ css: fieldTextWrapperStyles,
81
82
  key: this.fieldTextWrapperKey
82
- }, /*#__PURE__*/React.createElement(TextField, {
83
+ }, jsx(TextField, {
83
84
  value: text,
84
85
  isCompact: true,
85
86
  ref: this.handleInputRef,
@@ -88,7 +89,7 @@ var Picker = /*#__PURE__*/function (_PureComponent) {
88
89
  spellCheck: false,
89
90
  autoComplete: "off",
90
91
  "aria-label": intl.formatMessage(messages.statusInputLabel)
91
- })), /*#__PURE__*/React.createElement(ColorPalette, {
92
+ })), jsx(ColorPalette, {
92
93
  key: this.colorPaletteKey,
93
94
  onClick: onColorClick,
94
95
  onHover: onColorHover,
@@ -3,14 +3,16 @@ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral
3
3
 
4
4
  var _templateObject;
5
5
 
6
+ /** @jsx jsx */
6
7
  import { gridSize } from '@atlaskit/theme/constants';
7
8
  import * as colors from '@atlaskit/theme/colors';
9
+ import { token } from '@atlaskit/tokens';
8
10
  import React, { useEffect, useRef, useCallback } from 'react';
9
- import styled from 'styled-components';
11
+ import { css, jsx } from '@emotion/react';
10
12
  import Color from './color'; // color value, label, background, borderColor
11
13
 
12
- var palette = [['neutral', colors.N40, colors.N400], ['purple', colors.P50, colors.P400], ['blue', colors.B50, colors.B400], ['red', colors.R50, colors.R400], ['yellow', colors.Y75, colors.Y400], ['green', colors.G50, colors.G400]];
13
- var ColorPaletteWrapper = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n margin: ", "px ", "px 0 ", "px;\n /* Firefox bug fix: https://product-fabric.atlassian.net/browse/ED-1789 */\n display: flex;\n flex-wrap: wrap;\n"])), gridSize(), gridSize(), gridSize());
14
+ var palette = [['neutral', token('color.background.neutral', colors.N40), token('color.text', colors.N400)], ['purple', token('color.background.discovery', colors.P50), token('color.text.discovery', colors.P400)], ['blue', token('color.background.information', colors.B50), token('color.text.information', colors.B400)], ['red', token('color.background.danger', colors.R50), token('color.text.danger', colors.R400)], ['yellow', token('color.background.warning', colors.Y75), token('color.text.warning', colors.Y400)], ['green', token('color.background.success', colors.G50), token('color.text.success', colors.G400)]];
15
+ var colorPaletteWrapperStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n margin: ", "px ", "px 0 ", "px;\n /* Firefox bug fix: https://product-fabric.atlassian.net/browse/ED-1789 */\n display: flex;\n flex-wrap: wrap;\n"])), gridSize(), gridSize(), gridSize());
14
16
  var VK_LEFT = 37; //ArrowLeft
15
17
 
16
18
  var VK_RIGHT = 39; //ArrowRight
@@ -62,31 +64,41 @@ export default (function (_ref) {
62
64
  newRef === null || newRef === void 0 ? void 0 : newRef.focus();
63
65
  onClick(newColorValue);
64
66
  }, [selectedColor, onClick, colorRefs]);
65
- return /*#__PURE__*/React.createElement(ColorPaletteWrapper, {
66
- className: className,
67
- role: "radiogroup",
68
- style: {
69
- maxWidth: cols * 32
70
- },
71
- onKeyDown: memoizedHandleKeyDown
72
- }, palette.map(function (_ref4, i) {
73
- var _ref5 = _slicedToArray(_ref4, 3),
74
- colorValue = _ref5[0],
75
- backgroundColor = _ref5[1],
76
- borderColor = _ref5[2];
67
+ return (
68
+ /**
69
+ We need to disable below eslint rule becuase of role "radiogroup". This role was added
70
+ in https://a11y-internal.atlassian.net/browse/AK-832 to fix accessibility issue.
71
+ When we migrated to emotion from styled component, we started getting this error.
72
+ Task added in https://product-fabric.atlassian.net/wiki/spaces/E/pages/3182068181/Potential+improvements#Moderate-changes.
73
+ */
74
+ // eslint-disable-next-line jsx-a11y/interactive-supports-focus
75
+ jsx("div", {
76
+ css: colorPaletteWrapperStyles,
77
+ className: className,
78
+ role: "radiogroup",
79
+ style: {
80
+ maxWidth: cols * 32
81
+ },
82
+ onKeyDown: memoizedHandleKeyDown
83
+ }, palette.map(function (_ref4, i) {
84
+ var _ref5 = _slicedToArray(_ref4, 3),
85
+ colorValue = _ref5[0],
86
+ backgroundColor = _ref5[1],
87
+ borderColor = _ref5[2];
77
88
 
78
- return /*#__PURE__*/React.createElement(Color, {
79
- key: colorValue,
80
- value: colorValue,
81
- backgroundColor: backgroundColor,
82
- borderColor: borderColor,
83
- onClick: onClick,
84
- onHover: onHover,
85
- isSelected: colorValue === selectedColor,
86
- tabIndex: colorValue === selectedColor ? 0 : -1,
87
- setRef: function setRef(el) {
88
- return colorRefs.current[i] = el;
89
- }
90
- });
91
- }));
89
+ return jsx(Color, {
90
+ key: colorValue,
91
+ value: colorValue,
92
+ backgroundColor: backgroundColor,
93
+ borderColor: borderColor,
94
+ onClick: onClick,
95
+ onHover: onHover,
96
+ isSelected: colorValue === selectedColor,
97
+ tabIndex: colorValue === selectedColor ? 0 : -1,
98
+ setRef: function setRef(el) {
99
+ return colorRefs.current[i] = el;
100
+ }
101
+ });
102
+ }))
103
+ );
92
104
  });
@@ -13,16 +13,17 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
13
13
 
14
14
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
15
15
 
16
+ /** @jsx jsx */
16
17
  import EditorDoneIcon from '@atlaskit/icon/glyph/editor/done';
17
18
  import { N900, N0, N50 } from '@atlaskit/theme/colors';
18
- import React from 'react';
19
- import { PureComponent } from 'react';
19
+ import { token } from '@atlaskit/tokens';
20
+ import React, { PureComponent } from 'react';
20
21
  import { FormattedMessage } from 'react-intl-next';
21
- import styled from 'styled-components';
22
+ import { css, jsx } from '@emotion/react';
22
23
  import { ANALYTICS_HOVER_DELAY } from '../constants';
23
24
  import { messages } from '../i18n';
24
- var Button = styled.button(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n height: 24px;\n width: 24px;\n background: ", ";\n padding: 0;\n border-radius: 4px;\n border: 1px solid ", ";\n cursor: pointer;\n display: block;\n box-sizing: border-box;\n overflow: hidden;\n"])), N900, N0);
25
- var ButtonWrapper = styled.span(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n border: 1px solid transparent;\n margin: 0 2px;\n font-size: 0;\n display: flex;\n align-items: center;\n padding: 1px;\n border-radius: 6px;\n &:hover {\n border: 1px solid ", ";\n }\n"])), N50);
25
+ var buttonStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n height: 24px;\n width: 24px;\n background: ", ";\n padding: 0;\n border-radius: 4px;\n border: 1px solid ", ";\n cursor: pointer;\n display: block;\n box-sizing: border-box;\n overflow: hidden;\n"])), token('color.background.neutral', N900), token('color.border', N0));
26
+ var buttonWrapperStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n border: 1px solid transparent;\n margin: 0 2px;\n font-size: 0;\n display: flex;\n align-items: center;\n padding: 1px;\n border-radius: 6px;\n &:hover {\n border: 1px solid ", ";\n }\n"])), token('color.border', N50));
26
27
 
27
28
  var Color = /*#__PURE__*/function (_PureComponent) {
28
29
  _inherits(Color, _PureComponent);
@@ -86,22 +87,29 @@ var Color = /*#__PURE__*/function (_PureComponent) {
86
87
  value = _this$props2.value,
87
88
  setRef = _this$props2.setRef;
88
89
  var borderStyle = "1px solid ".concat(borderColor);
89
- return /*#__PURE__*/React.createElement(ButtonWrapper, null, /*#__PURE__*/React.createElement(FormattedMessage, messages["".concat(value, "Color")], function (labels) {
90
- return /*#__PURE__*/React.createElement(Button, {
90
+ return jsx("span", {
91
+ css: buttonWrapperStyles
92
+ }, jsx(FormattedMessage, messages["".concat(value, "Color")], function (labels) {
93
+ return jsx("button", {
94
+ css: buttonStyles,
91
95
  onClick: _this2.onClick,
92
96
  onMouseEnter: _this2.onMouseEnter,
93
97
  onMouseLeave: _this2.onMouseLeave,
94
98
  onMouseDown: _this2.onMouseDown,
95
99
  tabIndex: tabIndex,
96
100
  className: "".concat(isSelected ? 'selected' : ''),
97
- title: labels[0],
98
- "aria-checked": isSelected,
101
+ title: labels[0] // button element does not support aria-selected.
102
+ // For button selected (to be precise pressed) or not
103
+ // use aria-pressed as per
104
+ // https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/button_role#associated_aria_roles_states_and_properties
105
+ ,
106
+ "aria-pressed": isSelected,
99
107
  style: {
100
108
  backgroundColor: backgroundColor || 'transparent',
101
109
  border: borderStyle
102
110
  },
103
- innerRef: setRef
104
- }, isSelected && /*#__PURE__*/React.createElement(EditorDoneIcon, {
111
+ ref: setRef
112
+ }, isSelected && jsx(EditorDoneIcon, {
105
113
  primaryColor: borderColor,
106
114
  label: labels[0]
107
115
  }));
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/status",
3
- "version": "1.0.2"
3
+ "version": "1.1.0"
4
4
  }
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import { jsx } from '@emotion/react';
2
2
  import { Color as ColorType } from '../Status';
3
3
  interface ColorPaletteProps {
4
4
  selectedColor?: ColorType;
@@ -7,5 +7,5 @@ interface ColorPaletteProps {
7
7
  cols?: number;
8
8
  className?: string;
9
9
  }
10
- declare const _default: ({ cols, onClick, selectedColor, className, onHover, }: ColorPaletteProps) => JSX.Element;
10
+ declare const _default: ({ cols, onClick, selectedColor, className, onHover, }: ColorPaletteProps) => jsx.JSX.Element;
11
11
  export default _default;
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
- import { PureComponent } from 'react';
1
+ import React, { PureComponent } from 'react';
2
+ import { jsx } from '@emotion/react';
3
3
  import { Color as ColorType } from '../Status';
4
4
  export interface ColorProps {
5
5
  value: ColorType;
@@ -9,11 +9,11 @@ export interface ColorProps {
9
9
  onHover?: (value: ColorType) => void;
10
10
  backgroundColor: string;
11
11
  borderColor: string;
12
- setRef?: (value: HTMLElement) => HTMLElement;
12
+ setRef?: (value: HTMLButtonElement) => HTMLButtonElement;
13
13
  }
14
14
  export default class Color extends PureComponent<ColorProps> {
15
15
  private hoverStartTime;
16
- render(): JSX.Element;
16
+ render(): jsx.JSX.Element;
17
17
  componentWillUnmount(): void;
18
18
  onMouseEnter: () => void;
19
19
  onMouseLeave: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/status",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "Fabric Status React Components",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -30,8 +30,9 @@
30
30
  "@atlaskit/lozenge": "^11.1.0",
31
31
  "@atlaskit/textfield": "^5.1.0",
32
32
  "@atlaskit/theme": "^12.1.0",
33
+ "@atlaskit/tokens": "^0.9.0",
33
34
  "@babel/runtime": "^7.0.0",
34
- "styled-components": "^3.2.6"
35
+ "@emotion/react": "^11.7.1"
35
36
  },
36
37
  "peerDependencies": {
37
38
  "react": "^16.8.0",
@@ -39,7 +40,7 @@
39
40
  },
40
41
  "devDependencies": {
41
42
  "@atlaskit/docs": "^9.0.0",
42
- "@atlaskit/editor-test-helpers": "^16.1.0",
43
+ "@atlaskit/editor-test-helpers": "^17.0.0",
43
44
  "@atlaskit/elements-test-helpers": "^0.7.0",
44
45
  "@atlaskit/visual-regression": "*",
45
46
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
@@ -47,7 +48,7 @@
47
48
  "enzyme-adapter-react-16": "^1.15.1",
48
49
  "react": "^16.8.0",
49
50
  "react-intl-next": "npm:react-intl@^5.18.1",
50
- "typescript": "3.9.6"
51
+ "typescript": "3.9.10"
51
52
  },
52
53
  "keywords": [
53
54
  "ui",
@@ -55,5 +56,10 @@
55
56
  "fabric",
56
57
  "editor"
57
58
  ],
58
- "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
59
+ "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1",
60
+ "techstack": {
61
+ "@repo/internal": {
62
+ "theming": "tokens"
63
+ }
64
+ }
59
65
  }