@pingux/astro 1.30.0-alpha.5 → 1.30.0
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.
@@ -93,8 +93,8 @@ var Image = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
93
93
|
|
94
94
|
var _useState5 = (0, _react.useState)(false),
|
95
95
|
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
96
|
-
|
97
|
-
|
96
|
+
shouldShowFallback = _useState6[0],
|
97
|
+
setShouldShowFallback = _useState6[1]; // we need to use useRef here with useState so it will be updated in setTimeout and onload
|
98
98
|
// https://github.com/facebook/react/issues/14010#issuecomment-433788147
|
99
99
|
|
100
100
|
|
@@ -106,7 +106,7 @@ var Image = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
106
106
|
};
|
107
107
|
|
108
108
|
var setImgSrc = function setImgSrc() {
|
109
|
-
if (!loadedSuccessfully && !(isLoadingRef !== null && isLoadingRef !== void 0 && isLoadingRef.current) ||
|
109
|
+
if (!loadedSuccessfully && !(isLoadingRef !== null && isLoadingRef !== void 0 && isLoadingRef.current) || shouldShowFallback) {
|
110
110
|
return fallbackImage;
|
111
111
|
}
|
112
112
|
|
@@ -115,7 +115,7 @@ var Image = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
115
115
|
|
116
116
|
var imgSrc = (0, _react.useMemo)(function () {
|
117
117
|
return setImgSrc();
|
118
|
-
}, [src, isLoading,
|
118
|
+
}, [src, isLoading, shouldShowFallback]);
|
119
119
|
var imgRef = (0, _react.useRef)();
|
120
120
|
/* istanbul ignore next */
|
121
121
|
|
@@ -146,12 +146,13 @@ var Image = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
146
146
|
|
147
147
|
var onImageError = function onImageError() {
|
148
148
|
setIsLoadingWithRef(false);
|
149
|
+
setShouldShowFallback(true);
|
149
150
|
};
|
150
151
|
|
151
152
|
var onFallbackTimeout = function onFallbackTimeout() {
|
152
153
|
if (isLoadingRef !== null && isLoadingRef !== void 0 && isLoadingRef.current) {
|
153
154
|
setIsLoadingWithRef(false);
|
154
|
-
|
155
|
+
setShouldShowFallback(true);
|
155
156
|
}
|
156
157
|
};
|
157
158
|
|
@@ -179,9 +180,9 @@ var Image = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
179
180
|
};
|
180
181
|
|
181
182
|
var themeUiImage = (0, _react2.jsx)(_themeUi.Image, (0, _extends2["default"])({
|
183
|
+
alt: alt,
|
182
184
|
className: classNames,
|
183
185
|
ref: imgRef,
|
184
|
-
alt: alt,
|
185
186
|
role: "img",
|
186
187
|
src: imgSrc,
|
187
188
|
sx: sx
|
@@ -155,11 +155,12 @@ var wrapper = {
|
|
155
155
|
var lineNo = {
|
156
156
|
display: 'table-cell',
|
157
157
|
userSelect: 'none',
|
158
|
-
|
158
|
+
px: 5,
|
159
159
|
m: '0 10px 0 0',
|
160
160
|
bg: 'accent.30',
|
161
161
|
minWidth: 26,
|
162
|
-
color: 'white'
|
162
|
+
color: 'white',
|
163
|
+
lineHeight: '20px'
|
163
164
|
};
|
164
165
|
var _default = {
|
165
166
|
theme: theme,
|
@@ -57,8 +57,8 @@ var Image = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
57
57
|
|
58
58
|
var _useState5 = useState(false),
|
59
59
|
_useState6 = _slicedToArray(_useState5, 2),
|
60
|
-
|
61
|
-
|
60
|
+
shouldShowFallback = _useState6[0],
|
61
|
+
setShouldShowFallback = _useState6[1]; // we need to use useRef here with useState so it will be updated in setTimeout and onload
|
62
62
|
// https://github.com/facebook/react/issues/14010#issuecomment-433788147
|
63
63
|
|
64
64
|
|
@@ -70,7 +70,7 @@ var Image = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
70
70
|
};
|
71
71
|
|
72
72
|
var setImgSrc = function setImgSrc() {
|
73
|
-
if (!loadedSuccessfully && !(isLoadingRef !== null && isLoadingRef !== void 0 && isLoadingRef.current) ||
|
73
|
+
if (!loadedSuccessfully && !(isLoadingRef !== null && isLoadingRef !== void 0 && isLoadingRef.current) || shouldShowFallback) {
|
74
74
|
return fallbackImage;
|
75
75
|
}
|
76
76
|
|
@@ -79,7 +79,7 @@ var Image = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
79
79
|
|
80
80
|
var imgSrc = useMemo(function () {
|
81
81
|
return setImgSrc();
|
82
|
-
}, [src, isLoading,
|
82
|
+
}, [src, isLoading, shouldShowFallback]);
|
83
83
|
var imgRef = useRef();
|
84
84
|
/* istanbul ignore next */
|
85
85
|
|
@@ -110,12 +110,13 @@ var Image = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
110
110
|
|
111
111
|
var onImageError = function onImageError() {
|
112
112
|
setIsLoadingWithRef(false);
|
113
|
+
setShouldShowFallback(true);
|
113
114
|
};
|
114
115
|
|
115
116
|
var onFallbackTimeout = function onFallbackTimeout() {
|
116
117
|
if (isLoadingRef !== null && isLoadingRef !== void 0 && isLoadingRef.current) {
|
117
118
|
setIsLoadingWithRef(false);
|
118
|
-
|
119
|
+
setShouldShowFallback(true);
|
119
120
|
}
|
120
121
|
};
|
121
122
|
|
@@ -143,9 +144,9 @@ var Image = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
143
144
|
};
|
144
145
|
|
145
146
|
var themeUiImage = ___EmotionJSX(ThemeUIImage, _extends({
|
147
|
+
alt: alt,
|
146
148
|
className: classNames,
|
147
149
|
ref: imgRef,
|
148
|
-
alt: alt,
|
149
150
|
role: "img",
|
150
151
|
src: imgSrc,
|
151
152
|
sx: sx
|
@@ -146,11 +146,12 @@ var wrapper = {
|
|
146
146
|
var lineNo = {
|
147
147
|
display: 'table-cell',
|
148
148
|
userSelect: 'none',
|
149
|
-
|
149
|
+
px: 5,
|
150
150
|
m: '0 10px 0 0',
|
151
151
|
bg: 'accent.30',
|
152
152
|
minWidth: 26,
|
153
|
-
color: 'white'
|
153
|
+
color: 'white',
|
154
|
+
lineHeight: '20px'
|
154
155
|
};
|
155
156
|
export default {
|
156
157
|
theme: theme,
|