@eeacms/volto-hero-block 0.1.1 → 0.1.2
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,17 @@ 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.2](https://github.com/eea/volto-hero-block/compare/0.1.1...0.1.2)
|
|
8
|
+
|
|
9
|
+
- change(hero): wrap hero-block-image within a wrapper class [`2802c41`](https://github.com/eea/volto-hero-block/commit/2802c41ee8eba4c34bf6d4b4766ebafb24056602)
|
|
10
|
+
- change(hero): added spaced and inverted options to the main schema [`b6865cd`](https://github.com/eea/volto-hero-block/commit/b6865cdc6dfae0d486f43fccfb31fa555af3a536)
|
|
11
|
+
- change(hero): output h2 from slate instead of p tag [`0b2a4c5`](https://github.com/eea/volto-hero-block/commit/0b2a4c5070cc2bf97f31ff4cf74ade0e27434d91)
|
|
12
|
+
|
|
7
13
|
#### [0.1.1](https://github.com/eea/volto-hero-block/compare/0.1.0...0.1.1)
|
|
8
14
|
|
|
15
|
+
> 13 June 2022
|
|
16
|
+
|
|
17
|
+
- Add hero block [`#2`](https://github.com/eea/volto-hero-block/pull/2)
|
|
9
18
|
- change(hero): added image overlay option [`647ef2c`](https://github.com/eea/volto-hero-block/commit/647ef2ce68848ac38b71977485021b17e8c2f540)
|
|
10
19
|
- Fix Hero image type [`fb2188a`](https://github.com/eea/volto-hero-block/commit/fb2188ac604cfc57ba26ea482e799ca867a412ad)
|
|
11
20
|
- Fix external vs internal image [`5e447e9`](https://github.com/eea/volto-hero-block/commit/5e447e9a4e35229d9a29b74ad230a2e1e659bbea)
|
|
@@ -14,7 +23,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
14
23
|
- Update slate footnote support [`c1522b4`](https://github.com/eea/volto-hero-block/commit/c1522b4164dbe6de01771d211d7e0bf3009f44d4)
|
|
15
24
|
- Use justify content for text and button as well [`08599cc`](https://github.com/eea/volto-hero-block/commit/08599cc45546d9b349128c4f8ce9c01318385811)
|
|
16
25
|
- 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
26
|
|
|
19
27
|
#### 0.1.0
|
|
20
28
|
|
package/package.json
CHANGED
|
@@ -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 {
|
|
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 {
|
|
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={
|
|
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=
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
<
|
|
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 {
|
|
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: [
|
|
@@ -95,6 +102,7 @@ export const stylingSchema = ({ intl }) => ({
|
|
|
95
102
|
['tertiary', 'Tertiary'],
|
|
96
103
|
['grey', 'Grey'],
|
|
97
104
|
],
|
|
105
|
+
defaultValue: 'primary',
|
|
98
106
|
},
|
|
99
107
|
textVariant: {
|
|
100
108
|
title: 'Text theme',
|
|
@@ -104,6 +112,7 @@ export const stylingSchema = ({ intl }) => ({
|
|
|
104
112
|
['tertiary', 'Tertiary'],
|
|
105
113
|
['white', 'White'],
|
|
106
114
|
],
|
|
115
|
+
defaultValue: 'white',
|
|
107
116
|
},
|
|
108
117
|
buttonVariant: {
|
|
109
118
|
title: 'Button theme',
|
|
@@ -112,6 +121,7 @@ export const stylingSchema = ({ intl }) => ({
|
|
|
112
121
|
['primary', 'Primary'],
|
|
113
122
|
['secondary', 'Secondary'],
|
|
114
123
|
],
|
|
124
|
+
defaultValue: 'default',
|
|
115
125
|
},
|
|
116
126
|
},
|
|
117
127
|
required: [],
|
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
|
-
|
|
6
|
-
return
|
|
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) => {
|