@eeacms/volto-hero-block 3.0.1 → 5.0.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.
- package/CHANGELOG.md +32 -13
- package/package.json +3 -2
- package/src/components/Blocks/Hero/Hero.jsx +6 -1
- package/src/components/Blocks/Hero/schema.js +28 -13
- package/src/hooks.js +31 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,38 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
### [5.0.0](https://github.com/eea/volto-hero-block/compare/4.0.0...5.0.0) - 7 March 2023
|
|
8
|
+
|
|
9
|
+
#### :nail_care: Enhancements
|
|
10
|
+
|
|
11
|
+
- change(hero): Performance improvement by lazy loading image #15 from eea/performance_lazy_image [ichim-david - [`2c61703`](https://github.com/eea/volto-hero-block/commit/2c617034158a0c6bd7fb7a12f71d13f2664021d2)]
|
|
12
|
+
|
|
13
|
+
#### :house: Internal changes
|
|
14
|
+
|
|
15
|
+
- chore(import): Use absolute import [Alin Voinea - [`317feb0`](https://github.com/eea/volto-hero-block/commit/317feb0341c1b2d16fdee61f3dcb3d661d973820)]
|
|
16
|
+
|
|
17
|
+
#### :hammer_and_wrench: Others
|
|
18
|
+
|
|
19
|
+
- Release 5.0.0 [Alin Voinea - [`fb56e6c`](https://github.com/eea/volto-hero-block/commit/fb56e6c3b68d1bec5e346bf156e1408df4a567fe)]
|
|
20
|
+
- fix onScreen hook error #16 from eea/fix-onscreen-hook [ichim-david - [`9123541`](https://github.com/eea/volto-hero-block/commit/91235413f423d7e6c4788d70b687b3ed5d4884b4)]
|
|
21
|
+
- no need for comments [andreiggr - [`a14f9c3`](https://github.com/eea/volto-hero-block/commit/a14f9c3bdddfa22e6b4bbc8318f0ca5bdc9c2d38)]
|
|
22
|
+
- fix hook [andreiggr - [`f7fae73`](https://github.com/eea/volto-hero-block/commit/f7fae73007f79af2f06da1d9b72a53ad86fef4ac)]
|
|
23
|
+
- eslint [andreiggr - [`68451b7`](https://github.com/eea/volto-hero-block/commit/68451b725420015fbd5b695e97b8742988d49913)]
|
|
24
|
+
- lazy load huge img on first 10px [andreiggr - [`67dc7d3`](https://github.com/eea/volto-hero-block/commit/67dc7d3475188d692e053032c2639dd1a585c029)]
|
|
25
|
+
- lazy load huge bgimage wip [andreiggr - [`86e45ec`](https://github.com/eea/volto-hero-block/commit/86e45ece842f1cd7452920dffa3a9b4aea945f56)]
|
|
26
|
+
## [4.0.0](https://github.com/eea/volto-hero-block/compare/3.0.1...4.0.0) - 7 February 2023
|
|
27
|
+
|
|
28
|
+
#### :nail_care: Enhancements
|
|
29
|
+
|
|
30
|
+
- change(theme): color_picker widget for themes #12 from eea/color_pick_themes [ichim-david - [`d3e0e92`](https://github.com/eea/volto-hero-block/commit/d3e0e9266795b09d465cc00bff752040c8274bd8)]
|
|
31
|
+
|
|
32
|
+
#### :hammer_and_wrench: Others
|
|
33
|
+
|
|
34
|
+
- Release 4.0.0 [Alin Voinea - [`4f211df`](https://github.com/eea/volto-hero-block/commit/4f211df1c6488d1d70f009b592b828575ee783d6)]
|
|
35
|
+
- lint fix [David Ichim - [`1a51209`](https://github.com/eea/volto-hero-block/commit/1a51209dbaec1b9aa1a7e16f3d997dcf5fa8f764)]
|
|
36
|
+
- more theme_picker [Andrei Grigore - [`801ead1`](https://github.com/eea/volto-hero-block/commit/801ead1355eeb4a4fea371b84b91db3e651d7a40)]
|
|
37
|
+
- add theme_picker widget [Andrei Grigore - [`aef11f7`](https://github.com/eea/volto-hero-block/commit/aef11f7c26c3e2ec5d997ede076062bf9d23237c)]
|
|
38
|
+
- color_picker widget for themes [andreiggr - [`4037c24`](https://github.com/eea/volto-hero-block/commit/4037c24b850b5f514a2bafba156fd7888678cea5)]
|
|
7
39
|
### [3.0.1](https://github.com/eea/volto-hero-block/compare/3.0.0...3.0.1) - 27 January 2023
|
|
8
40
|
|
|
9
41
|
#### :rocket: New Features
|
|
@@ -16,7 +48,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
16
48
|
|
|
17
49
|
#### :hammer_and_wrench: Others
|
|
18
50
|
|
|
19
|
-
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`ab85c7b`](https://github.com/eea/volto-hero-block/commit/ab85c7bd5bd1e3aec95e02f9b4d026b1203d5739)]
|
|
20
51
|
## [3.0.0](https://github.com/eea/volto-hero-block/compare/2.1.0...3.0.0) - 22 December 2022
|
|
21
52
|
|
|
22
53
|
#### :rocket: New Features
|
|
@@ -25,11 +56,8 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
25
56
|
|
|
26
57
|
#### :hammer_and_wrench: Others
|
|
27
58
|
|
|
28
|
-
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`f06f58c`](https://github.com/eea/volto-hero-block/commit/f06f58c7cd4cfc15a03208e9c7a4e31fe2eba2f6)]
|
|
29
|
-
- Add Sonarqube tag using climate-energy-frontend addons list [EEA Jenkins - [`20e5bcb`](https://github.com/eea/volto-hero-block/commit/20e5bcb3c4dd538595741928319c3204c5d18f8c)]
|
|
30
59
|
- Cosmetics [Alin Voinea - [`9dac70c`](https://github.com/eea/volto-hero-block/commit/9dac70c0a3bea8e188ede9123f4f99de8e0f6987)]
|
|
31
60
|
- test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`2d4005f`](https://github.com/eea/volto-hero-block/commit/2d4005f0f31b121e1b7d2e94414f3dff92ec1a16)]
|
|
32
|
-
- Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`2931fcc`](https://github.com/eea/volto-hero-block/commit/2931fccbee5f8e117e5ae9095ba57e63e465ddb3)]
|
|
33
61
|
### [2.1.0](https://github.com/eea/volto-hero-block/compare/2.0.0...2.1.0) - 12 December 2022
|
|
34
62
|
|
|
35
63
|
#### :bug: Bug Fixes
|
|
@@ -38,12 +66,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
38
66
|
|
|
39
67
|
#### :hammer_and_wrench: Others
|
|
40
68
|
|
|
41
|
-
- Add Sonarqube tag using bise-frontend addons list [EEA Jenkins - [`93be4f9`](https://github.com/eea/volto-hero-block/commit/93be4f96fb72cacfc25f9b058cb379d80060ee13)]
|
|
42
|
-
- yarn 3 [Alin Voinea - [`8e2dccd`](https://github.com/eea/volto-hero-block/commit/8e2dccd47cbef3c0871407baa376ce61c540c754)]
|
|
43
|
-
- Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`6bc3af3`](https://github.com/eea/volto-hero-block/commit/6bc3af35b4edf07971d1b0ce1648965e8d6e3bc0)]
|
|
44
|
-
- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`d7dbbd2`](https://github.com/eea/volto-hero-block/commit/d7dbbd21277dd76bf59d91a4dc8e022b2a6ff99c)]
|
|
45
|
-
- Add Sonarqube tag using demo-kitkat-frontend addons list [EEA Jenkins - [`3c1f0d6`](https://github.com/eea/volto-hero-block/commit/3c1f0d6e7f8e5318aee3413ec3687d8492376f9d)]
|
|
46
|
-
- Add Sonarqube tag using forests-frontend addons list [EEA Jenkins - [`843017a`](https://github.com/eea/volto-hero-block/commit/843017aa7dbea71cc7888663496e352d287440b4)]
|
|
47
69
|
## [2.0.0](https://github.com/eea/volto-hero-block/compare/1.0.0...2.0.0) - 16 November 2022
|
|
48
70
|
|
|
49
71
|
#### :nail_care: Enhancements
|
|
@@ -53,7 +75,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
53
75
|
#### :hammer_and_wrench: Others
|
|
54
76
|
|
|
55
77
|
- test(estlint): Fix .project.eslintrc.js [Alin Voinea - [`b8f0971`](https://github.com/eea/volto-hero-block/commit/b8f0971b21a5334d40c1b8f5103cea61d9ffe6f1)]
|
|
56
|
-
- Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`581dedf`](https://github.com/eea/volto-hero-block/commit/581dedf07410ef2ca09e6ddaa05fbf176400adbb)]
|
|
57
78
|
## [1.0.0](https://github.com/eea/volto-hero-block/compare/0.2.0...1.0.0) - 28 October 2022
|
|
58
79
|
|
|
59
80
|
#### :nail_care: Enhancements
|
|
@@ -65,7 +86,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
65
86
|
- Remove cypress.json [Alin Voinea - [`593bdf2`](https://github.com/eea/volto-hero-block/commit/593bdf207ca4fd3f2393117b6f64a44727881ad0)]
|
|
66
87
|
- test(cypress): Upgrade to Cypress 10 / Razzle 4 [Alin Voinea - [`edd48a5`](https://github.com/eea/volto-hero-block/commit/edd48a5c13824bce5e03e46790f1890656b340d8)]
|
|
67
88
|
- Cleanup [Alin Voinea - [`9d72ee7`](https://github.com/eea/volto-hero-block/commit/9d72ee7a06d1c6fed46586d30bb85eae39e670bf)]
|
|
68
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`95986d0`](https://github.com/eea/volto-hero-block/commit/95986d0b8fd5c3cbb9e6da9059f71e066a8e171b)]
|
|
69
89
|
### [0.2.0](https://github.com/eea/volto-hero-block/compare/0.1.4...0.2.0) - 6 July 2022
|
|
70
90
|
|
|
71
91
|
#### :bug: Bug Fixes
|
|
@@ -104,7 +124,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
104
124
|
- Update slate footnote support [Miu Razvan - [`c1522b4`](https://github.com/eea/volto-hero-block/commit/c1522b4164dbe6de01771d211d7e0bf3009f44d4)]
|
|
105
125
|
- Use justify content for text and button as well [Miu Razvan - [`08599cc`](https://github.com/eea/volto-hero-block/commit/08599cc45546d9b349128c4f8ce9c01318385811)]
|
|
106
126
|
- Add dependencies [Miu Razvan - [`30e2881`](https://github.com/eea/volto-hero-block/commit/30e2881a2a97a899e7f4cc614a0405c300ac6fee)]
|
|
107
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`b415422`](https://github.com/eea/volto-hero-block/commit/b41542285edd29440a324b101a4dbae9334830bf)]
|
|
108
127
|
### 0.1.0 - 10 June 2022
|
|
109
128
|
|
|
110
129
|
#### :hammer_and_wrench: Others
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-hero-block",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "@eeacms/volto-hero-block: Volto add-on",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "European Environment Agency: IDM2 A-Team",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"@eeacms/volto-object-widget"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@eeacms/volto-object-widget": "*"
|
|
23
|
+
"@eeacms/volto-object-widget": "*",
|
|
24
|
+
"@eeacms/volto-widget-theme-picker": "^1.0.1"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
27
|
"@cypress/code-coverage": "^3.10.0",
|
|
@@ -3,6 +3,7 @@ import cx from 'classnames';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { isInternalURL } from '@plone/volto/helpers/Url/Url';
|
|
5
5
|
import { isImageGif } from '@eeacms/volto-hero-block/helpers';
|
|
6
|
+
import { useOnScreen } from '@eeacms/volto-hero-block/hooks';
|
|
6
7
|
|
|
7
8
|
Hero.propTypes = {
|
|
8
9
|
image: PropTypes.string,
|
|
@@ -30,6 +31,9 @@ function Hero({
|
|
|
30
31
|
const isExternal = !isInternalURL(image);
|
|
31
32
|
const { alignContent = 'center', backgroundVariant = 'primary' } =
|
|
32
33
|
styles || {};
|
|
34
|
+
|
|
35
|
+
const bgImgRef = React.useRef();
|
|
36
|
+
const onScreen = useOnScreen(bgImgRef);
|
|
33
37
|
return (
|
|
34
38
|
<div
|
|
35
39
|
className={cx(
|
|
@@ -59,8 +63,9 @@ function Hero({
|
|
|
59
63
|
>
|
|
60
64
|
<div
|
|
61
65
|
className={cx('hero-block-image', styles?.bg)}
|
|
66
|
+
ref={bgImgRef}
|
|
62
67
|
style={
|
|
63
|
-
image
|
|
68
|
+
image && onScreen
|
|
64
69
|
? {
|
|
65
70
|
backgroundImage: isExternal
|
|
66
71
|
? `url(${image})`
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { addStyling } from '@plone/volto/helpers';
|
|
2
|
+
import config from '@plone/volto/registry';
|
|
2
3
|
|
|
3
4
|
import alignTopSVG from '@plone/volto/icons/move-up.svg';
|
|
4
5
|
import alignCenterSVG from '@plone/volto/icons/row.svg';
|
|
@@ -126,11 +127,15 @@ export const stylingSchema = (props) => {
|
|
|
126
127
|
},
|
|
127
128
|
backgroundVariant: {
|
|
128
129
|
title: 'Background theme',
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
widget: 'theme_picker',
|
|
131
|
+
colors: [
|
|
132
|
+
...(config.settings && config.settings.themeColors
|
|
133
|
+
? config.settings.themeColors.map(({ value, title }) => ({
|
|
134
|
+
name: value,
|
|
135
|
+
label: title,
|
|
136
|
+
}))
|
|
137
|
+
: []),
|
|
138
|
+
//and add extra ones here
|
|
134
139
|
],
|
|
135
140
|
},
|
|
136
141
|
alignContent: {
|
|
@@ -149,18 +154,28 @@ export const stylingSchema = (props) => {
|
|
|
149
154
|
},
|
|
150
155
|
textVariant: {
|
|
151
156
|
title: 'Text theme',
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
157
|
+
widget: 'theme_picker',
|
|
158
|
+
colors: [
|
|
159
|
+
...(config.settings && config.settings.themeColors
|
|
160
|
+
? config.settings.themeColors.map(({ value, title }) => ({
|
|
161
|
+
name: value,
|
|
162
|
+
label: title,
|
|
163
|
+
}))
|
|
164
|
+
: []),
|
|
165
|
+
//and add extra ones here
|
|
156
166
|
],
|
|
157
167
|
},
|
|
158
168
|
buttonVariant: {
|
|
159
169
|
title: 'Button theme',
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
170
|
+
widget: 'theme_picker',
|
|
171
|
+
colors: [
|
|
172
|
+
...(config.settings && config.settings.themeColors
|
|
173
|
+
? config.settings.themeColors.map(({ value, title }) => ({
|
|
174
|
+
name: value,
|
|
175
|
+
label: title,
|
|
176
|
+
}))
|
|
177
|
+
: []),
|
|
178
|
+
//and add extra ones here
|
|
164
179
|
],
|
|
165
180
|
},
|
|
166
181
|
buttonAlign: {
|
package/src/hooks.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
function useOnScreen(ref, rootMargin = '0px') {
|
|
5
|
+
const [isIntersecting, setIntersecting] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
React.useEffect(() => {
|
|
8
|
+
const observer = new IntersectionObserver(
|
|
9
|
+
([entry]) => {
|
|
10
|
+
setIntersecting(entry.isIntersecting);
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
rootMargin,
|
|
14
|
+
threshold: 0,
|
|
15
|
+
root: null,
|
|
16
|
+
},
|
|
17
|
+
);
|
|
18
|
+
if (ref?.current) {
|
|
19
|
+
observer.observe(ref.current);
|
|
20
|
+
}
|
|
21
|
+
return () => {
|
|
22
|
+
if (ref?.current) {
|
|
23
|
+
observer.unobserve(ref.current);
|
|
24
|
+
}
|
|
25
|
+
observer.disconnect();
|
|
26
|
+
};
|
|
27
|
+
}, [ref, rootMargin]);
|
|
28
|
+
return isIntersecting;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { useOnScreen };
|