gatsby-core-theme 5.0.0 → 5.0.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 +11 -0
- package/package.json +1 -1
- package/src/hooks/lazy-image/index.js +34 -46
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## [5.0.1](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v5.0.0...v5.0.1) (2022-03-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* google bot images ([53fc90c](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/53fc90c24cc7bacc9d5911fb05c29dae611fbc1f))
|
|
7
|
+
* lazy image tests ([ef63ea8](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/ef63ea88cd2ff7b3dac335afd30e75e872cdff61))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
* Merge branch 'tm-2743-googlebot-images' into 'master' ([2156666](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/21566661cd703480bb5e58bba9b2b6e1ecb49121))
|
|
11
|
+
|
|
1
12
|
# [5.0.0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v4.0.0...v5.0.0) (2022-03-01)
|
|
2
13
|
|
|
3
14
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
2
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import
|
|
4
|
+
import LazyLoad from 'react-lazyload';
|
|
5
5
|
import { isNativeImageLazyLoadingSupported } from '~helpers/device-detect';
|
|
6
6
|
|
|
7
7
|
export default function LazyImage({
|
|
@@ -15,56 +15,44 @@ export default function LazyImage({
|
|
|
15
15
|
loading = 'lazy',
|
|
16
16
|
}) {
|
|
17
17
|
const [errorImage, setErrorImage] = useState(false);
|
|
18
|
+
const [nonNativeLazyLoaded, setNonNativeLazyLoaded] = useState(false);
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
setNonNativeLazyLoaded(!isNativeImageLazyLoadingSupported());
|
|
22
|
+
}, []);
|
|
18
23
|
|
|
19
24
|
if ((defaultImg && !src) || errorImage === true) {
|
|
20
25
|
return defaultImg;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
className={className}
|
|
36
|
-
height={height}
|
|
37
|
-
width={width}
|
|
38
|
-
alt={alt}
|
|
39
|
-
style={style}
|
|
40
|
-
/>
|
|
41
|
-
</LazyLoad>
|
|
42
|
-
<noscript>
|
|
43
|
-
<img
|
|
44
|
-
src={src}
|
|
45
|
-
className={className}
|
|
46
|
-
height={height}
|
|
47
|
-
width={width}
|
|
48
|
-
alt={alt}
|
|
49
|
-
style={style}
|
|
50
|
-
/>
|
|
51
|
-
</noscript>
|
|
52
|
-
</>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return (
|
|
28
|
+
return !nonNativeLazyLoaded ? (
|
|
29
|
+
<img
|
|
30
|
+
src={src}
|
|
31
|
+
loading={loading}
|
|
32
|
+
className={className}
|
|
33
|
+
height={height}
|
|
34
|
+
width={width}
|
|
35
|
+
alt={alt}
|
|
36
|
+
style={style}
|
|
37
|
+
onError={() => setErrorImage(true)}
|
|
38
|
+
/>
|
|
39
|
+
) : (
|
|
57
40
|
<>
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
41
|
+
<LazyLoad
|
|
42
|
+
height={height ? `${height}px` : null}
|
|
43
|
+
width={width ? `${width}px` : null}
|
|
44
|
+
placeholder={<span className="lazyload-placeholder" />}
|
|
45
|
+
debounce={0}
|
|
46
|
+
>
|
|
47
|
+
<img
|
|
48
|
+
src={src}
|
|
49
|
+
className={className}
|
|
50
|
+
height={height}
|
|
51
|
+
width={width}
|
|
52
|
+
alt={alt}
|
|
53
|
+
style={style}
|
|
54
|
+
/>
|
|
55
|
+
</LazyLoad>
|
|
68
56
|
<noscript>
|
|
69
57
|
<img
|
|
70
58
|
src={src}
|