@atlaskit/smart-card 20.1.0 → 20.1.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 +6 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/FlexibleCard/components/common/loading-skeleton/index.js +6 -4
- package/dist/cjs/view/HoverCard/components/HoverCardContent.js +23 -9
- package/dist/cjs/view/HoverCard/components/HoverCardLoadingView.js +46 -0
- package/dist/cjs/view/HoverCard/styled.js +10 -4
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/FlexibleCard/components/common/loading-skeleton/index.js +38 -31
- package/dist/es2019/view/HoverCard/components/HoverCardContent.js +22 -9
- package/dist/es2019/view/HoverCard/components/HoverCardLoadingView.js +32 -0
- package/dist/es2019/view/HoverCard/styled.js +12 -1
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/FlexibleCard/components/common/loading-skeleton/index.js +6 -3
- package/dist/esm/view/HoverCard/components/HoverCardContent.js +22 -9
- package/dist/esm/view/HoverCard/components/HoverCardLoadingView.js +31 -0
- package/dist/esm/view/HoverCard/styled.js +6 -3
- package/dist/types/view/FlexibleCard/components/common/loading-skeleton/types.d.ts +8 -0
- package/dist/types/view/HoverCard/components/HoverCardLoadingView.d.ts +4 -0
- package/dist/types/view/HoverCard/styled.d.ts +3 -0
- package/dist/types/view/HoverCard/types.d.ts +6 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/cjs/version.json
CHANGED
|
@@ -17,11 +17,13 @@ var _tokens = require("@atlaskit/tokens");
|
|
|
17
17
|
|
|
18
18
|
var _templateObject, _templateObject2;
|
|
19
19
|
|
|
20
|
-
var animationNameStyles = (0, _core.keyframes)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n 0% { background-position: -20px 0; }\n 100% { background-position: 20px 0; }\n"])));
|
|
21
|
-
var styles = (0, _core.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n border-radius: 2px;\n user-select: none;\n background: ", ";\n // TODO: https://product-fabric.atlassian.net/browse/DSP-4236\n background-image: linear-gradient(\n to right,\n ", " 0%,\n ", " 20%,\n ", " 40%,\n ", "100%\n );\n background-repeat: no-repeat;\n background-size: 280% 100%;\n display: inline-block;\n\n animation-duration: 1s;\n animation-fill-mode: forwards;\n animation-iteration-count: infinite;\n animation-name: ", ";\n animation-timing-function: linear;\n"])), (0, _tokens.token)('color.skeleton.subtle', '#f6f7f8'), (0, _tokens.token)('color.skeleton.subtle', '#f6f7f8'), (0, _tokens.token)('color.skeleton', '#edeef1'), (0, _tokens.token)('color.skeleton.subtle', '#f6f7f8'), (0, _tokens.token)('color.skeleton.subtle', '#f6f7f8'), animationNameStyles);
|
|
22
|
-
|
|
23
20
|
var LoadingSkeleton = function LoadingSkeleton(_ref) {
|
|
24
|
-
var testId = _ref.testId
|
|
21
|
+
var testId = _ref.testId,
|
|
22
|
+
width = _ref.width,
|
|
23
|
+
height = _ref.height;
|
|
24
|
+
var animationWidth = width ? "".concat(width, "rem") : '20px';
|
|
25
|
+
var animationNameStyles = (0, _core.keyframes)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n 0% { background-position: -", " 0; }\n 100% { background-position: ", " 0; }\n "])), animationWidth, animationWidth);
|
|
26
|
+
var styles = (0, _core.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n width: ", "rem;\n height: ", "rem;\n border-radius: 2px;\n user-select: none;\n background: ", ";\n // TODO: https://product-fabric.atlassian.net/browse/DSP-4236\n background-image: linear-gradient(\n to right,\n ", " 0%,\n ", " 20%,\n ", " 40%,\n ", "100%\n );\n background-repeat: no-repeat;\n background-size: 280% 100%;\n display: inline-block;\n\n animation-duration: 1s;\n animation-fill-mode: forwards;\n animation-iteration-count: infinite;\n animation-name: ", ";\n animation-timing-function: linear;\n "])), width, height, (0, _tokens.token)('color.skeleton.subtle', '#f6f7f8'), (0, _tokens.token)('color.skeleton.subtle', '#f6f7f8'), (0, _tokens.token)('color.skeleton', '#edeef1'), (0, _tokens.token)('color.skeleton.subtle', '#f6f7f8'), (0, _tokens.token)('color.skeleton.subtle', '#f6f7f8'), animationNameStyles);
|
|
25
27
|
return (0, _core.jsx)("span", {
|
|
26
28
|
css: styles,
|
|
27
29
|
"data-testid": testId
|
|
@@ -35,6 +35,8 @@ var _styled = require("../styled");
|
|
|
35
35
|
|
|
36
36
|
var _utils2 = require("../utils");
|
|
37
37
|
|
|
38
|
+
var _HoverCardLoadingView = _interopRequireDefault(require("./HoverCardLoadingView"));
|
|
39
|
+
|
|
38
40
|
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); }
|
|
39
41
|
|
|
40
42
|
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; }
|
|
@@ -125,21 +127,33 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
125
127
|
|
|
126
128
|
var titleMaxLines = subtitle && subtitle.length > 0 ? 1 : 2;
|
|
127
129
|
var body = data && (0, _extractPreview.default)(data) ? /*#__PURE__*/_react.default.createElement(_blocks.PreviewBlock, null) : /*#__PURE__*/_react.default.createElement(_blocks.SnippetBlock, null);
|
|
128
|
-
|
|
129
|
-
cardState: cardState,
|
|
130
|
-
onClick: onClick,
|
|
131
|
-
onResolve: onResolve,
|
|
132
|
-
renderers: renderers,
|
|
133
|
-
ui: _styled.flexibleUiOptions,
|
|
134
|
-
url: url
|
|
135
|
-
}, /*#__PURE__*/_react.default.createElement(_blocks.TitleBlock, {
|
|
130
|
+
var titleBlockProps = {
|
|
136
131
|
actions: titleActions,
|
|
137
132
|
maxLines: titleMaxLines,
|
|
138
133
|
overrideCss: _styled.titleBlockCss,
|
|
139
134
|
size: _constants.SmartLinkSize.Large,
|
|
140
135
|
position: _constants.SmartLinkPosition.Center,
|
|
141
136
|
subtitle: subtitle
|
|
142
|
-
}
|
|
137
|
+
};
|
|
138
|
+
var flexibleCardProps = {
|
|
139
|
+
cardState: cardState,
|
|
140
|
+
onClick: onClick,
|
|
141
|
+
onResolve: onResolve,
|
|
142
|
+
renderers: renderers,
|
|
143
|
+
ui: _styled.flexibleUiOptions,
|
|
144
|
+
url: url,
|
|
145
|
+
children: {}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
if (cardState.metadataStatus === 'pending') {
|
|
149
|
+
return /*#__PURE__*/_react.default.createElement(_HoverCardLoadingView.default, {
|
|
150
|
+
flexibleCardProps: flexibleCardProps,
|
|
151
|
+
titleBlockProps: titleBlockProps
|
|
152
|
+
});
|
|
153
|
+
} // if metadataStatus is 'errored' simply render using data available (normal path)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
return /*#__PURE__*/_react.default.createElement(_FlexibleCard.default, flexibleCardProps, /*#__PURE__*/_react.default.createElement(_blocks.TitleBlock, titleBlockProps), /*#__PURE__*/_react.default.createElement(_blocks.MetadataBlock, {
|
|
143
157
|
primary: primary,
|
|
144
158
|
secondary: secondary,
|
|
145
159
|
size: _constants.SmartLinkSize.Large,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _core = require("@emotion/core");
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
14
|
+
var _loadingSkeleton = _interopRequireDefault(require("../../FlexibleCard/components/common/loading-skeleton"));
|
|
15
|
+
|
|
16
|
+
var _FlexibleCard = _interopRequireDefault(require("../../FlexibleCard"));
|
|
17
|
+
|
|
18
|
+
var _blocks = require("../../FlexibleCard/components/blocks");
|
|
19
|
+
|
|
20
|
+
var _styled = require("../styled");
|
|
21
|
+
|
|
22
|
+
/** @jsx jsx */
|
|
23
|
+
var HoverCardLoadingView = function HoverCardLoadingView(_ref) {
|
|
24
|
+
var flexibleCardProps = _ref.flexibleCardProps,
|
|
25
|
+
titleBlockProps = _ref.titleBlockProps;
|
|
26
|
+
var lineHeightRem = 1.25;
|
|
27
|
+
var skeletonWidth = _styled.CARD_WIDTH_REM - 2;
|
|
28
|
+
return (0, _core.jsx)("div", {
|
|
29
|
+
css: _styled.loadingViewContainer,
|
|
30
|
+
"data-testid": "hover-card-loading-view"
|
|
31
|
+
}, (0, _core.jsx)(_FlexibleCard.default, flexibleCardProps, (0, _core.jsx)(_blocks.TitleBlock, titleBlockProps)), (0, _core.jsx)("div", {
|
|
32
|
+
css: _styled.skeletonContainer
|
|
33
|
+
}, (0, _core.jsx)("span", null), (0, _core.jsx)(_loadingSkeleton.default, {
|
|
34
|
+
width: skeletonWidth,
|
|
35
|
+
height: lineHeightRem
|
|
36
|
+
}), (0, _core.jsx)(_loadingSkeleton.default, {
|
|
37
|
+
width: skeletonWidth,
|
|
38
|
+
height: lineHeightRem * 3
|
|
39
|
+
}), (0, _core.jsx)(_loadingSkeleton.default, {
|
|
40
|
+
width: skeletonWidth,
|
|
41
|
+
height: lineHeightRem
|
|
42
|
+
})));
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
var _default = HoverCardLoadingView;
|
|
46
|
+
exports.default = _default;
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.titleBlockCss = exports.metadataBlockCss = exports.footerBlockCss = exports.flexibleUiOptions = exports.HoverCardContainer = void 0;
|
|
8
|
+
exports.titleBlockCss = exports.skeletonContainer = exports.metadataBlockCss = exports.loadingViewContainer = exports.footerBlockCss = exports.flexibleUiOptions = exports.HoverCardContainer = exports.CARD_WIDTH_REM = void 0;
|
|
9
9
|
|
|
10
10
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
11
11
|
|
|
@@ -15,7 +15,7 @@ var _index = require("../../index");
|
|
|
15
15
|
|
|
16
16
|
var _constants = require("../../constants");
|
|
17
17
|
|
|
18
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
18
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
19
19
|
|
|
20
20
|
var flexibleUiOptions = {
|
|
21
21
|
hideElevation: true,
|
|
@@ -25,14 +25,20 @@ var flexibleUiOptions = {
|
|
|
25
25
|
hidePadding: true
|
|
26
26
|
};
|
|
27
27
|
exports.flexibleUiOptions = flexibleUiOptions;
|
|
28
|
+
var CARD_WIDTH_REM = 24;
|
|
29
|
+
exports.CARD_WIDTH_REM = CARD_WIDTH_REM;
|
|
28
30
|
var blockGap = '0.5rem';
|
|
29
31
|
var elementGap = '0.5rem';
|
|
30
32
|
var separatorCss = (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n [data-separator] + [data-separator]:before {\n margin-right: ", ";\n }\n"])), elementGap);
|
|
31
|
-
var HoverCardContainer = (0, _core.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n background: none;\n border-width: 0;\n box-sizing: border-box;\n width:
|
|
33
|
+
var HoverCardContainer = (0, _core.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n background: none;\n border-width: 0;\n box-sizing: border-box;\n width: ", "rem;\n padding: 1rem;\n\n .", " {\n display: none;\n }\n"])), CARD_WIDTH_REM, _index.loadingPlaceholderClassName);
|
|
32
34
|
exports.HoverCardContainer = HoverCardContainer;
|
|
33
35
|
var titleBlockCss = (0, _core.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n gap: ", ";\n\n ", "\n\n // title and subtitle element group\n [data-smart-element-group] {\n // gap between title and subtitle\n gap: 0.06rem;\n\n /* subtitle element group */\n > [data-smart-element-group] {\n > span {\n margin-right: ", ";\n }\n }\n }\n"])), blockGap, separatorCss, elementGap);
|
|
34
36
|
exports.titleBlockCss = titleBlockCss;
|
|
35
37
|
var metadataBlockCss = (0, _core.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n gap: 0px;\n\n /* primary element group */\n [data-smart-element-group]:nth-of-type(1) {\n flex-grow: 7;\n\n // a separator between text-based element\n ", "\n\n /* horizontal spacing between elements in group */\n > span {\n margin-right: ", ";\n }\n }\n /* secondary element group */\n [data-smart-element-group]:nth-of-type(2) {\n flex-grow: 3;\n /* horizontal spacing between elements in group */\n > span {\n margin-left: ", ";\n }\n }\n"])), separatorCss, elementGap, elementGap);
|
|
36
38
|
exports.metadataBlockCss = metadataBlockCss;
|
|
37
39
|
var footerBlockCss = (0, _core.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n padding-top: 0.25rem;\n"])));
|
|
38
|
-
exports.footerBlockCss = footerBlockCss;
|
|
40
|
+
exports.footerBlockCss = footerBlockCss;
|
|
41
|
+
var loadingViewContainer = (0, _core.css)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n"])));
|
|
42
|
+
exports.loadingViewContainer = loadingViewContainer;
|
|
43
|
+
var skeletonContainer = (0, _core.css)(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n gap: 0.625rem;\n align-items: center;\n"])));
|
|
44
|
+
exports.skeletonContainer = skeletonContainer;
|
package/dist/es2019/version.json
CHANGED
|
@@ -2,38 +2,45 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { css, jsx, keyframes } from '@emotion/core';
|
|
4
4
|
import { token } from '@atlaskit/tokens';
|
|
5
|
-
const animationNameStyles = keyframes`
|
|
6
|
-
0% { background-position: -20px 0; }
|
|
7
|
-
100% { background-position: 20px 0; }
|
|
8
|
-
`;
|
|
9
|
-
const styles = css`
|
|
10
|
-
border-radius: 2px;
|
|
11
|
-
user-select: none;
|
|
12
|
-
background: ${token('color.skeleton.subtle', '#f6f7f8')};
|
|
13
|
-
// TODO: https://product-fabric.atlassian.net/browse/DSP-4236
|
|
14
|
-
background-image: linear-gradient(
|
|
15
|
-
to right,
|
|
16
|
-
${token('color.skeleton.subtle', '#f6f7f8')} 0%,
|
|
17
|
-
${token('color.skeleton', '#edeef1')} 20%,
|
|
18
|
-
${token('color.skeleton.subtle', '#f6f7f8')} 40%,
|
|
19
|
-
${token('color.skeleton.subtle', '#f6f7f8')}100%
|
|
20
|
-
);
|
|
21
|
-
background-repeat: no-repeat;
|
|
22
|
-
background-size: 280% 100%;
|
|
23
|
-
display: inline-block;
|
|
24
|
-
|
|
25
|
-
animation-duration: 1s;
|
|
26
|
-
animation-fill-mode: forwards;
|
|
27
|
-
animation-iteration-count: infinite;
|
|
28
|
-
animation-name: ${animationNameStyles};
|
|
29
|
-
animation-timing-function: linear;
|
|
30
|
-
`;
|
|
31
5
|
|
|
32
6
|
const LoadingSkeleton = ({
|
|
33
|
-
testId
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
7
|
+
testId,
|
|
8
|
+
width,
|
|
9
|
+
height
|
|
10
|
+
}) => {
|
|
11
|
+
const animationWidth = width ? `${width}rem` : '20px';
|
|
12
|
+
const animationNameStyles = keyframes`
|
|
13
|
+
0% { background-position: -${animationWidth} 0; }
|
|
14
|
+
100% { background-position: ${animationWidth} 0; }
|
|
15
|
+
`;
|
|
16
|
+
const styles = css`
|
|
17
|
+
width: ${width}rem;
|
|
18
|
+
height: ${height}rem;
|
|
19
|
+
border-radius: 2px;
|
|
20
|
+
user-select: none;
|
|
21
|
+
background: ${token('color.skeleton.subtle', '#f6f7f8')};
|
|
22
|
+
// TODO: https://product-fabric.atlassian.net/browse/DSP-4236
|
|
23
|
+
background-image: linear-gradient(
|
|
24
|
+
to right,
|
|
25
|
+
${token('color.skeleton.subtle', '#f6f7f8')} 0%,
|
|
26
|
+
${token('color.skeleton', '#edeef1')} 20%,
|
|
27
|
+
${token('color.skeleton.subtle', '#f6f7f8')} 40%,
|
|
28
|
+
${token('color.skeleton.subtle', '#f6f7f8')}100%
|
|
29
|
+
);
|
|
30
|
+
background-repeat: no-repeat;
|
|
31
|
+
background-size: 280% 100%;
|
|
32
|
+
display: inline-block;
|
|
33
|
+
|
|
34
|
+
animation-duration: 1s;
|
|
35
|
+
animation-fill-mode: forwards;
|
|
36
|
+
animation-iteration-count: infinite;
|
|
37
|
+
animation-name: ${animationNameStyles};
|
|
38
|
+
animation-timing-function: linear;
|
|
39
|
+
`;
|
|
40
|
+
return jsx("span", {
|
|
41
|
+
css: styles,
|
|
42
|
+
"data-testid": testId
|
|
43
|
+
});
|
|
44
|
+
};
|
|
38
45
|
|
|
39
46
|
export default LoadingSkeleton;
|
|
@@ -11,6 +11,7 @@ import FlexibleCard from '../../FlexibleCard';
|
|
|
11
11
|
import { FooterBlock, MetadataBlock, PreviewBlock, SnippetBlock, TitleBlock } from '../../FlexibleCard/components/blocks';
|
|
12
12
|
import { flexibleUiOptions, footerBlockCss, metadataBlockCss, titleBlockCss } from '../styled';
|
|
13
13
|
import { getSimulatedMetadata, SMART_CARD_ANALYTICS_DISPLAY } from '../utils';
|
|
14
|
+
import HoverCardLoadingView from './HoverCardLoadingView';
|
|
14
15
|
export const getOpenAction = (url, analytics, onActionClick) => ({
|
|
15
16
|
name: ActionName.CustomAction,
|
|
16
17
|
icon: /*#__PURE__*/React.createElement(ShortcutIcon, {
|
|
@@ -79,21 +80,33 @@ const HoverCardContent = ({
|
|
|
79
80
|
} = extractMetadata(getSimulatedMetadata(extensionKey, types));
|
|
80
81
|
const titleMaxLines = subtitle && subtitle.length > 0 ? 1 : 2;
|
|
81
82
|
const body = data && extractPreview(data) ? /*#__PURE__*/React.createElement(PreviewBlock, null) : /*#__PURE__*/React.createElement(SnippetBlock, null);
|
|
82
|
-
|
|
83
|
-
cardState: cardState,
|
|
84
|
-
onClick: onClick,
|
|
85
|
-
onResolve: onResolve,
|
|
86
|
-
renderers: renderers,
|
|
87
|
-
ui: flexibleUiOptions,
|
|
88
|
-
url: url
|
|
89
|
-
}, /*#__PURE__*/React.createElement(TitleBlock, {
|
|
83
|
+
const titleBlockProps = {
|
|
90
84
|
actions: titleActions,
|
|
91
85
|
maxLines: titleMaxLines,
|
|
92
86
|
overrideCss: titleBlockCss,
|
|
93
87
|
size: SmartLinkSize.Large,
|
|
94
88
|
position: SmartLinkPosition.Center,
|
|
95
89
|
subtitle: subtitle
|
|
96
|
-
}
|
|
90
|
+
};
|
|
91
|
+
const flexibleCardProps = {
|
|
92
|
+
cardState: cardState,
|
|
93
|
+
onClick: onClick,
|
|
94
|
+
onResolve: onResolve,
|
|
95
|
+
renderers: renderers,
|
|
96
|
+
ui: flexibleUiOptions,
|
|
97
|
+
url: url,
|
|
98
|
+
children: {}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
if (cardState.metadataStatus === 'pending') {
|
|
102
|
+
return /*#__PURE__*/React.createElement(HoverCardLoadingView, {
|
|
103
|
+
flexibleCardProps: flexibleCardProps,
|
|
104
|
+
titleBlockProps: titleBlockProps
|
|
105
|
+
});
|
|
106
|
+
} // if metadataStatus is 'errored' simply render using data available (normal path)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
return /*#__PURE__*/React.createElement(FlexibleCard, flexibleCardProps, /*#__PURE__*/React.createElement(TitleBlock, titleBlockProps), /*#__PURE__*/React.createElement(MetadataBlock, {
|
|
97
110
|
primary: primary,
|
|
98
111
|
secondary: secondary,
|
|
99
112
|
size: SmartLinkSize.Large,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/core';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import LoadingSkeleton from '../../FlexibleCard/components/common/loading-skeleton';
|
|
5
|
+
import FlexibleCard from '../../FlexibleCard';
|
|
6
|
+
import { TitleBlock } from '../../FlexibleCard/components/blocks';
|
|
7
|
+
import { CARD_WIDTH_REM, loadingViewContainer, skeletonContainer } from '../styled';
|
|
8
|
+
|
|
9
|
+
const HoverCardLoadingView = ({
|
|
10
|
+
flexibleCardProps,
|
|
11
|
+
titleBlockProps
|
|
12
|
+
}) => {
|
|
13
|
+
const lineHeightRem = 1.25;
|
|
14
|
+
const skeletonWidth = CARD_WIDTH_REM - 2;
|
|
15
|
+
return jsx("div", {
|
|
16
|
+
css: loadingViewContainer,
|
|
17
|
+
"data-testid": "hover-card-loading-view"
|
|
18
|
+
}, jsx(FlexibleCard, flexibleCardProps, jsx(TitleBlock, titleBlockProps)), jsx("div", {
|
|
19
|
+
css: skeletonContainer
|
|
20
|
+
}, jsx("span", null), jsx(LoadingSkeleton, {
|
|
21
|
+
width: skeletonWidth,
|
|
22
|
+
height: lineHeightRem
|
|
23
|
+
}), jsx(LoadingSkeleton, {
|
|
24
|
+
width: skeletonWidth,
|
|
25
|
+
height: lineHeightRem * 3
|
|
26
|
+
}), jsx(LoadingSkeleton, {
|
|
27
|
+
width: skeletonWidth,
|
|
28
|
+
height: lineHeightRem
|
|
29
|
+
})));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default HoverCardLoadingView;
|
|
@@ -8,6 +8,7 @@ export const flexibleUiOptions = {
|
|
|
8
8
|
theme: SmartLinkTheme.Black,
|
|
9
9
|
hidePadding: true
|
|
10
10
|
};
|
|
11
|
+
export const CARD_WIDTH_REM = 24;
|
|
11
12
|
const blockGap = '0.5rem';
|
|
12
13
|
const elementGap = '0.5rem';
|
|
13
14
|
const separatorCss = css`
|
|
@@ -19,7 +20,7 @@ export const HoverCardContainer = css`
|
|
|
19
20
|
background: none;
|
|
20
21
|
border-width: 0;
|
|
21
22
|
box-sizing: border-box;
|
|
22
|
-
width:
|
|
23
|
+
width: ${CARD_WIDTH_REM}rem;
|
|
23
24
|
padding: 1rem;
|
|
24
25
|
|
|
25
26
|
.${loadingPlaceholderClassName} {
|
|
@@ -70,4 +71,14 @@ export const metadataBlockCss = css`
|
|
|
70
71
|
`;
|
|
71
72
|
export const footerBlockCss = css`
|
|
72
73
|
padding-top: 0.25rem;
|
|
74
|
+
`;
|
|
75
|
+
export const loadingViewContainer = css`
|
|
76
|
+
display: flex;
|
|
77
|
+
flex-direction: column;
|
|
78
|
+
`;
|
|
79
|
+
export const skeletonContainer = css`
|
|
80
|
+
display: flex;
|
|
81
|
+
flex-direction: column;
|
|
82
|
+
gap: 0.625rem;
|
|
83
|
+
align-items: center;
|
|
73
84
|
`;
|
package/dist/esm/version.json
CHANGED
|
@@ -6,11 +6,14 @@ var _templateObject, _templateObject2;
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { css, jsx, keyframes } from '@emotion/core';
|
|
8
8
|
import { token } from '@atlaskit/tokens';
|
|
9
|
-
var animationNameStyles = keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 0% { background-position: -20px 0; }\n 100% { background-position: 20px 0; }\n"])));
|
|
10
|
-
var styles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n border-radius: 2px;\n user-select: none;\n background: ", ";\n // TODO: https://product-fabric.atlassian.net/browse/DSP-4236\n background-image: linear-gradient(\n to right,\n ", " 0%,\n ", " 20%,\n ", " 40%,\n ", "100%\n );\n background-repeat: no-repeat;\n background-size: 280% 100%;\n display: inline-block;\n\n animation-duration: 1s;\n animation-fill-mode: forwards;\n animation-iteration-count: infinite;\n animation-name: ", ";\n animation-timing-function: linear;\n"])), token('color.skeleton.subtle', '#f6f7f8'), token('color.skeleton.subtle', '#f6f7f8'), token('color.skeleton', '#edeef1'), token('color.skeleton.subtle', '#f6f7f8'), token('color.skeleton.subtle', '#f6f7f8'), animationNameStyles);
|
|
11
9
|
|
|
12
10
|
var LoadingSkeleton = function LoadingSkeleton(_ref) {
|
|
13
|
-
var testId = _ref.testId
|
|
11
|
+
var testId = _ref.testId,
|
|
12
|
+
width = _ref.width,
|
|
13
|
+
height = _ref.height;
|
|
14
|
+
var animationWidth = width ? "".concat(width, "rem") : '20px';
|
|
15
|
+
var animationNameStyles = keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 0% { background-position: -", " 0; }\n 100% { background-position: ", " 0; }\n "])), animationWidth, animationWidth);
|
|
16
|
+
var styles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: ", "rem;\n height: ", "rem;\n border-radius: 2px;\n user-select: none;\n background: ", ";\n // TODO: https://product-fabric.atlassian.net/browse/DSP-4236\n background-image: linear-gradient(\n to right,\n ", " 0%,\n ", " 20%,\n ", " 40%,\n ", "100%\n );\n background-repeat: no-repeat;\n background-size: 280% 100%;\n display: inline-block;\n\n animation-duration: 1s;\n animation-fill-mode: forwards;\n animation-iteration-count: infinite;\n animation-name: ", ";\n animation-timing-function: linear;\n "])), width, height, token('color.skeleton.subtle', '#f6f7f8'), token('color.skeleton.subtle', '#f6f7f8'), token('color.skeleton', '#edeef1'), token('color.skeleton.subtle', '#f6f7f8'), token('color.skeleton.subtle', '#f6f7f8'), animationNameStyles);
|
|
14
17
|
return jsx("span", {
|
|
15
18
|
css: styles,
|
|
16
19
|
"data-testid": testId
|
|
@@ -11,6 +11,7 @@ import FlexibleCard from '../../FlexibleCard';
|
|
|
11
11
|
import { FooterBlock, MetadataBlock, PreviewBlock, SnippetBlock, TitleBlock } from '../../FlexibleCard/components/blocks';
|
|
12
12
|
import { flexibleUiOptions, footerBlockCss, metadataBlockCss, titleBlockCss } from '../styled';
|
|
13
13
|
import { getSimulatedMetadata, SMART_CARD_ANALYTICS_DISPLAY } from '../utils';
|
|
14
|
+
import HoverCardLoadingView from './HoverCardLoadingView';
|
|
14
15
|
export var getOpenAction = function getOpenAction(url, analytics, onActionClick) {
|
|
15
16
|
return {
|
|
16
17
|
name: ActionName.CustomAction,
|
|
@@ -92,21 +93,33 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
92
93
|
|
|
93
94
|
var titleMaxLines = subtitle && subtitle.length > 0 ? 1 : 2;
|
|
94
95
|
var body = data && extractPreview(data) ? /*#__PURE__*/React.createElement(PreviewBlock, null) : /*#__PURE__*/React.createElement(SnippetBlock, null);
|
|
95
|
-
|
|
96
|
-
cardState: cardState,
|
|
97
|
-
onClick: onClick,
|
|
98
|
-
onResolve: onResolve,
|
|
99
|
-
renderers: renderers,
|
|
100
|
-
ui: flexibleUiOptions,
|
|
101
|
-
url: url
|
|
102
|
-
}, /*#__PURE__*/React.createElement(TitleBlock, {
|
|
96
|
+
var titleBlockProps = {
|
|
103
97
|
actions: titleActions,
|
|
104
98
|
maxLines: titleMaxLines,
|
|
105
99
|
overrideCss: titleBlockCss,
|
|
106
100
|
size: SmartLinkSize.Large,
|
|
107
101
|
position: SmartLinkPosition.Center,
|
|
108
102
|
subtitle: subtitle
|
|
109
|
-
}
|
|
103
|
+
};
|
|
104
|
+
var flexibleCardProps = {
|
|
105
|
+
cardState: cardState,
|
|
106
|
+
onClick: onClick,
|
|
107
|
+
onResolve: onResolve,
|
|
108
|
+
renderers: renderers,
|
|
109
|
+
ui: flexibleUiOptions,
|
|
110
|
+
url: url,
|
|
111
|
+
children: {}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
if (cardState.metadataStatus === 'pending') {
|
|
115
|
+
return /*#__PURE__*/React.createElement(HoverCardLoadingView, {
|
|
116
|
+
flexibleCardProps: flexibleCardProps,
|
|
117
|
+
titleBlockProps: titleBlockProps
|
|
118
|
+
});
|
|
119
|
+
} // if metadataStatus is 'errored' simply render using data available (normal path)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
return /*#__PURE__*/React.createElement(FlexibleCard, flexibleCardProps, /*#__PURE__*/React.createElement(TitleBlock, titleBlockProps), /*#__PURE__*/React.createElement(MetadataBlock, {
|
|
110
123
|
primary: primary,
|
|
111
124
|
secondary: secondary,
|
|
112
125
|
size: SmartLinkSize.Large,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/core';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import LoadingSkeleton from '../../FlexibleCard/components/common/loading-skeleton';
|
|
5
|
+
import FlexibleCard from '../../FlexibleCard';
|
|
6
|
+
import { TitleBlock } from '../../FlexibleCard/components/blocks';
|
|
7
|
+
import { CARD_WIDTH_REM, loadingViewContainer, skeletonContainer } from '../styled';
|
|
8
|
+
|
|
9
|
+
var HoverCardLoadingView = function HoverCardLoadingView(_ref) {
|
|
10
|
+
var flexibleCardProps = _ref.flexibleCardProps,
|
|
11
|
+
titleBlockProps = _ref.titleBlockProps;
|
|
12
|
+
var lineHeightRem = 1.25;
|
|
13
|
+
var skeletonWidth = CARD_WIDTH_REM - 2;
|
|
14
|
+
return jsx("div", {
|
|
15
|
+
css: loadingViewContainer,
|
|
16
|
+
"data-testid": "hover-card-loading-view"
|
|
17
|
+
}, jsx(FlexibleCard, flexibleCardProps, jsx(TitleBlock, titleBlockProps)), jsx("div", {
|
|
18
|
+
css: skeletonContainer
|
|
19
|
+
}, jsx("span", null), jsx(LoadingSkeleton, {
|
|
20
|
+
width: skeletonWidth,
|
|
21
|
+
height: lineHeightRem
|
|
22
|
+
}), jsx(LoadingSkeleton, {
|
|
23
|
+
width: skeletonWidth,
|
|
24
|
+
height: lineHeightRem * 3
|
|
25
|
+
}), jsx(LoadingSkeleton, {
|
|
26
|
+
width: skeletonWidth,
|
|
27
|
+
height: lineHeightRem
|
|
28
|
+
})));
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default HoverCardLoadingView;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
2
|
|
|
3
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
4
4
|
|
|
5
5
|
import { css } from '@emotion/core';
|
|
6
6
|
import { loadingPlaceholderClassName } from '../../index';
|
|
@@ -12,10 +12,13 @@ export var flexibleUiOptions = {
|
|
|
12
12
|
theme: SmartLinkTheme.Black,
|
|
13
13
|
hidePadding: true
|
|
14
14
|
};
|
|
15
|
+
export var CARD_WIDTH_REM = 24;
|
|
15
16
|
var blockGap = '0.5rem';
|
|
16
17
|
var elementGap = '0.5rem';
|
|
17
18
|
var separatorCss = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n [data-separator] + [data-separator]:before {\n margin-right: ", ";\n }\n"])), elementGap);
|
|
18
|
-
export var HoverCardContainer = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n background: none;\n border-width: 0;\n box-sizing: border-box;\n width:
|
|
19
|
+
export var HoverCardContainer = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n background: none;\n border-width: 0;\n box-sizing: border-box;\n width: ", "rem;\n padding: 1rem;\n\n .", " {\n display: none;\n }\n"])), CARD_WIDTH_REM, loadingPlaceholderClassName);
|
|
19
20
|
export var titleBlockCss = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n gap: ", ";\n\n ", "\n\n // title and subtitle element group\n [data-smart-element-group] {\n // gap between title and subtitle\n gap: 0.06rem;\n\n /* subtitle element group */\n > [data-smart-element-group] {\n > span {\n margin-right: ", ";\n }\n }\n }\n"])), blockGap, separatorCss, elementGap);
|
|
20
21
|
export var metadataBlockCss = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n gap: 0px;\n\n /* primary element group */\n [data-smart-element-group]:nth-of-type(1) {\n flex-grow: 7;\n\n // a separator between text-based element\n ", "\n\n /* horizontal spacing between elements in group */\n > span {\n margin-right: ", ";\n }\n }\n /* secondary element group */\n [data-smart-element-group]:nth-of-type(2) {\n flex-grow: 3;\n /* horizontal spacing between elements in group */\n > span {\n margin-left: ", ";\n }\n }\n"])), separatorCss, elementGap, elementGap);
|
|
21
|
-
export var footerBlockCss = css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n padding-top: 0.25rem;\n"])));
|
|
22
|
+
export var footerBlockCss = css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n padding-top: 0.25rem;\n"])));
|
|
23
|
+
export var loadingViewContainer = css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n"])));
|
|
24
|
+
export var skeletonContainer = css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n gap: 0.625rem;\n align-items: center;\n"])));
|
|
@@ -5,4 +5,12 @@ export declare type LoadingSkeletonProps = {
|
|
|
5
5
|
* code, serving as a hook for automated tests
|
|
6
6
|
*/
|
|
7
7
|
testId?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Width of the loading skeleton, defaults to width of the parent element
|
|
10
|
+
*/
|
|
11
|
+
width?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Height of loading skeleton, defaults to height of the parent element
|
|
14
|
+
*/
|
|
15
|
+
height?: number;
|
|
8
16
|
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { FlexibleUiOptions } from '../FlexibleCard/types';
|
|
2
2
|
export declare const flexibleUiOptions: FlexibleUiOptions;
|
|
3
|
+
export declare const CARD_WIDTH_REM = 24;
|
|
3
4
|
export declare const HoverCardContainer: import("@emotion/utils").SerializedStyles;
|
|
4
5
|
export declare const titleBlockCss: import("@emotion/utils").SerializedStyles;
|
|
5
6
|
export declare const metadataBlockCss: import("@emotion/utils").SerializedStyles;
|
|
6
7
|
export declare const footerBlockCss: import("@emotion/utils").SerializedStyles;
|
|
8
|
+
export declare const loadingViewContainer: import("@emotion/utils").SerializedStyles;
|
|
9
|
+
export declare const skeletonContainer: import("@emotion/utils").SerializedStyles;
|
|
@@ -6,6 +6,8 @@ import { CardState } from '@atlaskit/linking-common';
|
|
|
6
6
|
import { CardProviderRenderers } from '@atlaskit/link-provider';
|
|
7
7
|
import { AnalyticsHandler } from '../../utils/types';
|
|
8
8
|
import { ReactElement } from 'react';
|
|
9
|
+
import { TitleBlockProps } from '../FlexibleCard/components/blocks/title-block/types';
|
|
10
|
+
import { FlexibleCardProps } from '../FlexibleCard/types';
|
|
9
11
|
export interface HoverCardProps extends WithAnalyticsEventsProps {
|
|
10
12
|
id?: string;
|
|
11
13
|
url: string;
|
|
@@ -32,3 +34,7 @@ export declare type HoverCardContentProps = {
|
|
|
32
34
|
onResolve: () => void;
|
|
33
35
|
url: string;
|
|
34
36
|
};
|
|
37
|
+
export declare type HoverCardLoadingViewProps = {
|
|
38
|
+
flexibleCardProps: FlexibleCardProps;
|
|
39
|
+
titleBlockProps: TitleBlockProps;
|
|
40
|
+
};
|