skeleton-ghost-loader 2.6.5 → 2.6.6
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.
|
@@ -14,9 +14,7 @@ function getComputedStyleFromNode(node) {
|
|
|
14
14
|
if (node.props.id) el.id = node.props.id;
|
|
15
15
|
if (node.props.className) el.className = node.props.className;
|
|
16
16
|
if (node.props.style) {
|
|
17
|
-
Object.entries(node.props.style).forEach(([k, v]) =>
|
|
18
|
-
el.style[k] = v;
|
|
19
|
-
});
|
|
17
|
+
Object.entries(node.props.style).forEach(([k, v]) => el.style[k] = v);
|
|
20
18
|
}
|
|
21
19
|
el.style.display = "none";
|
|
22
20
|
document.body.appendChild(el);
|
|
@@ -27,7 +25,7 @@ function getComputedStyleFromNode(node) {
|
|
|
27
25
|
fontSize: cs.fontSize || void 0,
|
|
28
26
|
margin: cs.margin || "0",
|
|
29
27
|
padding: cs.padding || "0",
|
|
30
|
-
borderRadius: cs.borderRadius || "
|
|
28
|
+
borderRadius: cs.borderRadius || "4px"
|
|
31
29
|
};
|
|
32
30
|
document.body.removeChild(el);
|
|
33
31
|
styleCache[key] = computed;
|
|
@@ -39,7 +37,6 @@ const SkeletonBlock = ({ children }) => {
|
|
|
39
37
|
let newProps = { ...node.props };
|
|
40
38
|
let style = { ...newProps.style };
|
|
41
39
|
if (newProps.skeletonrequired === "y" && typeof node.type === "string") {
|
|
42
|
-
const type = node.type;
|
|
43
40
|
const defaults = getComputedStyleFromNode(node);
|
|
44
41
|
style.height = style.height || newProps.height || defaults.height || "20px";
|
|
45
42
|
style.width = style.width || newProps.width || defaults.width || "100%";
|
|
@@ -47,7 +44,7 @@ const SkeletonBlock = ({ children }) => {
|
|
|
47
44
|
style.margin = style.margin || newProps.margin || defaults.margin || "0";
|
|
48
45
|
style.padding = style.padding || newProps.padding || defaults.padding || "0";
|
|
49
46
|
style.borderRadius = style.borderRadius || defaults.borderRadius || "4px";
|
|
50
|
-
const isText = ["p", "span", "h1", "h2", "h3", "h4", "h5", "h6"].includes(type);
|
|
47
|
+
const isText = ["p", "span", "h1", "h2", "h3", "h4", "h5", "h6"].includes(node.type);
|
|
51
48
|
style.backgroundColor = isText ? skeletonBgColors.text : skeletonBgColors.box;
|
|
52
49
|
style.color = "transparent";
|
|
53
50
|
style.position = "relative";
|
|
@@ -59,6 +56,10 @@ const SkeletonBlock = ({ children }) => {
|
|
|
59
56
|
delete newProps.skeletonrequired;
|
|
60
57
|
newProps.style = style;
|
|
61
58
|
}
|
|
59
|
+
if (typeof node.type === "function") {
|
|
60
|
+
const element = React.createElement(node.type, node.props);
|
|
61
|
+
return traverse(element);
|
|
62
|
+
}
|
|
62
63
|
const childrenNodes = React.Children.map(node.props.children, traverse);
|
|
63
64
|
return React.cloneElement(node, newProps, childrenNodes);
|
|
64
65
|
}
|
|
@@ -16,9 +16,7 @@
|
|
|
16
16
|
if (node.props.id) el.id = node.props.id;
|
|
17
17
|
if (node.props.className) el.className = node.props.className;
|
|
18
18
|
if (node.props.style) {
|
|
19
|
-
Object.entries(node.props.style).forEach(([k, v]) =>
|
|
20
|
-
el.style[k] = v;
|
|
21
|
-
});
|
|
19
|
+
Object.entries(node.props.style).forEach(([k, v]) => el.style[k] = v);
|
|
22
20
|
}
|
|
23
21
|
el.style.display = "none";
|
|
24
22
|
document.body.appendChild(el);
|
|
@@ -29,7 +27,7 @@
|
|
|
29
27
|
fontSize: cs.fontSize || void 0,
|
|
30
28
|
margin: cs.margin || "0",
|
|
31
29
|
padding: cs.padding || "0",
|
|
32
|
-
borderRadius: cs.borderRadius || "
|
|
30
|
+
borderRadius: cs.borderRadius || "4px"
|
|
33
31
|
};
|
|
34
32
|
document.body.removeChild(el);
|
|
35
33
|
styleCache[key] = computed;
|
|
@@ -41,7 +39,6 @@
|
|
|
41
39
|
let newProps = { ...node.props };
|
|
42
40
|
let style = { ...newProps.style };
|
|
43
41
|
if (newProps.skeletonrequired === "y" && typeof node.type === "string") {
|
|
44
|
-
const type = node.type;
|
|
45
42
|
const defaults = getComputedStyleFromNode(node);
|
|
46
43
|
style.height = style.height || newProps.height || defaults.height || "20px";
|
|
47
44
|
style.width = style.width || newProps.width || defaults.width || "100%";
|
|
@@ -49,7 +46,7 @@
|
|
|
49
46
|
style.margin = style.margin || newProps.margin || defaults.margin || "0";
|
|
50
47
|
style.padding = style.padding || newProps.padding || defaults.padding || "0";
|
|
51
48
|
style.borderRadius = style.borderRadius || defaults.borderRadius || "4px";
|
|
52
|
-
const isText = ["p", "span", "h1", "h2", "h3", "h4", "h5", "h6"].includes(type);
|
|
49
|
+
const isText = ["p", "span", "h1", "h2", "h3", "h4", "h5", "h6"].includes(node.type);
|
|
53
50
|
style.backgroundColor = isText ? skeletonBgColors.text : skeletonBgColors.box;
|
|
54
51
|
style.color = "transparent";
|
|
55
52
|
style.position = "relative";
|
|
@@ -61,6 +58,10 @@
|
|
|
61
58
|
delete newProps.skeletonrequired;
|
|
62
59
|
newProps.style = style;
|
|
63
60
|
}
|
|
61
|
+
if (typeof node.type === "function") {
|
|
62
|
+
const element = React.createElement(node.type, node.props);
|
|
63
|
+
return traverse(element);
|
|
64
|
+
}
|
|
64
65
|
const childrenNodes = React.Children.map(node.props.children, traverse);
|
|
65
66
|
return React.cloneElement(node, newProps, childrenNodes);
|
|
66
67
|
}
|