@atlaskit/editor-plugin-card 0.15.0 → 0.15.1
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 +8 -0
- package/dist/cjs/ui/InlineCardOverlay/index.js +22 -7
- package/dist/cjs/ui/InlineCardOverlay/utils.js +9 -1
- package/dist/es2019/ui/InlineCardOverlay/index.js +25 -9
- package/dist/es2019/ui/InlineCardOverlay/utils.js +8 -0
- package/dist/esm/ui/InlineCardOverlay/index.js +24 -9
- package/dist/esm/ui/InlineCardOverlay/utils.js +8 -0
- package/dist/types/ui/InlineCardOverlay/utils.d.ts +2 -0
- package/dist/types-ts4.5/ui/InlineCardOverlay/utils.d.ts +2 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 0.15.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#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
|
|
8
|
+
- [#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
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 0.15.0
|
|
4
12
|
|
|
5
13
|
### 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,11 +32,22 @@ 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.
|
|
@@ -53,8 +67,7 @@ var overlayStyles = (0, _react2.css)({
|
|
|
53
67
|
zIndex: 2,
|
|
54
68
|
// Appearance
|
|
55
69
|
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
|
|
70
|
+
// Using `&` twice to increase specificity. (These are not nested styles.)
|
|
58
71
|
'&&:link, &&:active, &&:focus, &&:hover, &&:visited': {
|
|
59
72
|
color: "var(--ds-text-subtlest, ".concat(_colors.N700, ")"),
|
|
60
73
|
textDecoration: 'none'
|
|
@@ -67,7 +80,6 @@ var showOverlayStyles = (0, _react2.css)({
|
|
|
67
80
|
});
|
|
68
81
|
var iconStyles = (0, _react2.css)({
|
|
69
82
|
// Position icon in the middle
|
|
70
|
-
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
71
83
|
span: {
|
|
72
84
|
display: 'flex'
|
|
73
85
|
}
|
|
@@ -78,7 +90,7 @@ var labelStyles = (0, _react2.css)({
|
|
|
78
90
|
width: 'max-content'
|
|
79
91
|
});
|
|
80
92
|
var iconAndLabelStyles = (0, _react2.css)({
|
|
81
|
-
background:
|
|
93
|
+
background: SMART_LINK_BACKGROUND_COLOR,
|
|
82
94
|
display: 'flex',
|
|
83
95
|
alignItems: 'center',
|
|
84
96
|
height: '100%',
|
|
@@ -97,7 +109,7 @@ var overflowingContainerStyles = (0, _react2.css)({
|
|
|
97
109
|
var gradientStyles = (0, _react2.css)({
|
|
98
110
|
width: '2.5rem',
|
|
99
111
|
height: '100%',
|
|
100
|
-
background:
|
|
112
|
+
background: getGradientWithColor(SMART_LINK_BACKGROUND_COLOR)
|
|
101
113
|
});
|
|
102
114
|
var InlineCardOverlay = function InlineCardOverlay(_ref) {
|
|
103
115
|
var children = _ref.children,
|
|
@@ -124,6 +136,7 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
|
|
|
124
136
|
var maxOverlayWidth = (0, _react.useRef)(0);
|
|
125
137
|
var minOverlayWidth = (0, _react.useRef)(ESTIMATED_MIN_WIDTH_IN_PX);
|
|
126
138
|
var parentWidth = (0, _react.useRef)(0);
|
|
139
|
+
var iconSize = (0, _react.useRef)('small');
|
|
127
140
|
var containerRef = (0, _react.useRef)(null);
|
|
128
141
|
var setVisibility = (0, _react.useCallback)(function () {
|
|
129
142
|
if (!containerRef.current || !maxOverlayWidth.current) {
|
|
@@ -173,6 +186,7 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
|
|
|
173
186
|
min = _getOverlayWidths.min;
|
|
174
187
|
maxOverlayWidth.current = max;
|
|
175
188
|
minOverlayWidth.current = min;
|
|
189
|
+
iconSize.current = (0, _utils2.getIconSize)(_label);
|
|
176
190
|
}
|
|
177
191
|
}
|
|
178
192
|
if (isVisible) {
|
|
@@ -240,7 +254,7 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
|
|
|
240
254
|
css: iconStyles
|
|
241
255
|
}, (0, _react2.jsx)(_preferences.default, {
|
|
242
256
|
label: label,
|
|
243
|
-
size:
|
|
257
|
+
size: iconSize.current,
|
|
244
258
|
testId: "".concat(testId, "-icon")
|
|
245
259
|
})), showLabel && (0, _react2.jsx)("span", {
|
|
246
260
|
css: labelStyles,
|
|
@@ -248,6 +262,7 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
|
|
|
248
262
|
"data-testid": "".concat(testId, "-label")
|
|
249
263
|
}, label)), (0, _react2.jsx)("span", {
|
|
250
264
|
css: gradientStyles,
|
|
265
|
+
className: OVERLAY_GRADIENT_CLASSNAME,
|
|
251
266
|
"data-testid": "".concat(testId, "-gradient")
|
|
252
267
|
})))));
|
|
253
268
|
};
|
|
@@ -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,19 +10,33 @@ 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.
|
|
@@ -41,8 +56,7 @@ const overlayStyles = css({
|
|
|
41
56
|
zIndex: 2,
|
|
42
57
|
// Appearance
|
|
43
58
|
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
|
|
59
|
+
// Using `&` twice to increase specificity. (These are not nested styles.)
|
|
46
60
|
'&&:link, &&:active, &&:focus, &&:hover, &&:visited': {
|
|
47
61
|
color: `var(--ds-text-subtlest, ${N700})`,
|
|
48
62
|
textDecoration: 'none'
|
|
@@ -55,7 +69,6 @@ const showOverlayStyles = css({
|
|
|
55
69
|
});
|
|
56
70
|
const iconStyles = css({
|
|
57
71
|
// Position icon in the middle
|
|
58
|
-
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
59
72
|
span: {
|
|
60
73
|
display: 'flex'
|
|
61
74
|
}
|
|
@@ -66,7 +79,7 @@ const labelStyles = css({
|
|
|
66
79
|
width: 'max-content'
|
|
67
80
|
});
|
|
68
81
|
const iconAndLabelStyles = css({
|
|
69
|
-
background:
|
|
82
|
+
background: SMART_LINK_BACKGROUND_COLOR,
|
|
70
83
|
display: 'flex',
|
|
71
84
|
alignItems: 'center',
|
|
72
85
|
height: '100%',
|
|
@@ -85,7 +98,7 @@ const overflowingContainerStyles = css({
|
|
|
85
98
|
const gradientStyles = css({
|
|
86
99
|
width: '2.5rem',
|
|
87
100
|
height: '100%',
|
|
88
|
-
background:
|
|
101
|
+
background: getGradientWithColor(SMART_LINK_BACKGROUND_COLOR)
|
|
89
102
|
});
|
|
90
103
|
const InlineCardOverlay = ({
|
|
91
104
|
children,
|
|
@@ -101,6 +114,7 @@ const InlineCardOverlay = ({
|
|
|
101
114
|
const maxOverlayWidth = useRef(0);
|
|
102
115
|
const minOverlayWidth = useRef(ESTIMATED_MIN_WIDTH_IN_PX);
|
|
103
116
|
const parentWidth = useRef(0);
|
|
117
|
+
const iconSize = useRef('small');
|
|
104
118
|
const containerRef = useRef(null);
|
|
105
119
|
const setVisibility = useCallback(() => {
|
|
106
120
|
if (!containerRef.current || !maxOverlayWidth.current) {
|
|
@@ -151,6 +165,7 @@ const InlineCardOverlay = ({
|
|
|
151
165
|
} = getOverlayWidths(iconAndLabel, label);
|
|
152
166
|
maxOverlayWidth.current = max;
|
|
153
167
|
minOverlayWidth.current = min;
|
|
168
|
+
iconSize.current = getIconSize(label);
|
|
154
169
|
}
|
|
155
170
|
}
|
|
156
171
|
if (isVisible) {
|
|
@@ -216,7 +231,7 @@ const InlineCardOverlay = ({
|
|
|
216
231
|
css: iconStyles
|
|
217
232
|
}, jsx(PreferencesIcon, {
|
|
218
233
|
label: label,
|
|
219
|
-
size:
|
|
234
|
+
size: iconSize.current,
|
|
220
235
|
testId: `${testId}-icon`
|
|
221
236
|
})), showLabel && jsx("span", {
|
|
222
237
|
css: labelStyles,
|
|
@@ -224,6 +239,7 @@ const InlineCardOverlay = ({
|
|
|
224
239
|
"data-testid": `${testId}-label`
|
|
225
240
|
}, label)), jsx("span", {
|
|
226
241
|
css: gradientStyles,
|
|
242
|
+
className: OVERLAY_GRADIENT_CLASSNAME,
|
|
227
243
|
"data-testid": `${testId}-gradient`
|
|
228
244
|
})))));
|
|
229
245
|
};
|
|
@@ -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,19 +15,30 @@ 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.
|
|
@@ -44,8 +58,7 @@ var overlayStyles = css({
|
|
|
44
58
|
zIndex: 2,
|
|
45
59
|
// Appearance
|
|
46
60
|
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
|
|
61
|
+
// Using `&` twice to increase specificity. (These are not nested styles.)
|
|
49
62
|
'&&:link, &&:active, &&:focus, &&:hover, &&:visited': {
|
|
50
63
|
color: "var(--ds-text-subtlest, ".concat(N700, ")"),
|
|
51
64
|
textDecoration: 'none'
|
|
@@ -58,7 +71,6 @@ var showOverlayStyles = css({
|
|
|
58
71
|
});
|
|
59
72
|
var iconStyles = css({
|
|
60
73
|
// Position icon in the middle
|
|
61
|
-
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
62
74
|
span: {
|
|
63
75
|
display: 'flex'
|
|
64
76
|
}
|
|
@@ -69,7 +81,7 @@ var labelStyles = css({
|
|
|
69
81
|
width: 'max-content'
|
|
70
82
|
});
|
|
71
83
|
var iconAndLabelStyles = css({
|
|
72
|
-
background:
|
|
84
|
+
background: SMART_LINK_BACKGROUND_COLOR,
|
|
73
85
|
display: 'flex',
|
|
74
86
|
alignItems: 'center',
|
|
75
87
|
height: '100%',
|
|
@@ -88,7 +100,7 @@ var overflowingContainerStyles = css({
|
|
|
88
100
|
var gradientStyles = css({
|
|
89
101
|
width: '2.5rem',
|
|
90
102
|
height: '100%',
|
|
91
|
-
background:
|
|
103
|
+
background: getGradientWithColor(SMART_LINK_BACKGROUND_COLOR)
|
|
92
104
|
});
|
|
93
105
|
var InlineCardOverlay = function InlineCardOverlay(_ref) {
|
|
94
106
|
var children = _ref.children,
|
|
@@ -115,6 +127,7 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
|
|
|
115
127
|
var maxOverlayWidth = useRef(0);
|
|
116
128
|
var minOverlayWidth = useRef(ESTIMATED_MIN_WIDTH_IN_PX);
|
|
117
129
|
var parentWidth = useRef(0);
|
|
130
|
+
var iconSize = useRef('small');
|
|
118
131
|
var containerRef = useRef(null);
|
|
119
132
|
var setVisibility = useCallback(function () {
|
|
120
133
|
if (!containerRef.current || !maxOverlayWidth.current) {
|
|
@@ -164,6 +177,7 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
|
|
|
164
177
|
min = _getOverlayWidths.min;
|
|
165
178
|
maxOverlayWidth.current = max;
|
|
166
179
|
minOverlayWidth.current = min;
|
|
180
|
+
iconSize.current = getIconSize(_label);
|
|
167
181
|
}
|
|
168
182
|
}
|
|
169
183
|
if (isVisible) {
|
|
@@ -231,7 +245,7 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
|
|
|
231
245
|
css: iconStyles
|
|
232
246
|
}, jsx(PreferencesIcon, {
|
|
233
247
|
label: label,
|
|
234
|
-
size:
|
|
248
|
+
size: iconSize.current,
|
|
235
249
|
testId: "".concat(testId, "-icon")
|
|
236
250
|
})), showLabel && jsx("span", {
|
|
237
251
|
css: labelStyles,
|
|
@@ -239,6 +253,7 @@ var InlineCardOverlay = function InlineCardOverlay(_ref) {
|
|
|
239
253
|
"data-testid": "".concat(testId, "-label")
|
|
240
254
|
}, label)), jsx("span", {
|
|
241
255
|
css: gradientStyles,
|
|
256
|
+
className: OVERLAY_GRADIENT_CLASSNAME,
|
|
242
257
|
"data-testid": "".concat(testId, "-gradient")
|
|
243
258
|
})))));
|
|
244
259
|
};
|
|
@@ -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.
|
|
3
|
+
"version": "0.15.1",
|
|
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.
|
|
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.
|
|
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.
|
|
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",
|