@atlaskit/editor-plugin-card 0.15.0 → 0.15.2

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/editor-plugin-card
2
2
 
3
+ ## 0.15.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#65152](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/65152) [`7b55d001d263`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7b55d001d263) - remove unused css and small refactor
8
+
9
+ ## 0.15.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#64861](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/64861) [`87c2c502ea93`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/87c2c502ea93) - [UX] scale icon size based on font size in discoverability overlay
14
+ - [#64817](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/64817) [`afa680b9f6bb`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/afa680b9f6bb) - change background color for active state of discoverability overlay to match color of smart link active state
15
+ - Updated dependencies
16
+
3
17
  ## 0.15.0
4
18
 
5
19
  ### Minor Changes
@@ -9,6 +9,7 @@ exports.default = void 0;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
11
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
13
  var _react = _interopRequireWildcard(require("react"));
13
14
  var _react2 = require("@emotion/react");
14
15
  var _debounce = _interopRequireDefault(require("lodash/debounce"));
@@ -19,6 +20,8 @@ var _preferences = _interopRequireDefault(require("@atlaskit/icon/glyph/preferen
19
20
  var _colors = require("@atlaskit/theme/colors");
20
21
  var _utils2 = require("./utils");
21
22
  var _excluded = ["children", "isSelected", "isVisible", "testId", "url"];
23
+ var _active;
24
+ /* eslint-disable @atlaskit/design-system/no-nested-styles */
22
25
  /* eslint-disable @atlaskit/design-system/prefer-primitives */
23
26
  /** @jsx jsx */
24
27
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -29,16 +32,26 @@ var PADDING_IN_PX = 4;
29
32
  var ICON_WIDTH_IN_PX = 14;
30
33
  var ICON_AND_LABEL_CLASSNAME = 'ak-editor-card-overlay-icon-and-label';
31
34
  var OVERLAY_LABEL_CLASSNAME = 'ak-editor-card-overlay-label';
35
+ var OVERLAY_GRADIENT_CLASSNAME = 'ak-editor-card-overlay-gradient';
32
36
  var OVERLAY_MARKER_CLASSNAME = 'ak-editor-card-overlay-marker';
33
37
  var TEXT_NODE_SELECTOR = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].join(',');
38
+ var SMART_LINK_BACKGROUND_COLOR = "var(--ds-surface-raised, ".concat(_colors.N0, ")");
39
+ var SMART_LINK_ACTIVE_COLOR = "var(--ds-background-selected, ".concat(_colors.B100, ")");
40
+ var getGradientWithColor = function getGradientWithColor(color) {
41
+ return "linear-gradient(270deg, ".concat(color, " 0%, rgba(255, 255, 255, 0.00) 100%)");
42
+ };
34
43
  var containerStyles = (0, _react2.css)({
35
44
  position: 'relative',
36
- lineHeight: 'normal'
45
+ lineHeight: 'normal',
46
+ ':active': (_active = {}, (0, _defineProperty2.default)(_active, ".".concat(ICON_AND_LABEL_CLASSNAME), {
47
+ background: SMART_LINK_ACTIVE_COLOR
48
+ }), (0, _defineProperty2.default)(_active, ".".concat(OVERLAY_GRADIENT_CLASSNAME), {
49
+ background: getGradientWithColor(SMART_LINK_ACTIVE_COLOR)
50
+ }), _active)
37
51
  });
38
52
  var overlayStyles = (0, _react2.css)({
39
53
  // Set default styling to be invisible but available in dom for width calculation.
40
54
  visibility: 'hidden',
41
- // Layout
42
55
  position: 'absolute',
43
56
  display: 'inline-flex',
44
57
  justifyContent: 'flex-end',
@@ -51,14 +64,6 @@ var overlayStyles = (0, _react2.css)({
51
64
  overflow: 'hidden',
52
65
  // EDM-1717: box-shadow Safari fix bring load wrapper zIndex to 1
53
66
  zIndex: 2,
54
- // Appearance
55
- color: "var(--ds-text-subtlest, ".concat(_colors.N700, ")"),
56
- // Using `&` twice to increase specificity. (These are not nested styles.)+
57
- // eslint-disable-next-line @atlaskit/design-system/no-nested-styles
58
- '&&:link, &&:active, &&:focus, &&:hover, &&:visited': {
59
- color: "var(--ds-text-subtlest, ".concat(_colors.N700, ")"),
60
- textDecoration: 'none'
61
- },
62
67
  pointerEvents: 'none'
63
68
  });
64
69
  var showOverlayStyles = (0, _react2.css)({
@@ -67,7 +72,6 @@ var showOverlayStyles = (0, _react2.css)({
67
72
  });
68
73
  var iconStyles = (0, _react2.css)({
69
74
  // Position icon in the middle
70
- // eslint-disable-next-line @atlaskit/design-system/no-nested-styles
71
75
  span: {
72
76
  display: 'flex'
73
77
  }
@@ -78,14 +82,15 @@ var labelStyles = (0, _react2.css)({
78
82
  width: 'max-content'
79
83
  });
80
84
  var iconAndLabelStyles = (0, _react2.css)({
81
- background: "var(--ds-surface-raised, white)",
82
85
  display: 'flex',
83
86
  alignItems: 'center',
84
87
  height: '100%',
85
88
  gap: "var(--ds-space-050, 4px)",
86
89
  paddingRight: "var(--ds-space-050, 4px)",
87
90
  // Margin to avoid the background covering the link border
88
- marginRight: "var(--ds-space-025, 2px)"
91
+ marginRight: "var(--ds-space-025, 2px)",
92
+ background: SMART_LINK_BACKGROUND_COLOR,
93
+ color: "var(--ds-text-subtlest, ".concat(_colors.N700, ")")
89
94
  });
90
95
  var overflowingContainerStyles = (0, _react2.css)({
91
96
  display: 'flex',
@@ -97,7 +102,7 @@ var overflowingContainerStyles = (0, _react2.css)({
97
102
  var gradientStyles = (0, _react2.css)({
98
103
  width: '2.5rem',
99
104
  height: '100%',
100
- background: "linear-gradient(270deg, ".concat("var(--ds-surface-raised, white)", " 0%, rgba(255, 255, 255, 0.00) 100%)")
105
+ background: getGradientWithColor(SMART_LINK_BACKGROUND_COLOR)
101
106
  });
102
107
  var InlineCardOverlay = function InlineCardOverlay(_ref) {
103
108
  var children = _ref.children,
@@ -124,6 +129,7 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
124
129
  var maxOverlayWidth = (0, _react.useRef)(0);
125
130
  var minOverlayWidth = (0, _react.useRef)(ESTIMATED_MIN_WIDTH_IN_PX);
126
131
  var parentWidth = (0, _react.useRef)(0);
132
+ var iconSize = (0, _react.useRef)('small');
127
133
  var containerRef = (0, _react.useRef)(null);
128
134
  var setVisibility = (0, _react.useCallback)(function () {
129
135
  if (!containerRef.current || !maxOverlayWidth.current) {
@@ -173,6 +179,7 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
173
179
  min = _getOverlayWidths.min;
174
180
  maxOverlayWidth.current = max;
175
181
  minOverlayWidth.current = min;
182
+ iconSize.current = (0, _utils2.getIconSize)(_label);
176
183
  }
177
184
  }
178
185
  if (isVisible) {
@@ -240,7 +247,7 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
240
247
  css: iconStyles
241
248
  }, (0, _react2.jsx)(_preferences.default, {
242
249
  label: label,
243
- size: "small",
250
+ size: iconSize.current,
244
251
  testId: "".concat(testId, "-icon")
245
252
  })), showLabel && (0, _react2.jsx)("span", {
246
253
  css: labelStyles,
@@ -248,6 +255,7 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
248
255
  "data-testid": "".concat(testId, "-label")
249
256
  }, label)), (0, _react2.jsx)("span", {
250
257
  css: gradientStyles,
258
+ className: OVERLAY_GRADIENT_CLASSNAME,
251
259
  "data-testid": "".concat(testId, "-gradient")
252
260
  })))));
253
261
  };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isOneLine = exports.getOverlayWidths = exports.getInlineCardAvailableWidth = exports.getChildElement = void 0;
6
+ exports.isOneLine = exports.getOverlayWidths = exports.getInlineCardAvailableWidth = exports.getIconSize = exports.getChildElement = void 0;
7
7
  /**
8
8
  * Find a child element inside a ref.
9
9
  */
@@ -37,4 +37,12 @@ var getOverlayWidths = exports.getOverlayWidths = function getOverlayWidths(over
37
37
  max: max,
38
38
  min: min
39
39
  };
40
+ };
41
+ var getIconSize = exports.getIconSize = function getIconSize(labelEl) {
42
+ var h2FontSizePx = 20;
43
+ var fontSize = window && parseFloat(window.getComputedStyle(labelEl).fontSize);
44
+ if (!fontSize || fontSize < h2FontSizePx) {
45
+ return 'small';
46
+ }
47
+ return 'medium';
40
48
  };
@@ -1,4 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ /* eslint-disable @atlaskit/design-system/no-nested-styles */
2
3
  /* eslint-disable @atlaskit/design-system/prefer-primitives */
3
4
  /** @jsx jsx */
4
5
 
@@ -9,24 +10,37 @@ import { useIntl } from 'react-intl-next';
9
10
  import { cardMessages as messages } from '@atlaskit/editor-common/messages';
10
11
  import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/utils';
11
12
  import PreferencesIcon from '@atlaskit/icon/glyph/preferences';
12
- import { N700 } from '@atlaskit/theme/colors';
13
- import { getChildElement, getInlineCardAvailableWidth, getOverlayWidths, isOneLine } from './utils';
13
+ import { B100, N0, N700 } from '@atlaskit/theme/colors';
14
+ import { getChildElement, getIconSize, getInlineCardAvailableWidth, getOverlayWidths, isOneLine } from './utils';
14
15
  const DEBOUNCE_IN_MS = 5;
15
16
  const ESTIMATED_MIN_WIDTH_IN_PX = 16;
16
17
  const PADDING_IN_PX = 4;
17
18
  const ICON_WIDTH_IN_PX = 14;
18
19
  const ICON_AND_LABEL_CLASSNAME = 'ak-editor-card-overlay-icon-and-label';
19
20
  const OVERLAY_LABEL_CLASSNAME = 'ak-editor-card-overlay-label';
21
+ const OVERLAY_GRADIENT_CLASSNAME = 'ak-editor-card-overlay-gradient';
20
22
  const OVERLAY_MARKER_CLASSNAME = 'ak-editor-card-overlay-marker';
21
23
  const TEXT_NODE_SELECTOR = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].join(',');
24
+ const SMART_LINK_BACKGROUND_COLOR = `var(--ds-surface-raised, ${N0})`;
25
+ const SMART_LINK_ACTIVE_COLOR = `var(--ds-background-selected, ${B100})`;
26
+ const getGradientWithColor = color => {
27
+ return `linear-gradient(270deg, ${color} 0%, rgba(255, 255, 255, 0.00) 100%)`;
28
+ };
22
29
  const containerStyles = css({
23
30
  position: 'relative',
24
- lineHeight: 'normal'
31
+ lineHeight: 'normal',
32
+ ':active': {
33
+ [`.${ICON_AND_LABEL_CLASSNAME}`]: {
34
+ background: SMART_LINK_ACTIVE_COLOR
35
+ },
36
+ [`.${OVERLAY_GRADIENT_CLASSNAME}`]: {
37
+ background: getGradientWithColor(SMART_LINK_ACTIVE_COLOR)
38
+ }
39
+ }
25
40
  });
26
41
  const overlayStyles = css({
27
42
  // Set default styling to be invisible but available in dom for width calculation.
28
43
  visibility: 'hidden',
29
- // Layout
30
44
  position: 'absolute',
31
45
  display: 'inline-flex',
32
46
  justifyContent: 'flex-end',
@@ -39,14 +53,6 @@ const overlayStyles = css({
39
53
  overflow: 'hidden',
40
54
  // EDM-1717: box-shadow Safari fix bring load wrapper zIndex to 1
41
55
  zIndex: 2,
42
- // Appearance
43
- color: `var(--ds-text-subtlest, ${N700})`,
44
- // Using `&` twice to increase specificity. (These are not nested styles.)+
45
- // eslint-disable-next-line @atlaskit/design-system/no-nested-styles
46
- '&&:link, &&:active, &&:focus, &&:hover, &&:visited': {
47
- color: `var(--ds-text-subtlest, ${N700})`,
48
- textDecoration: 'none'
49
- },
50
56
  pointerEvents: 'none'
51
57
  });
52
58
  const showOverlayStyles = css({
@@ -55,7 +61,6 @@ const showOverlayStyles = css({
55
61
  });
56
62
  const iconStyles = css({
57
63
  // Position icon in the middle
58
- // eslint-disable-next-line @atlaskit/design-system/no-nested-styles
59
64
  span: {
60
65
  display: 'flex'
61
66
  }
@@ -66,14 +71,15 @@ const labelStyles = css({
66
71
  width: 'max-content'
67
72
  });
68
73
  const iconAndLabelStyles = css({
69
- background: "var(--ds-surface-raised, white)",
70
74
  display: 'flex',
71
75
  alignItems: 'center',
72
76
  height: '100%',
73
77
  gap: "var(--ds-space-050, 4px)",
74
78
  paddingRight: "var(--ds-space-050, 4px)",
75
79
  // Margin to avoid the background covering the link border
76
- marginRight: "var(--ds-space-025, 2px)"
80
+ marginRight: "var(--ds-space-025, 2px)",
81
+ background: SMART_LINK_BACKGROUND_COLOR,
82
+ color: `var(--ds-text-subtlest, ${N700})`
77
83
  });
78
84
  const overflowingContainerStyles = css({
79
85
  display: 'flex',
@@ -85,7 +91,7 @@ const overflowingContainerStyles = css({
85
91
  const gradientStyles = css({
86
92
  width: '2.5rem',
87
93
  height: '100%',
88
- background: `linear-gradient(270deg, ${"var(--ds-surface-raised, white)"} 0%, rgba(255, 255, 255, 0.00) 100%)`
94
+ background: getGradientWithColor(SMART_LINK_BACKGROUND_COLOR)
89
95
  });
90
96
  const InlineCardOverlay = ({
91
97
  children,
@@ -101,6 +107,7 @@ const InlineCardOverlay = ({
101
107
  const maxOverlayWidth = useRef(0);
102
108
  const minOverlayWidth = useRef(ESTIMATED_MIN_WIDTH_IN_PX);
103
109
  const parentWidth = useRef(0);
110
+ const iconSize = useRef('small');
104
111
  const containerRef = useRef(null);
105
112
  const setVisibility = useCallback(() => {
106
113
  if (!containerRef.current || !maxOverlayWidth.current) {
@@ -151,6 +158,7 @@ const InlineCardOverlay = ({
151
158
  } = getOverlayWidths(iconAndLabel, label);
152
159
  maxOverlayWidth.current = max;
153
160
  minOverlayWidth.current = min;
161
+ iconSize.current = getIconSize(label);
154
162
  }
155
163
  }
156
164
  if (isVisible) {
@@ -216,7 +224,7 @@ const InlineCardOverlay = ({
216
224
  css: iconStyles
217
225
  }, jsx(PreferencesIcon, {
218
226
  label: label,
219
- size: "small",
227
+ size: iconSize.current,
220
228
  testId: `${testId}-icon`
221
229
  })), showLabel && jsx("span", {
222
230
  css: labelStyles,
@@ -224,6 +232,7 @@ const InlineCardOverlay = ({
224
232
  "data-testid": `${testId}-label`
225
233
  }, label)), jsx("span", {
226
234
  css: gradientStyles,
235
+ className: OVERLAY_GRADIENT_CLASSNAME,
227
236
  "data-testid": `${testId}-gradient`
228
237
  })))));
229
238
  };
@@ -29,4 +29,12 @@ export const getOverlayWidths = (overlayEl, labelEl) => {
29
29
  max,
30
30
  min
31
31
  };
32
+ };
33
+ export const getIconSize = labelEl => {
34
+ const h2FontSizePx = 20;
35
+ const fontSize = window && parseFloat(window.getComputedStyle(labelEl).fontSize);
36
+ if (!fontSize || fontSize < h2FontSizePx) {
37
+ return 'small';
38
+ }
39
+ return 'medium';
32
40
  };
@@ -1,7 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
5
  var _excluded = ["children", "isSelected", "isVisible", "testId", "url"];
6
+ var _active;
7
+ /* eslint-disable @atlaskit/design-system/no-nested-styles */
5
8
  /* eslint-disable @atlaskit/design-system/prefer-primitives */
6
9
  /** @jsx jsx */
7
10
 
@@ -12,24 +15,34 @@ import { useIntl } from 'react-intl-next';
12
15
  import { cardMessages as messages } from '@atlaskit/editor-common/messages';
13
16
  import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/utils';
14
17
  import PreferencesIcon from '@atlaskit/icon/glyph/preferences';
15
- import { N700 } from '@atlaskit/theme/colors';
16
- import { getChildElement, getInlineCardAvailableWidth, getOverlayWidths, isOneLine } from './utils';
18
+ import { B100, N0, N700 } from '@atlaskit/theme/colors';
19
+ import { getChildElement, getIconSize, getInlineCardAvailableWidth, getOverlayWidths, isOneLine } from './utils';
17
20
  var DEBOUNCE_IN_MS = 5;
18
21
  var ESTIMATED_MIN_WIDTH_IN_PX = 16;
19
22
  var PADDING_IN_PX = 4;
20
23
  var ICON_WIDTH_IN_PX = 14;
21
24
  var ICON_AND_LABEL_CLASSNAME = 'ak-editor-card-overlay-icon-and-label';
22
25
  var OVERLAY_LABEL_CLASSNAME = 'ak-editor-card-overlay-label';
26
+ var OVERLAY_GRADIENT_CLASSNAME = 'ak-editor-card-overlay-gradient';
23
27
  var OVERLAY_MARKER_CLASSNAME = 'ak-editor-card-overlay-marker';
24
28
  var TEXT_NODE_SELECTOR = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].join(',');
29
+ var SMART_LINK_BACKGROUND_COLOR = "var(--ds-surface-raised, ".concat(N0, ")");
30
+ var SMART_LINK_ACTIVE_COLOR = "var(--ds-background-selected, ".concat(B100, ")");
31
+ var getGradientWithColor = function getGradientWithColor(color) {
32
+ return "linear-gradient(270deg, ".concat(color, " 0%, rgba(255, 255, 255, 0.00) 100%)");
33
+ };
25
34
  var containerStyles = css({
26
35
  position: 'relative',
27
- lineHeight: 'normal'
36
+ lineHeight: 'normal',
37
+ ':active': (_active = {}, _defineProperty(_active, ".".concat(ICON_AND_LABEL_CLASSNAME), {
38
+ background: SMART_LINK_ACTIVE_COLOR
39
+ }), _defineProperty(_active, ".".concat(OVERLAY_GRADIENT_CLASSNAME), {
40
+ background: getGradientWithColor(SMART_LINK_ACTIVE_COLOR)
41
+ }), _active)
28
42
  });
29
43
  var overlayStyles = css({
30
44
  // Set default styling to be invisible but available in dom for width calculation.
31
45
  visibility: 'hidden',
32
- // Layout
33
46
  position: 'absolute',
34
47
  display: 'inline-flex',
35
48
  justifyContent: 'flex-end',
@@ -42,14 +55,6 @@ var overlayStyles = css({
42
55
  overflow: 'hidden',
43
56
  // EDM-1717: box-shadow Safari fix bring load wrapper zIndex to 1
44
57
  zIndex: 2,
45
- // Appearance
46
- color: "var(--ds-text-subtlest, ".concat(N700, ")"),
47
- // Using `&` twice to increase specificity. (These are not nested styles.)+
48
- // eslint-disable-next-line @atlaskit/design-system/no-nested-styles
49
- '&&:link, &&:active, &&:focus, &&:hover, &&:visited': {
50
- color: "var(--ds-text-subtlest, ".concat(N700, ")"),
51
- textDecoration: 'none'
52
- },
53
58
  pointerEvents: 'none'
54
59
  });
55
60
  var showOverlayStyles = css({
@@ -58,7 +63,6 @@ var showOverlayStyles = css({
58
63
  });
59
64
  var iconStyles = css({
60
65
  // Position icon in the middle
61
- // eslint-disable-next-line @atlaskit/design-system/no-nested-styles
62
66
  span: {
63
67
  display: 'flex'
64
68
  }
@@ -69,14 +73,15 @@ var labelStyles = css({
69
73
  width: 'max-content'
70
74
  });
71
75
  var iconAndLabelStyles = css({
72
- background: "var(--ds-surface-raised, white)",
73
76
  display: 'flex',
74
77
  alignItems: 'center',
75
78
  height: '100%',
76
79
  gap: "var(--ds-space-050, 4px)",
77
80
  paddingRight: "var(--ds-space-050, 4px)",
78
81
  // Margin to avoid the background covering the link border
79
- marginRight: "var(--ds-space-025, 2px)"
82
+ marginRight: "var(--ds-space-025, 2px)",
83
+ background: SMART_LINK_BACKGROUND_COLOR,
84
+ color: "var(--ds-text-subtlest, ".concat(N700, ")")
80
85
  });
81
86
  var overflowingContainerStyles = css({
82
87
  display: 'flex',
@@ -88,7 +93,7 @@ var overflowingContainerStyles = css({
88
93
  var gradientStyles = css({
89
94
  width: '2.5rem',
90
95
  height: '100%',
91
- background: "linear-gradient(270deg, ".concat("var(--ds-surface-raised, white)", " 0%, rgba(255, 255, 255, 0.00) 100%)")
96
+ background: getGradientWithColor(SMART_LINK_BACKGROUND_COLOR)
92
97
  });
93
98
  var InlineCardOverlay = function InlineCardOverlay(_ref) {
94
99
  var children = _ref.children,
@@ -115,6 +120,7 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
115
120
  var maxOverlayWidth = useRef(0);
116
121
  var minOverlayWidth = useRef(ESTIMATED_MIN_WIDTH_IN_PX);
117
122
  var parentWidth = useRef(0);
123
+ var iconSize = useRef('small');
118
124
  var containerRef = useRef(null);
119
125
  var setVisibility = useCallback(function () {
120
126
  if (!containerRef.current || !maxOverlayWidth.current) {
@@ -164,6 +170,7 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
164
170
  min = _getOverlayWidths.min;
165
171
  maxOverlayWidth.current = max;
166
172
  minOverlayWidth.current = min;
173
+ iconSize.current = getIconSize(_label);
167
174
  }
168
175
  }
169
176
  if (isVisible) {
@@ -231,7 +238,7 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
231
238
  css: iconStyles
232
239
  }, jsx(PreferencesIcon, {
233
240
  label: label,
234
- size: "small",
241
+ size: iconSize.current,
235
242
  testId: "".concat(testId, "-icon")
236
243
  })), showLabel && jsx("span", {
237
244
  css: labelStyles,
@@ -239,6 +246,7 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
239
246
  "data-testid": "".concat(testId, "-label")
240
247
  }, label)), jsx("span", {
241
248
  css: gradientStyles,
249
+ className: OVERLAY_GRADIENT_CLASSNAME,
242
250
  "data-testid": "".concat(testId, "-gradient")
243
251
  })))));
244
252
  };
@@ -31,4 +31,12 @@ export var getOverlayWidths = function getOverlayWidths(overlayEl, labelEl) {
31
31
  max: max,
32
32
  min: min
33
33
  };
34
+ };
35
+ export var getIconSize = function getIconSize(labelEl) {
36
+ var h2FontSizePx = 20;
37
+ var fontSize = window && parseFloat(window.getComputedStyle(labelEl).fontSize);
38
+ if (!fontSize || fontSize < h2FontSizePx) {
39
+ return 'small';
40
+ }
41
+ return 'medium';
34
42
  };
@@ -1,3 +1,4 @@
1
+ import type { Size } from '@atlaskit/icon';
1
2
  /**
2
3
  * Find a child element inside a ref.
3
4
  */
@@ -16,3 +17,4 @@ export declare const getOverlayWidths: (overlayEl: HTMLElement, labelEl: HTMLEle
16
17
  max: number;
17
18
  min: number;
18
19
  };
20
+ export declare const getIconSize: (labelEl: HTMLElement) => Size;
@@ -1,3 +1,4 @@
1
+ import type { Size } from '@atlaskit/icon';
1
2
  /**
2
3
  * Find a child element inside a ref.
3
4
  */
@@ -16,3 +17,4 @@ export declare const getOverlayWidths: (overlayEl: HTMLElement, labelEl: HTMLEle
16
17
  max: number;
17
18
  min: number;
18
19
  };
20
+ export declare const getIconSize: (labelEl: HTMLElement) => Size;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,7 +35,7 @@
35
35
  "@atlaskit/adf-schema": "^35.2.0",
36
36
  "@atlaskit/analytics-next": "^9.1.0",
37
37
  "@atlaskit/custom-steps": "^0.0.10",
38
- "@atlaskit/editor-common": "^76.33.0",
38
+ "@atlaskit/editor-common": "^76.34.0",
39
39
  "@atlaskit/editor-plugin-analytics": "^0.4.0",
40
40
  "@atlaskit/editor-plugin-decorations": "^0.2.0",
41
41
  "@atlaskit/editor-plugin-feature-flags": "^1.0.0",
@@ -44,13 +44,13 @@
44
44
  "@atlaskit/editor-plugin-hyperlink": "^0.6.0",
45
45
  "@atlaskit/editor-plugin-width": "^0.2.0",
46
46
  "@atlaskit/editor-prosemirror": "1.1.0",
47
- "@atlaskit/editor-shared-styles": "^2.8.0",
47
+ "@atlaskit/editor-shared-styles": "^2.9.0",
48
48
  "@atlaskit/frontend-utilities": "^2.7.0",
49
49
  "@atlaskit/icon": "^22.0.0",
50
50
  "@atlaskit/link-analytics": "^8.3.0",
51
51
  "@atlaskit/link-client-extension": "^1.8.0",
52
52
  "@atlaskit/link-datasource": "^1.19.0",
53
- "@atlaskit/linking-common": "^5.1.0",
53
+ "@atlaskit/linking-common": "^5.3.0",
54
54
  "@atlaskit/linking-types": "^8.5.0",
55
55
  "@atlaskit/platform-feature-flags": "^0.2.0",
56
56
  "@atlaskit/primitives": "^1.16.0",