@eeacms/volto-hero-block 7.0.0 → 7.1.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 CHANGED
@@ -4,7 +4,33 @@ 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
- ### [7.0.0](https://github.com/eea/volto-hero-block/compare/6.0.1...7.0.0) - 22 April 2024
7
+ ### [7.1.0](https://github.com/eea/volto-hero-block/compare/7.0.1...7.1.0) - 28 June 2024
8
+
9
+ #### :bug: Bug Fixes
10
+
11
+ - fix(hero): default values for non boolean are set by default not defaultValue [David Ichim - [`608ec21`](https://github.com/eea/volto-hero-block/commit/608ec21f6a3c14ee0b5ec3dc6864650adc0c83bc)]
12
+
13
+ #### :nail_care: Enhancements
14
+
15
+ - change(hero): cache containerCssStyles and use it only on top level [David Ichim - [`cd666c8`](https://github.com/eea/volto-hero-block/commit/cd666c86d80d17a1acaca68fd37778976cbb607e)]
16
+
17
+ #### :house: Internal changes
18
+
19
+ - chore: package.json [alin - [`516b46f`](https://github.com/eea/volto-hero-block/commit/516b46fc82000ac4ccb4d08c6a71acd4c548385b)]
20
+
21
+ #### :hammer_and_wrench: Others
22
+
23
+ - Added back style to the divs as required by the other developers [David Ichim - [`56c6156`](https://github.com/eea/volto-hero-block/commit/56c61566a6338a0147ab7c439b21e7120d2e88e9)]
24
+ - bump package version to 7.1.0 [David Ichim - [`9f4cf35`](https://github.com/eea/volto-hero-block/commit/9f4cf3571205c578aaefcb6ffc6779e3d557f07f)]
25
+ - add height property [dorutrip - [`86b0f13`](https://github.com/eea/volto-hero-block/commit/86b0f13034d7ee3a2c21b5865250af8c5a39b3cc)]
26
+ ### [7.0.1](https://github.com/eea/volto-hero-block/compare/7.0.0...7.0.1) - 13 May 2024
27
+
28
+ #### :bug: Bug Fixes
29
+
30
+ - fix: cypress 13.1.0 [alin - [`2569c63`](https://github.com/eea/volto-hero-block/commit/2569c63e0c1ef229c0758ba918378d56b4de7a10)]
31
+ - fix: Pin dependency to volto-widget-theme-picker [alin - [`05bb2e4`](https://github.com/eea/volto-hero-block/commit/05bb2e43f166fabe9fa8426673b115c01f1e415b)]
32
+
33
+ ## [7.0.0](https://github.com/eea/volto-hero-block/compare/6.0.1...7.0.0) - 22 April 2024
8
34
 
9
35
  #### :rocket: New Features
10
36
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-hero-block",
3
- "version": "7.0.0",
3
+ "version": "7.1.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",
@@ -21,12 +21,13 @@
21
21
  ],
22
22
  "dependencies": {
23
23
  "@eeacms/volto-object-widget": "*",
24
- "@eeacms/volto-widget-theme-picker": "^1.0.1"
24
+ "@eeacms/volto-widget-theme-picker": "*"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@cypress/code-coverage": "^3.10.0",
28
28
  "@plone/scripts": "*",
29
29
  "babel-plugin-transform-class-properties": "^6.24.1",
30
+ "cypress": "13.1.0",
30
31
  "dotenv": "^16.3.2",
31
32
  "husky": "^8.0.3",
32
33
  "lint-staged": "^14.0.1",
@@ -26,15 +26,32 @@ function Hero({
26
26
  spaced = false,
27
27
  inverted = true,
28
28
  styles,
29
+ height,
29
30
  ...props
30
31
  }) {
31
32
  const image = getFieldURL(props.image);
32
33
  const isExternal = !isInternalURL(image);
33
34
  const { alignContent = 'center', backgroundVariant = 'primary' } =
34
35
  styles || {};
35
-
36
36
  const bgImgRef = React.useRef();
37
37
  const onScreen = useFirstVisited(bgImgRef);
38
+ const containerCssStyles = React.useMemo(
39
+ () => ({
40
+ ...(height && !fullHeight ? { height } : {}),
41
+ }),
42
+ [height, fullHeight],
43
+ );
44
+
45
+ const backgroundImageStyle =
46
+ onScreen && image
47
+ ? {
48
+ backgroundImage: isExternal
49
+ ? `url(${image})`
50
+ : isImageGif(image)
51
+ ? `url(${image}/@@images/image)`
52
+ : `url(${image}/@@images/image/huge)`,
53
+ }
54
+ : {};
38
55
 
39
56
  return (
40
57
  <div
@@ -62,21 +79,12 @@ function Hero({
62
79
  'full-width': fullWidth,
63
80
  },
64
81
  )}
82
+ style={containerCssStyles}
65
83
  >
66
84
  <div
67
85
  className={cx('hero-block-image', styles?.bg)}
68
86
  ref={bgImgRef}
69
- style={
70
- image && onScreen
71
- ? {
72
- backgroundImage: isExternal
73
- ? `url(${image})`
74
- : isImageGif(image)
75
- ? `url(${image}/@@images/image)`
76
- : `url(${image}/@@images/image/huge)`,
77
- }
78
- : {}
79
- }
87
+ style={backgroundImageStyle}
80
88
  />
81
89
  {image && overlay && (
82
90
  <div className="hero-block-image-overlay dark-overlay-4"></div>
@@ -87,6 +95,7 @@ function Hero({
87
95
  'hero-block-inner-wrapper d-flex',
88
96
  `flex-items-${alignContent}`,
89
97
  )}
98
+ style={containerCssStyles}
90
99
  >
91
100
  <div className="hero-block-body">{children}</div>
92
101
  </div>
@@ -13,7 +13,7 @@ const ALIGN_INFO_MAP = {
13
13
  '': [clearSVG, 'None'],
14
14
  };
15
15
 
16
- export const HeroBlockSchema = () => {
16
+ export const HeroBlockSchema = ({ data }) => {
17
17
  return {
18
18
  title: 'Hero',
19
19
  fieldsets: [
@@ -23,6 +23,7 @@ export const HeroBlockSchema = () => {
23
23
  fields: [
24
24
  'fullWidth',
25
25
  'fullHeight',
26
+ ...(!data?.fullHeight ? ['height'] : []),
26
27
  'quoted',
27
28
  'spaced',
28
29
  'inverted',
@@ -100,7 +101,13 @@ export const HeroBlockSchema = () => {
100
101
  title: 'Align',
101
102
  widget: 'align',
102
103
  actions: ['left', 'right'],
103
- defaultValue: 'left',
104
+ default: 'left',
105
+ },
106
+ height: {
107
+ title: 'Height',
108
+ description:
109
+ 'Use CSS numeric dimmension (ex: 100px or 20vh). ' +
110
+ 'Images cannnot be made smaller than min-height.',
104
111
  },
105
112
  },
106
113
  required: [],
@@ -133,7 +140,7 @@ export const stylingSchema = (props) => {
133
140
  widget: 'align',
134
141
  actions: Object.keys(ALIGN_INFO_MAP),
135
142
  actionsInfoMap: ALIGN_INFO_MAP,
136
- defaultValue: 'has--bg--center',
143
+ default: 'has--bg--center',
137
144
  },
138
145
  backgroundVariant: {
139
146
  title: 'Background theme',
@@ -155,12 +162,13 @@ export const stylingSchema = (props) => {
155
162
  ['center', 'Center'],
156
163
  ['end', 'Bottom'],
157
164
  ],
165
+ default: 'center',
158
166
  },
159
167
  textAlign: {
160
168
  title: 'Text align',
161
169
  widget: 'align',
162
170
  actions: ['left', 'center', 'right'],
163
- defaultValue: 'left',
171
+ default: 'left',
164
172
  },
165
173
  textVariant: {
166
174
  title: 'Text theme',
@@ -192,7 +200,7 @@ export const stylingSchema = (props) => {
192
200
  title: 'Button align',
193
201
  widget: 'align',
194
202
  actions: ['left', 'center', 'right'],
195
- defaultValue: 'left',
203
+ default: 'left',
196
204
  },
197
205
  },
198
206
  required: [],