@eeacms/volto-hero-block 1.0.0 → 2.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.
@@ -1,7 +1,9 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
 
4
- const projectRootPath = fs.realpathSync('./project'); // __dirname
4
+ const projectRootPath = fs.existsSync('./project')
5
+ ? fs.realpathSync('./project')
6
+ : fs.realpathSync('./../../../');
5
7
  const packageJson = require(path.join(projectRootPath, 'package.json'));
6
8
  const jsConfig = require(path.join(projectRootPath, 'jsconfig.json')).compilerOptions;
7
9
 
package/CHANGELOG.md CHANGED
@@ -4,7 +4,24 @@ 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
- ### [1.0.0](https://github.com/eea/volto-hero-block/compare/0.2.0...1.0.0) - 28 October 2022
7
+ ### [2.1.0](https://github.com/eea/volto-hero-block/compare/2.0.0...2.1.0) - 12 December 2022
8
+
9
+ #### :bug: Bug Fixes
10
+
11
+ - fix(gif): Use ES6 with isImageGif utility - refs #158188 [Alin Voinea - [`ad32432`](https://github.com/eea/volto-hero-block/commit/ad32432ee320bb4e43f20e260f2900269adf0401)]
12
+
13
+ #### :hammer_and_wrench: Others
14
+
15
+ ## [2.0.0](https://github.com/eea/volto-hero-block/compare/1.0.0...2.0.0) - 16 November 2022
16
+
17
+ #### :nail_care: Enhancements
18
+
19
+ - refactor(Styling): Use schemaEnhancer in favor of StyleWrapper [Alin Voinea - [`dacf4db`](https://github.com/eea/volto-hero-block/commit/dacf4db6c59a584639f13c7ce8a3d7bd808ea64c)]
20
+
21
+ #### :hammer_and_wrench: Others
22
+
23
+ - test(estlint): Fix .project.eslintrc.js [Alin Voinea - [`b8f0971`](https://github.com/eea/volto-hero-block/commit/b8f0971b21a5334d40c1b8f5103cea61d9ffe6f1)]
24
+ ## [1.0.0](https://github.com/eea/volto-hero-block/compare/0.2.0...1.0.0) - 28 October 2022
8
25
 
9
26
  #### :nail_care: Enhancements
10
27
 
package/README.md CHANGED
@@ -21,6 +21,12 @@ Enhanced Hero Block [Volto](https://github.com/plone/volto) add-on
21
21
 
22
22
  Demo GIF
23
23
 
24
+ ## Upgrade
25
+
26
+ ### Upgrading to 2.x
27
+
28
+ This version requires: `@plone/volto >= 16.0.0.alpha.46` (schemaEnhancer / addStyling).
29
+
24
30
  ## Getting started
25
31
 
26
32
  ### Add volto-hero-block to your Volto project
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-hero-block",
3
- "version": "1.0.0",
3
+ "version": "2.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",
@@ -23,8 +23,8 @@
23
23
  "@eeacms/volto-object-widget": "*"
24
24
  },
25
25
  "devDependencies": {
26
- "@plone/scripts": "*",
27
26
  "@cypress/code-coverage": "^3.10.0",
27
+ "@plone/scripts": "*",
28
28
  "babel-plugin-transform-class-properties": "^6.24.1",
29
29
  "md5": "^2.3.0"
30
30
  },
@@ -46,5 +46,5 @@
46
46
  "i18n": "make i18n",
47
47
  "cypress:run": "make cypress-run",
48
48
  "cypress:open": "make cypress-open"
49
- }
49
+ }
50
50
  }
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import cx from 'classnames';
3
3
  import PropTypes from 'prop-types';
4
4
  import { isInternalURL } from '@plone/volto/helpers/Url/Url';
5
+ import { isImageGif } from '@eeacms/volto-hero-block/helpers';
5
6
 
6
7
  Hero.propTypes = {
7
8
  image: PropTypes.string,
@@ -33,18 +34,28 @@ function Hero({
33
34
  <div
34
35
  className={cx(
35
36
  'eea hero-block',
36
- { spaced },
37
- { inverted },
38
- !image && backgroundVariant && `color-bg-${backgroundVariant}`,
37
+ !image &&
38
+ backgroundVariant &&
39
+ !fullWidth &&
40
+ `color-bg-${backgroundVariant}`,
39
41
  {
42
+ spaced,
43
+ inverted,
40
44
  'full-height': fullHeight,
41
45
  },
42
46
  )}
43
47
  >
44
48
  <div
45
- className={cx('hero-block-image-wrapper', {
46
- 'full-width': fullWidth,
47
- })}
49
+ className={cx(
50
+ 'hero-block-image-wrapper',
51
+ !image &&
52
+ backgroundVariant &&
53
+ fullWidth &&
54
+ `color-bg-${backgroundVariant}`,
55
+ {
56
+ 'full-width': fullWidth,
57
+ },
58
+ )}
48
59
  >
49
60
  <div
50
61
  className={cx('hero-block-image')}
@@ -53,6 +64,8 @@ function Hero({
53
64
  ? {
54
65
  backgroundImage: isExternal
55
66
  ? `url(${image})`
67
+ : isImageGif(image)
68
+ ? `url(${image}/@@images/image)`
56
69
  : `url(${image}/@@images/image/huge)`,
57
70
  }
58
71
  : {}
@@ -12,8 +12,7 @@ export default (config) => {
12
12
  edit: HeroEdit,
13
13
  view: HeroView,
14
14
  blockHasOwnFocusManagement: true,
15
- stylesSchema: stylingSchema,
16
- enableStyling: true,
15
+ schemaEnhancer: stylingSchema,
17
16
  restricted: false,
18
17
  mostUsed: false,
19
18
  sidebarTab: 1,
@@ -1,4 +1,6 @@
1
- export default ({ data }) => {
1
+ import { addStyling } from '@plone/volto/helpers';
2
+
3
+ export default () => {
2
4
  return {
3
5
  title: 'Hero',
4
6
  fieldsets: [
@@ -66,69 +68,73 @@ export default ({ data }) => {
66
68
  };
67
69
  };
68
70
 
69
- export const stylingSchema = ({ intl }) => ({
70
- title: 'Hero style',
71
- block: 'hero',
72
- fieldsets: [
73
- {
74
- id: 'default',
75
- title: 'Default',
76
- fields: [
77
- 'backgroundVariant',
78
- 'alignContent',
79
- 'textAlign',
80
- 'textVariant',
81
- 'buttonVariant',
82
- 'buttonAlign',
83
- ],
84
- },
85
- ],
86
- properties: {
87
- backgroundVariant: {
88
- title: 'Background theme',
89
- choices: [
90
- ['primary', 'Primary'],
91
- ['secondary', 'Secondary'],
92
- ['tertiary', 'Tertiary'],
93
- ['grey', 'Grey'],
94
- ],
95
- },
96
- alignContent: {
97
- title: 'Content align',
98
- choices: [
99
- ['start', 'Top'],
100
- ['center', 'Center'],
101
- ['end', 'Bottom'],
102
- ],
103
- },
104
- textAlign: {
105
- title: 'Text align',
106
- widget: 'align',
107
- actions: ['left', 'center', 'right'],
108
- defaultValue: 'left',
109
- },
110
- textVariant: {
111
- title: 'Text theme',
112
- choices: [
113
- ['primary', 'Primary'],
114
- ['secondary', 'Secondary'],
115
- ['tertiary', 'Tertiary'],
116
- ],
117
- },
118
- buttonVariant: {
119
- title: 'Button theme',
120
- choices: [
121
- ['primary', 'Primary'],
122
- ['secondary', 'Secondary'],
123
- ['tertiary', 'Tertiary'],
124
- ],
125
- },
126
- buttonAlign: {
127
- title: 'Button align',
128
- widget: 'align',
129
- actions: ['left', 'center', 'right'],
130
- defaultValue: 'left',
71
+ export const stylingSchema = (props) => {
72
+ const schema = addStyling(props);
73
+ schema.properties.styles.schema = {
74
+ title: 'Hero style',
75
+ block: 'hero',
76
+ fieldsets: [
77
+ {
78
+ id: 'default',
79
+ title: 'Default',
80
+ fields: [
81
+ 'backgroundVariant',
82
+ 'alignContent',
83
+ 'textAlign',
84
+ 'textVariant',
85
+ 'buttonVariant',
86
+ 'buttonAlign',
87
+ ],
88
+ },
89
+ ],
90
+ properties: {
91
+ backgroundVariant: {
92
+ title: 'Background theme',
93
+ choices: [
94
+ ['primary', 'Primary'],
95
+ ['secondary', 'Secondary'],
96
+ ['tertiary', 'Tertiary'],
97
+ ['grey', 'Grey'],
98
+ ],
99
+ },
100
+ alignContent: {
101
+ title: 'Content align',
102
+ choices: [
103
+ ['start', 'Top'],
104
+ ['center', 'Center'],
105
+ ['end', 'Bottom'],
106
+ ],
107
+ },
108
+ textAlign: {
109
+ title: 'Text align',
110
+ widget: 'align',
111
+ actions: ['left', 'center', 'right'],
112
+ defaultValue: 'left',
113
+ },
114
+ textVariant: {
115
+ title: 'Text theme',
116
+ choices: [
117
+ ['primary', 'Primary'],
118
+ ['secondary', 'Secondary'],
119
+ ['tertiary', 'Tertiary'],
120
+ ],
121
+ },
122
+ buttonVariant: {
123
+ title: 'Button theme',
124
+ choices: [
125
+ ['primary', 'Primary'],
126
+ ['secondary', 'Secondary'],
127
+ ['tertiary', 'Tertiary'],
128
+ ],
129
+ },
130
+ buttonAlign: {
131
+ title: 'Button align',
132
+ widget: 'align',
133
+ actions: ['left', 'center', 'right'],
134
+ defaultValue: 'left',
135
+ },
131
136
  },
132
- },
133
- required: [],
134
- });
137
+ required: [],
138
+ };
139
+ return schema;
140
+ };
package/src/helpers.js CHANGED
@@ -15,3 +15,7 @@ export const createSlateHeader = (text) => {
15
15
  export const serializeText = (text) => {
16
16
  return isArray(text) ? serializeNodes(text) : text;
17
17
  };
18
+
19
+ export const isImageGif = (image) => {
20
+ return image?.endsWith?.('.gif');
21
+ };