@eeacms/volto-hero-block 0.1.1 → 0.1.4

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,8 +4,29 @@ 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
+ #### [0.1.4](https://github.com/eea/volto-hero-block/compare/0.1.3...0.1.4)
8
+
9
+
10
+ #### [0.1.3](https://github.com/eea/volto-hero-block/compare/0.1.2...0.1.3)
11
+
12
+ > 30 June 2022
13
+
14
+ - Cleanup themeing options [`#4`](https://github.com/eea/volto-hero-block/pull/4)
15
+
16
+ #### [0.1.2](https://github.com/eea/volto-hero-block/compare/0.1.1...0.1.2)
17
+
18
+ > 16 June 2022
19
+
20
+ - Release [`#3`](https://github.com/eea/volto-hero-block/pull/3)
21
+ - change(hero): wrap hero-block-image within a wrapper class [`2802c41`](https://github.com/eea/volto-hero-block/commit/2802c41ee8eba4c34bf6d4b4766ebafb24056602)
22
+ - change(hero): added spaced and inverted options to the main schema [`b6865cd`](https://github.com/eea/volto-hero-block/commit/b6865cdc6dfae0d486f43fccfb31fa555af3a536)
23
+ - change(hero): output h2 from slate instead of p tag [`0b2a4c5`](https://github.com/eea/volto-hero-block/commit/0b2a4c5070cc2bf97f31ff4cf74ade0e27434d91)
24
+
7
25
  #### [0.1.1](https://github.com/eea/volto-hero-block/compare/0.1.0...0.1.1)
8
26
 
27
+ > 13 June 2022
28
+
29
+ - Add hero block [`#2`](https://github.com/eea/volto-hero-block/pull/2)
9
30
  - change(hero): added image overlay option [`647ef2c`](https://github.com/eea/volto-hero-block/commit/647ef2ce68848ac38b71977485021b17e8c2f540)
10
31
  - Fix Hero image type [`fb2188a`](https://github.com/eea/volto-hero-block/commit/fb2188ac604cfc57ba26ea482e799ca867a412ad)
11
32
  - Fix external vs internal image [`5e447e9`](https://github.com/eea/volto-hero-block/commit/5e447e9a4e35229d9a29b74ad230a2e1e659bbea)
@@ -14,7 +35,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
14
35
  - Update slate footnote support [`c1522b4`](https://github.com/eea/volto-hero-block/commit/c1522b4164dbe6de01771d211d7e0bf3009f44d4)
15
36
  - Use justify content for text and button as well [`08599cc`](https://github.com/eea/volto-hero-block/commit/08599cc45546d9b349128c4f8ce9c01318385811)
16
37
  - Add dependencies [`30e2881`](https://github.com/eea/volto-hero-block/commit/30e2881a2a97a899e7f4cc614a0405c300ac6fee)
17
- - Add hero block [`5ded9f5`](https://github.com/eea/volto-hero-block/commit/5ded9f5029de8b756cecef389e9546d7b3f49d11)
18
38
 
19
39
  #### 0.1.0
20
40
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-hero-block",
3
- "version": "0.1.1",
3
+ "version": "0.1.4",
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",
@@ -11,13 +11,13 @@ import SlateEditor from 'volto-slate/editor/SlateEditor';
11
11
  import { handleKey } from 'volto-slate/blocks/Text/keyboard';
12
12
  import { uploadContent, saveSlateBlockSelection } from 'volto-slate/actions';
13
13
 
14
- import { createSlateParagraph } from '@eeacms/volto-hero-block/helpers';
14
+ import { createSlateHeader } from '@eeacms/volto-hero-block/helpers';
15
15
 
16
16
  import Hero from './Hero';
17
17
  import getSchema from './schema';
18
18
 
19
- const Metadata = ({ buttonLabel, buttonLink, styles }) => {
20
- const { inverted = true, buttonVariant = 'white' } = styles || {};
19
+ const Metadata = ({ buttonLabel, buttonLink, inverted, styles }) => {
20
+ const { buttonVariant } = styles || {};
21
21
 
22
22
  return buttonLabel ? (
23
23
  <UniversalLink
@@ -68,7 +68,7 @@ const Edit = (props) => {
68
68
  properties={properties}
69
69
  extensions={slate.textblockExtensions}
70
70
  renderExtensions={[withBlockProperties]}
71
- value={createSlateParagraph(text)}
71
+ value={createSlateHeader(text)}
72
72
  onChange={(text) => {
73
73
  onChangeBlock(block, {
74
74
  ...data,
@@ -11,6 +11,8 @@ Hero.propTypes = {
11
11
  justifyContent: PropTypes.string,
12
12
  backgroundVariant: PropTypes.string,
13
13
  quoted: PropTypes.bool,
14
+ spaced: PropTypes.bool,
15
+ inverted: PropTypes.bool,
14
16
  textVariant: PropTypes.string,
15
17
  };
16
18
 
@@ -20,6 +22,8 @@ function Hero({
20
22
  fullWidth = true,
21
23
  fullHeight = true,
22
24
  children,
25
+ spaced = false,
26
+ inverted = true,
23
27
  styles,
24
28
  }) {
25
29
  const isExternal = !isInternalURL(image);
@@ -29,28 +33,35 @@ function Hero({
29
33
  <div
30
34
  className={cx(
31
35
  'eea hero-block',
36
+ { spaced },
37
+ { inverted },
32
38
  !image && backgroundVariant && `color-bg-${backgroundVariant}`,
33
39
  {
34
- 'full-width': fullWidth,
35
40
  'full-height': fullHeight,
36
41
  },
37
42
  )}
38
43
  >
39
44
  <div
40
- className="hero-block-image"
41
- style={
42
- image
43
- ? {
44
- backgroundImage: isExternal
45
- ? `url(${image})`
46
- : `url(${image}/@@images/image/huge)`,
47
- }
48
- : {}
49
- }
50
- />
51
- {image && overlay && (
52
- <div className="hero-block-image-overlay dark-overlay-4"></div>
53
- )}
45
+ className={cx('hero-block-image-wrapper', {
46
+ 'full-width': fullWidth,
47
+ })}
48
+ >
49
+ <div
50
+ className={cx('hero-block-image')}
51
+ style={
52
+ image
53
+ ? {
54
+ backgroundImage: isExternal
55
+ ? `url(${image})`
56
+ : `url(${image}/@@images/image/huge)`,
57
+ }
58
+ : {}
59
+ }
60
+ />
61
+ {image && overlay && (
62
+ <div className="hero-block-image-overlay dark-overlay-4"></div>
63
+ )}
64
+ </div>
54
65
  <div
55
66
  className={cx(
56
67
  'hero-block-inner-wrapper d-flex ui container',
@@ -74,7 +85,7 @@ Hero.Text = ({ children, styles }) => {
74
85
  `text-${justifyContent}`,
75
86
  )}
76
87
  >
77
- <h2 className={cx({ quoted })}>{children}</h2>
88
+ <div className={cx({ quoted })}>{children}</div>
78
89
  </div>
79
90
  );
80
91
  };
@@ -4,8 +4,8 @@ import { UniversalLink } from '@plone/volto/components';
4
4
  import Hero from './Hero';
5
5
  import { serializeText } from '@eeacms/volto-hero-block/helpers';
6
6
 
7
- const Metadata = ({ buttonLabel, buttonLink, styles }) => {
8
- const { inverted = true, buttonVariant = 'white' } = styles || {};
7
+ const Metadata = ({ buttonLabel, buttonLink, inverted, styles }) => {
8
+ const { buttonVariant = 'white' } = styles || {};
9
9
 
10
10
  return buttonLabel ? (
11
11
  <UniversalLink
@@ -8,6 +8,8 @@ export default ({ data }) => {
8
8
  fields: [
9
9
  'fullWidth',
10
10
  'fullHeight',
11
+ 'spaced',
12
+ 'inverted',
11
13
  'buttonLabel',
12
14
  'buttonLink',
13
15
  'overlay',
@@ -26,6 +28,16 @@ export default ({ data }) => {
26
28
  type: 'boolean',
27
29
  defaultValue: true,
28
30
  },
31
+ spaced: {
32
+ title: 'Spaced',
33
+ type: 'boolean',
34
+ defaultValue: false,
35
+ },
36
+ inverted: {
37
+ title: 'Inverted',
38
+ type: 'boolean',
39
+ defaultValue: true,
40
+ },
29
41
  buttonLabel: {
30
42
  title: 'Button label',
31
43
  widget: 'textarea',
@@ -56,8 +68,7 @@ export const stylingSchema = ({ intl }) => ({
56
68
  id: 'default',
57
69
  title: 'Default',
58
70
  fields: [
59
- 'quoted',
60
- 'inverted',
71
+ // 'quoted',
61
72
  'alignContent',
62
73
  'justifyContent',
63
74
  'backgroundVariant',
@@ -71,10 +82,6 @@ export const stylingSchema = ({ intl }) => ({
71
82
  title: 'Quoted',
72
83
  type: 'boolean',
73
84
  },
74
- inverted: {
75
- title: 'Inverted',
76
- type: 'boolean',
77
- },
78
85
  alignContent: {
79
86
  title: 'Align content',
80
87
  choices: [
@@ -102,15 +109,14 @@ export const stylingSchema = ({ intl }) => ({
102
109
  ['primary', 'Primary'],
103
110
  ['secondary', 'Secondary'],
104
111
  ['tertiary', 'Tertiary'],
105
- ['white', 'White'],
106
112
  ],
107
113
  },
108
114
  buttonVariant: {
109
115
  title: 'Button theme',
110
116
  choices: [
111
- ['default', 'Default'],
112
117
  ['primary', 'Primary'],
113
118
  ['secondary', 'Secondary'],
119
+ ['tertiary', 'Tertiary'],
114
120
  ],
115
121
  },
116
122
  },
package/src/helpers.js CHANGED
@@ -1,9 +1,15 @@
1
1
  import { isArray } from 'lodash';
2
- import config from '@plone/volto/registry';
3
2
  import { serializeNodes } from 'volto-slate/editor/render';
4
3
 
5
- export const createSlateParagraph = (text) => {
6
- return isArray(text) ? text : config.settings.slate.defaultValue();
4
+ const createEmptyHeader = () => {
5
+ return {
6
+ type: 'h2',
7
+ children: [{ text: '' }],
8
+ };
9
+ };
10
+
11
+ export const createSlateHeader = (text) => {
12
+ return isArray(text) ? text : [createEmptyHeader()];
7
13
  };
8
14
 
9
15
  export const serializeText = (text) => {