@atlaskit/button 16.8.5 → 16.9.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,11 @@
1
1
  # @atlaskit/button
2
2
 
3
+ ## 16.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`f4aff27416d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f4aff27416d) - [ux] We are testing icon button internal spacing fix behind a feature flag. Now the space between icons and right or left edge of the button will be optically perceived as even. If this fix is successful it will be available in a later release.
8
+
3
9
  ## 16.8.5
4
10
 
5
11
  ### Patch Changes
@@ -19,6 +19,7 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
19
19
  var _colors = require("@atlaskit/theme/colors");
20
20
  var _blockEvents = _interopRequireDefault(require("./block-events"));
21
21
  var _css = require("./css");
22
+ var _getIfVisuallyHiddenChildren = require("./get-if-visually-hidden-children");
22
23
  var _excluded = ["analyticsContext", "appearance", "autoFocus", "buttonCss", "children", "className", "href", "component", "iconAfter", "iconBefore", "interactionName", "isDisabled", "isSelected", "onBlur", "onClick", "onFocus", "onMouseDown", "overlay", "shouldFitContainer", "spacing", "tabIndex", "type", "testId"];
23
24
  /** @jsx jsx */
24
25
  // eslint-disable-next-line no-duplicate-imports
@@ -33,6 +34,26 @@ var noPointerEventsOnChildrenCss = {
33
34
  pointerEvents: 'none'
34
35
  }
35
36
  };
37
+ var iconBeforeSpacingFixStyle = (0, _react2.css)({
38
+ marginLeft: '-4px'
39
+ });
40
+ var iconAfterSpacingFixStyle = (0, _react2.css)({
41
+ marginRight: '-4px'
42
+ });
43
+ var getSpacingFix = function getSpacingFix(children, spacingStyles) {
44
+ if (!(0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.icon-button-spacing-fix_o1zc5') || !children || (0, _getIfVisuallyHiddenChildren.getIfVisuallyHiddenChildren)(children)) {
45
+ return null;
46
+ }
47
+ return spacingStyles;
48
+ };
49
+ var getChildren = function getChildren(children, childrenStyles) {
50
+ if ((0, _getIfVisuallyHiddenChildren.getIfVisuallyHiddenChildren)(children)) {
51
+ return children;
52
+ }
53
+ return children ? (0, _react2.jsx)("span", {
54
+ css: childrenStyles
55
+ }, children) : null;
56
+ };
36
57
  var _default = /*#__PURE__*/_react.default.forwardRef(function ButtonBase(props, ref) {
37
58
  var analyticsContext = props.analyticsContext,
38
59
  _props$appearance = props.appearance,
@@ -96,7 +117,7 @@ var _default = /*#__PURE__*/_react.default.forwardRef(function ButtonBase(props,
96
117
  action: 'clicked',
97
118
  componentName: 'button',
98
119
  packageName: "@atlaskit/button",
99
- packageVersion: "16.8.5",
120
+ packageVersion: "16.9.0",
100
121
  analyticsData: analyticsContext
101
122
  });
102
123
 
@@ -159,15 +180,17 @@ var _default = /*#__PURE__*/_react.default.forwardRef(function ButtonBase(props,
159
180
  })), iconBefore ? (0, _react2.jsx)("span", {
160
181
  css: [fadeCss, (0, _css.getIconStyle)({
161
182
  spacing: spacing
162
- })]
163
- }, iconBefore) : null, children ? (0, _react2.jsx)("span", {
183
+ }), getSpacingFix(children, iconBeforeSpacingFixStyle)]
184
+ }, iconBefore) : null, !(0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.icon-button-spacing-fix_o1zc5') && children ? (0, _react2.jsx)("span", {
164
185
  css: [fadeCss, (0, _css.getContentStyle)({
165
186
  spacing: spacing
166
187
  })]
167
- }, children) : null, iconAfter ? (0, _react2.jsx)("span", {
188
+ }, children) : null, (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.icon-button-spacing-fix_o1zc5') && getChildren(children, [fadeCss, (0, _css.getContentStyle)({
189
+ spacing: spacing
190
+ })]), iconAfter ? (0, _react2.jsx)("span", {
168
191
  css: [fadeCss, (0, _css.getIconStyle)({
169
192
  spacing: spacing
170
- })]
193
+ }), getSpacingFix(children, iconAfterSpacingFixStyle)]
171
194
  }, iconAfter) : null, overlay ? (0, _react2.jsx)("span", {
172
195
  css: [_css.overlayCss, spinnerHackCss]
173
196
  }, overlay) : null));
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getIfVisuallyHiddenChildren = void 0;
8
+ var _react = require("react");
9
+ var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
10
+ var getIfVisuallyHiddenChildren = function getIfVisuallyHiddenChildren(children) {
11
+ return children && /*#__PURE__*/(0, _react.isValidElement)(children) && children.type === _visuallyHidden.default;
12
+ };
13
+ exports.getIfVisuallyHiddenChildren = getIfVisuallyHiddenChildren;
@@ -4,10 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = getIsOnlySingleIcon;
7
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
8
+ var _getIfVisuallyHiddenChildren = require("./get-if-visually-hidden-children");
7
9
  function getIsOnlySingleIcon(_ref) {
8
10
  var children = _ref.children,
9
11
  iconBefore = _ref.iconBefore,
10
12
  iconAfter = _ref.iconAfter;
13
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.icon-button-spacing-fix_o1zc5') && (0, _getIfVisuallyHiddenChildren.getIfVisuallyHiddenChildren)(children)) {
14
+ return true;
15
+ }
11
16
  if (children) {
12
17
  return false;
13
18
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/button",
3
- "version": "16.8.5",
3
+ "version": "16.9.0",
4
4
  "sideEffects": false
5
5
  }
@@ -12,6 +12,7 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
12
12
  import { N500 } from '@atlaskit/theme/colors';
13
13
  import blockEvents from './block-events';
14
14
  import { getContentStyle, getFadingCss, getIconStyle, overlayCss } from './css';
15
+ import { getIfVisuallyHiddenChildren } from './get-if-visually-hidden-children';
15
16
 
16
17
  // Disabled buttons will still publish events for nested elements in webkit.
17
18
  // We are disabling pointer events on child elements so that
@@ -22,6 +23,26 @@ const noPointerEventsOnChildrenCss = {
22
23
  pointerEvents: 'none'
23
24
  }
24
25
  };
26
+ const iconBeforeSpacingFixStyle = css({
27
+ marginLeft: '-4px'
28
+ });
29
+ const iconAfterSpacingFixStyle = css({
30
+ marginRight: '-4px'
31
+ });
32
+ const getSpacingFix = (children, spacingStyles) => {
33
+ if (!getBooleanFF('platform.design-system-team.icon-button-spacing-fix_o1zc5') || !children || getIfVisuallyHiddenChildren(children)) {
34
+ return null;
35
+ }
36
+ return spacingStyles;
37
+ };
38
+ const getChildren = (children, childrenStyles) => {
39
+ if (getIfVisuallyHiddenChildren(children)) {
40
+ return children;
41
+ }
42
+ return children ? jsx("span", {
43
+ css: childrenStyles
44
+ }, children) : null;
45
+ };
25
46
  export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
26
47
  const {
27
48
  // I don't think analytics should be in button, but for now it is
@@ -84,7 +105,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
84
105
  action: 'clicked',
85
106
  componentName: 'button',
86
107
  packageName: "@atlaskit/button",
87
- packageVersion: "16.8.5",
108
+ packageVersion: "16.9.0",
88
109
  analyticsData: analyticsContext
89
110
  });
90
111
 
@@ -147,15 +168,17 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
147
168
  })), iconBefore ? jsx("span", {
148
169
  css: [fadeCss, getIconStyle({
149
170
  spacing
150
- })]
151
- }, iconBefore) : null, children ? jsx("span", {
171
+ }), getSpacingFix(children, iconBeforeSpacingFixStyle)]
172
+ }, iconBefore) : null, !getBooleanFF('platform.design-system-team.icon-button-spacing-fix_o1zc5') && children ? jsx("span", {
152
173
  css: [fadeCss, getContentStyle({
153
174
  spacing
154
175
  })]
155
- }, children) : null, iconAfter ? jsx("span", {
176
+ }, children) : null, getBooleanFF('platform.design-system-team.icon-button-spacing-fix_o1zc5') && getChildren(children, [fadeCss, getContentStyle({
177
+ spacing
178
+ })]), iconAfter ? jsx("span", {
156
179
  css: [fadeCss, getIconStyle({
157
180
  spacing
158
- })]
181
+ }), getSpacingFix(children, iconAfterSpacingFixStyle)]
159
182
  }, iconAfter) : null, overlay ? jsx("span", {
160
183
  css: [overlayCss, spinnerHackCss]
161
184
  }, overlay) : null));
@@ -0,0 +1,5 @@
1
+ import { isValidElement } from 'react';
2
+ import VisuallyHidden from '@atlaskit/visually-hidden';
3
+ export const getIfVisuallyHiddenChildren = children => {
4
+ return children && /*#__PURE__*/isValidElement(children) && children.type === VisuallyHidden;
5
+ };
@@ -1,8 +1,13 @@
1
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
2
+ import { getIfVisuallyHiddenChildren } from './get-if-visually-hidden-children';
1
3
  export default function getIsOnlySingleIcon({
2
4
  children,
3
5
  iconBefore,
4
6
  iconAfter
5
7
  }) {
8
+ if (getBooleanFF('platform.design-system-team.icon-button-spacing-fix_o1zc5') && getIfVisuallyHiddenChildren(children)) {
9
+ return true;
10
+ }
6
11
  if (children) {
7
12
  return false;
8
13
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/button",
3
- "version": "16.8.5",
3
+ "version": "16.9.0",
4
4
  "sideEffects": false
5
5
  }
@@ -14,6 +14,7 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
14
14
  import { N500 } from '@atlaskit/theme/colors';
15
15
  import blockEvents from './block-events';
16
16
  import { getContentStyle, getFadingCss, getIconStyle, overlayCss } from './css';
17
+ import { getIfVisuallyHiddenChildren } from './get-if-visually-hidden-children';
17
18
 
18
19
  // Disabled buttons will still publish events for nested elements in webkit.
19
20
  // We are disabling pointer events on child elements so that
@@ -24,6 +25,26 @@ var noPointerEventsOnChildrenCss = {
24
25
  pointerEvents: 'none'
25
26
  }
26
27
  };
28
+ var iconBeforeSpacingFixStyle = css({
29
+ marginLeft: '-4px'
30
+ });
31
+ var iconAfterSpacingFixStyle = css({
32
+ marginRight: '-4px'
33
+ });
34
+ var getSpacingFix = function getSpacingFix(children, spacingStyles) {
35
+ if (!getBooleanFF('platform.design-system-team.icon-button-spacing-fix_o1zc5') || !children || getIfVisuallyHiddenChildren(children)) {
36
+ return null;
37
+ }
38
+ return spacingStyles;
39
+ };
40
+ var getChildren = function getChildren(children, childrenStyles) {
41
+ if (getIfVisuallyHiddenChildren(children)) {
42
+ return children;
43
+ }
44
+ return children ? jsx("span", {
45
+ css: childrenStyles
46
+ }, children) : null;
47
+ };
27
48
  export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
28
49
  var analyticsContext = props.analyticsContext,
29
50
  _props$appearance = props.appearance,
@@ -87,7 +108,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
87
108
  action: 'clicked',
88
109
  componentName: 'button',
89
110
  packageName: "@atlaskit/button",
90
- packageVersion: "16.8.5",
111
+ packageVersion: "16.9.0",
91
112
  analyticsData: analyticsContext
92
113
  });
93
114
 
@@ -150,15 +171,17 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
150
171
  })), iconBefore ? jsx("span", {
151
172
  css: [fadeCss, getIconStyle({
152
173
  spacing: spacing
153
- })]
154
- }, iconBefore) : null, children ? jsx("span", {
174
+ }), getSpacingFix(children, iconBeforeSpacingFixStyle)]
175
+ }, iconBefore) : null, !getBooleanFF('platform.design-system-team.icon-button-spacing-fix_o1zc5') && children ? jsx("span", {
155
176
  css: [fadeCss, getContentStyle({
156
177
  spacing: spacing
157
178
  })]
158
- }, children) : null, iconAfter ? jsx("span", {
179
+ }, children) : null, getBooleanFF('platform.design-system-team.icon-button-spacing-fix_o1zc5') && getChildren(children, [fadeCss, getContentStyle({
180
+ spacing: spacing
181
+ })]), iconAfter ? jsx("span", {
159
182
  css: [fadeCss, getIconStyle({
160
183
  spacing: spacing
161
- })]
184
+ }), getSpacingFix(children, iconAfterSpacingFixStyle)]
162
185
  }, iconAfter) : null, overlay ? jsx("span", {
163
186
  css: [overlayCss, spinnerHackCss]
164
187
  }, overlay) : null));
@@ -0,0 +1,5 @@
1
+ import { isValidElement } from 'react';
2
+ import VisuallyHidden from '@atlaskit/visually-hidden';
3
+ export var getIfVisuallyHiddenChildren = function getIfVisuallyHiddenChildren(children) {
4
+ return children && /*#__PURE__*/isValidElement(children) && children.type === VisuallyHidden;
5
+ };
@@ -1,7 +1,12 @@
1
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
2
+ import { getIfVisuallyHiddenChildren } from './get-if-visually-hidden-children';
1
3
  export default function getIsOnlySingleIcon(_ref) {
2
4
  var children = _ref.children,
3
5
  iconBefore = _ref.iconBefore,
4
6
  iconAfter = _ref.iconAfter;
7
+ if (getBooleanFF('platform.design-system-team.icon-button-spacing-fix_o1zc5') && getIfVisuallyHiddenChildren(children)) {
8
+ return true;
9
+ }
5
10
  if (children) {
6
11
  return false;
7
12
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/button",
3
- "version": "16.8.5",
3
+ "version": "16.9.0",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1,2 @@
1
+ import { type ReactNode } from 'react';
2
+ export declare const getIfVisuallyHiddenChildren: (children: ReactNode) => boolean | "" | 0 | null | undefined;
@@ -0,0 +1,2 @@
1
+ import { type ReactNode } from 'react';
2
+ export declare const getIfVisuallyHiddenChildren: (children: ReactNode) => boolean | "" | 0 | null | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/button",
3
- "version": "16.8.5",
3
+ "version": "16.9.0",
4
4
  "description": "A button triggers an event or action. They let users know what will happen next.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -41,6 +41,9 @@
41
41
  "platform-feature-flags": {
42
42
  "platform.design-system-team.clove-sprint-a11y-button_5rz5j": {
43
43
  "type": "boolean"
44
+ },
45
+ "platform.design-system-team.icon-button-spacing-fix_o1zc5": {
46
+ "type": "boolean"
44
47
  }
45
48
  },
46
49
  "dependencies": {
@@ -51,7 +54,8 @@
51
54
  "@atlaskit/platform-feature-flags": "^0.2.0",
52
55
  "@atlaskit/spinner": "^15.5.0",
53
56
  "@atlaskit/theme": "^12.5.0",
54
- "@atlaskit/tokens": "^1.13.0",
57
+ "@atlaskit/tokens": "^1.14.0",
58
+ "@atlaskit/visually-hidden": "^1.2.4",
55
59
  "@babel/runtime": "^7.0.0",
56
60
  "@emotion/react": "^11.7.1"
57
61
  },