@teambit/preview.ui.preview-placeholder 0.0.506 → 0.0.508
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/dist/preview-placeholder.js +12 -17
- package/dist/preview-placeholder.js.map +1 -1
- package/dist/preview-placeholder.module.scss +1 -0
- package/package.json +5 -5
- package/preview-placeholder.module.scss +1 -0
- package/preview-placeholder.tsx +13 -19
- /package/dist/{preview-1704178234226.js → preview-1704347596257.js} +0 -0
|
@@ -64,14 +64,20 @@ function getDescription(component) {
|
|
|
64
64
|
return descriptionItem.value || '';
|
|
65
65
|
}
|
|
66
66
|
exports.getDescription = getDescription;
|
|
67
|
-
function PreviewPlaceholder(
|
|
68
|
-
var
|
|
67
|
+
function PreviewPlaceholder(_a) {
|
|
68
|
+
var _b;
|
|
69
|
+
var { component, componentDescriptor, Container = ({ children, className }) => react_1.default.createElement("div", { className: className }, children), shouldShowPreview = ((_b = component === null || component === void 0 ? void 0 : component.compositions.length) !== null && _b !== void 0 ? _b : 0) > 0 && (component === null || component === void 0 ? void 0 : component.buildStatus) !== 'pending', } = _a;
|
|
70
|
+
const compositions = component === null || component === void 0 ? void 0 : component.compositions;
|
|
71
|
+
const description = componentDescriptor && getDescription(componentDescriptor);
|
|
72
|
+
const displayName = componentDescriptor && getDisplayName(componentDescriptor);
|
|
73
|
+
const selectedPreview = (0, react_1.useMemo)(() => {
|
|
74
|
+
if (!shouldShowPreview || !component)
|
|
75
|
+
return undefined;
|
|
76
|
+
return selectDefaultComposition(component);
|
|
77
|
+
}, [component, shouldShowPreview]);
|
|
69
78
|
if (!component || !componentDescriptor)
|
|
70
79
|
return null;
|
|
71
|
-
|
|
72
|
-
const description = getDescription(componentDescriptor);
|
|
73
|
-
const displayName = getDisplayName(componentDescriptor);
|
|
74
|
-
if (!compositions || !compositions.length || ((_a = component.buildStatus) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== 'succeed') {
|
|
80
|
+
if (!shouldShowPreview || !compositions || !compositions.length) {
|
|
75
81
|
return (react_1.default.createElement(Container, { className: preview_placeholder_module_scss_1.default.noPreview, component: component },
|
|
76
82
|
react_1.default.createElement("div", { className: preview_placeholder_module_scss_1.default.scope },
|
|
77
83
|
react_1.default.createElement(design_ui_heading_1.H5, { className: preview_placeholder_module_scss_1.default.scopeTitle }, component.id.scope)),
|
|
@@ -79,11 +85,6 @@ function PreviewPlaceholder({ component, componentDescriptor, Container = ({ chi
|
|
|
79
85
|
react_1.default.createElement(design_ui_heading_1.H3, { className: preview_placeholder_module_scss_1.default.componentTitle }, displayName),
|
|
80
86
|
react_1.default.createElement("span", { className: preview_placeholder_module_scss_1.default.description }, description))));
|
|
81
87
|
}
|
|
82
|
-
const selectedPreview = (0, react_1.useMemo)(() => {
|
|
83
|
-
if (!shouldShowPreview)
|
|
84
|
-
return undefined;
|
|
85
|
-
return selectDefaultComposition(component);
|
|
86
|
-
}, [component, shouldShowPreview]);
|
|
87
88
|
const name = component.id.toString();
|
|
88
89
|
if (component.buildStatus === 'pending')
|
|
89
90
|
return (react_1.default.createElement("div", { className: preview_placeholder_module_scss_1.default.previewPlaceholder, "data-tip": "", "data-for": name },
|
|
@@ -92,12 +93,6 @@ function PreviewPlaceholder({ component, componentDescriptor, Container = ({ chi
|
|
|
92
93
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
93
94
|
react_1.default.createElement(compositions_1.ComponentComposition, { component: component, composition: selectedPreview, pubsub: false }),
|
|
94
95
|
react_1.default.createElement("div", { className: preview_placeholder_module_scss_1.default.previewOverlay })));
|
|
95
|
-
// return (
|
|
96
|
-
// <div className={styles.previewPlaceholder} data-tip="" data-for={name}>
|
|
97
|
-
// <Icon of="img" />
|
|
98
|
-
// <div>No preview available</div>
|
|
99
|
-
// </div>
|
|
100
|
-
// );
|
|
101
96
|
}
|
|
102
97
|
exports.PreviewPlaceholder = PreviewPlaceholder;
|
|
103
98
|
const PREVIEW_COMPOSITION_SUFFIX = 'Preview';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview-placeholder.js","sourceRoot":"","sources":["../preview-placeholder.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiE;AACjE,sEAA8F;AAC9F,kEAAoD;AACpD,kFAAgE;AAChE,gFAAyD;AAGzD,yDAAuC;
|
|
1
|
+
{"version":3,"file":"preview-placeholder.js","sourceRoot":"","sources":["../preview-placeholder.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiE;AACjE,sEAA8F;AAC9F,kEAAoD;AACpD,kFAAgE;AAChE,gFAAyD;AAGzD,yDAAuC;AAEvC,wGAAuD;AAEvD,SAAgB,eAAe,CAAC,SAA8B;IAC5D,MAAM,KAAK,GAAQ,SAAS,CAAC,GAAG,CAAC,sBAAkB,CAAC,EAAE,CAAC,CAAC;IACxD,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IACtB,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC;IAC7C,IAAI,CAAC,YAAY;QAAE,OAAO,EAAE,CAAC;IAE7B,OAAO,0BAAW,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;AAC7C,CAAC;AAPD,0CAOC;AAED,SAAgB,cAAc,CAAC,SAA8B;IAC3D,MAAM,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,sCAAU,EAAC,KAAK,CAAC,CAAC,CAAC;IAC9E,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1B,CAAC;AAHD,wCAGC;AAED,SAAS,eAAe,CAAC,SAA8B,EAAE,IAAY;;IACnE,MAAM,IAAI,GAAG,CAAA,MAAA,SAAS,CAAC,GAAG,CAAM,cAAU,CAAC,EAAE,CAAC,0CAAE,IAAI,K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C;AAnDD,gDAmDC;AAED,MAAM,0BAA0B,GAAG,SAAS,CAAC;AAE7C,SAAS,wBAAwB,CAAC,SAAyB;IACzD,MAAM,EAAE,YAAY,EAAE,GAAG,SAAS,CAAC;IAEnC,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,0BAA0B,CAAC,CAAC,CAAC;AACrF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/preview.ui.preview-placeholder",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.508",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/preview/ui/preview-placeholder",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.preview",
|
|
8
8
|
"name": "ui/preview-placeholder",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.508"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"core-js": "^3.0.0",
|
|
13
13
|
"@teambit/design.ui.heading": "1.0.16",
|
|
14
14
|
"@teambit/evangelist.elements.icon": "1.0.2",
|
|
15
|
-
"@teambit/component-descriptor": "0.0.
|
|
16
|
-
"@teambit/toolbox.string.capitalize": "0.0.
|
|
15
|
+
"@teambit/component-descriptor": "0.0.412",
|
|
16
|
+
"@teambit/toolbox.string.capitalize": "0.0.496"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/react": "^17.0.8",
|
|
@@ -49,4 +49,4 @@
|
|
|
49
49
|
"angular",
|
|
50
50
|
"angular-components"
|
|
51
51
|
]
|
|
52
|
-
}
|
|
52
|
+
}
|
package/preview-placeholder.tsx
CHANGED
|
@@ -6,6 +6,7 @@ import { Icon } from '@teambit/evangelist.elements.icon';
|
|
|
6
6
|
import { ComponentModel } from '@teambit/component';
|
|
7
7
|
import { ComponentDescriptor } from '@teambit/component-descriptor';
|
|
8
8
|
import DocsAspect from '@teambit/docs';
|
|
9
|
+
|
|
9
10
|
import styles from './preview-placeholder.module.scss';
|
|
10
11
|
|
|
11
12
|
export function getCompositions(component: ComponentDescriptor) {
|
|
@@ -39,20 +40,25 @@ export function PreviewPlaceholder({
|
|
|
39
40
|
component,
|
|
40
41
|
componentDescriptor,
|
|
41
42
|
Container = ({ children, className }) => <div className={className}>{children}</div>,
|
|
42
|
-
shouldShowPreview =
|
|
43
|
+
shouldShowPreview = (component?.compositions.length ?? 0) > 0 && component?.buildStatus !== 'pending',
|
|
43
44
|
}: {
|
|
44
45
|
component?: ComponentModel;
|
|
45
46
|
componentDescriptor?: ComponentDescriptor;
|
|
46
47
|
Container?: ComponentType<{ component: any; children: ReactNode; className: string }>;
|
|
47
48
|
shouldShowPreview?: boolean;
|
|
48
49
|
}) {
|
|
49
|
-
|
|
50
|
+
const compositions = component?.compositions;
|
|
51
|
+
const description = componentDescriptor && getDescription(componentDescriptor);
|
|
52
|
+
const displayName = componentDescriptor && getDisplayName(componentDescriptor);
|
|
50
53
|
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
const selectedPreview = useMemo(() => {
|
|
55
|
+
if (!shouldShowPreview || !component) return undefined;
|
|
56
|
+
return selectDefaultComposition(component);
|
|
57
|
+
}, [component, shouldShowPreview]);
|
|
58
|
+
|
|
59
|
+
if (!component || !componentDescriptor) return null;
|
|
54
60
|
|
|
55
|
-
if (!
|
|
61
|
+
if (!shouldShowPreview || !compositions || !compositions.length) {
|
|
56
62
|
return (
|
|
57
63
|
<Container className={styles.noPreview} component={component}>
|
|
58
64
|
<div className={styles.scope}>
|
|
@@ -65,13 +71,8 @@ export function PreviewPlaceholder({
|
|
|
65
71
|
</Container>
|
|
66
72
|
);
|
|
67
73
|
}
|
|
68
|
-
|
|
69
|
-
const selectedPreview = useMemo(() => {
|
|
70
|
-
if (!shouldShowPreview) return undefined;
|
|
71
|
-
return selectDefaultComposition(component);
|
|
72
|
-
}, [component, shouldShowPreview]);
|
|
73
|
-
|
|
74
74
|
const name = component.id.toString();
|
|
75
|
+
|
|
75
76
|
if (component.buildStatus === 'pending')
|
|
76
77
|
return (
|
|
77
78
|
<div className={styles.previewPlaceholder} data-tip="" data-for={name}>
|
|
@@ -86,13 +87,6 @@ export function PreviewPlaceholder({
|
|
|
86
87
|
<div className={styles.previewOverlay} />
|
|
87
88
|
</>
|
|
88
89
|
);
|
|
89
|
-
|
|
90
|
-
// return (
|
|
91
|
-
// <div className={styles.previewPlaceholder} data-tip="" data-for={name}>
|
|
92
|
-
// <Icon of="img" />
|
|
93
|
-
// <div>No preview available</div>
|
|
94
|
-
// </div>
|
|
95
|
-
// );
|
|
96
90
|
}
|
|
97
91
|
|
|
98
92
|
const PREVIEW_COMPOSITION_SUFFIX = 'Preview';
|
|
File without changes
|