skeleton-ghost-loader 2.6.4 → 2.6.5
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.
|
@@ -2,9 +2,7 @@ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
const skeletonBgColors = {
|
|
4
4
|
text: "#ccc",
|
|
5
|
-
// lighter for text/headings
|
|
6
5
|
box: "#e0e0e0"
|
|
7
|
-
// darker for boxes/images/buttons
|
|
8
6
|
};
|
|
9
7
|
const styleCache = {};
|
|
10
8
|
function getComputedStyleFromNode(node) {
|
|
@@ -40,8 +38,8 @@ const SkeletonBlock = ({ children }) => {
|
|
|
40
38
|
if (!React.isValidElement(node)) return node;
|
|
41
39
|
let newProps = { ...node.props };
|
|
42
40
|
let style = { ...newProps.style };
|
|
43
|
-
if (newProps.skeletonrequired === "y") {
|
|
44
|
-
const type =
|
|
41
|
+
if (newProps.skeletonrequired === "y" && typeof node.type === "string") {
|
|
42
|
+
const type = node.type;
|
|
45
43
|
const defaults = getComputedStyleFromNode(node);
|
|
46
44
|
style.height = style.height || newProps.height || defaults.height || "20px";
|
|
47
45
|
style.width = style.width || newProps.width || defaults.width || "100%";
|
|
@@ -61,14 +59,7 @@ const SkeletonBlock = ({ children }) => {
|
|
|
61
59
|
delete newProps.skeletonrequired;
|
|
62
60
|
newProps.style = style;
|
|
63
61
|
}
|
|
64
|
-
|
|
65
|
-
const rendered = node.type(newProps);
|
|
66
|
-
return traverse(rendered);
|
|
67
|
-
}
|
|
68
|
-
const childrenNodes = React.Children.map(
|
|
69
|
-
node.props.children,
|
|
70
|
-
(child) => traverse(child)
|
|
71
|
-
);
|
|
62
|
+
const childrenNodes = React.Children.map(node.props.children, traverse);
|
|
72
63
|
return React.cloneElement(node, newProps, childrenNodes);
|
|
73
64
|
}
|
|
74
65
|
const result = React.Children.map(children, traverse);
|
|
@@ -4,9 +4,7 @@
|
|
|
4
4
|
"use strict";
|
|
5
5
|
const skeletonBgColors = {
|
|
6
6
|
text: "#ccc",
|
|
7
|
-
// lighter for text/headings
|
|
8
7
|
box: "#e0e0e0"
|
|
9
|
-
// darker for boxes/images/buttons
|
|
10
8
|
};
|
|
11
9
|
const styleCache = {};
|
|
12
10
|
function getComputedStyleFromNode(node) {
|
|
@@ -42,8 +40,8 @@
|
|
|
42
40
|
if (!React.isValidElement(node)) return node;
|
|
43
41
|
let newProps = { ...node.props };
|
|
44
42
|
let style = { ...newProps.style };
|
|
45
|
-
if (newProps.skeletonrequired === "y") {
|
|
46
|
-
const type =
|
|
43
|
+
if (newProps.skeletonrequired === "y" && typeof node.type === "string") {
|
|
44
|
+
const type = node.type;
|
|
47
45
|
const defaults = getComputedStyleFromNode(node);
|
|
48
46
|
style.height = style.height || newProps.height || defaults.height || "20px";
|
|
49
47
|
style.width = style.width || newProps.width || defaults.width || "100%";
|
|
@@ -63,14 +61,7 @@
|
|
|
63
61
|
delete newProps.skeletonrequired;
|
|
64
62
|
newProps.style = style;
|
|
65
63
|
}
|
|
66
|
-
|
|
67
|
-
const rendered = node.type(newProps);
|
|
68
|
-
return traverse(rendered);
|
|
69
|
-
}
|
|
70
|
-
const childrenNodes = React.Children.map(
|
|
71
|
-
node.props.children,
|
|
72
|
-
(child) => traverse(child)
|
|
73
|
-
);
|
|
64
|
+
const childrenNodes = React.Children.map(node.props.children, traverse);
|
|
74
65
|
return React.cloneElement(node, newProps, childrenNodes);
|
|
75
66
|
}
|
|
76
67
|
const result = React.Children.map(children, traverse);
|