@eeacms/volto-eea-website-policy 0.2.3 → 0.2.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 +10 -1
- package/package.json +1 -1
- package/src/components/Blocks/Teaser/Card.jsx +73 -0
- package/src/components/Blocks/Teaser/Schema.js +57 -0
- package/src/components/Blocks/Teaser/index.js +26 -0
- package/src/components/Blocks/Teaser/utils.js +18 -0
- package/src/index.js +10 -4
- package/src/components/Blocks/Teaser/Edit.jsx +0 -0
- package/src/components/Blocks/Teaser/View.jsx +0 -0
- package/src/components/Blocks/TeaserGrid/Edit.jsx +0 -0
- package/src/components/Blocks/TeaserGrid/View.jsx +0 -0
- package/src/components/index.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,18 @@ 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.2.4](https://github.com/eea/volto-eea-website-policy/compare/0.2.3...0.2.4)
|
|
8
|
+
|
|
9
|
+
- Fix listing block title: Listing (Content) [`cec2760`](https://github.com/eea/volto-eea-website-policy/commit/cec276082c3fc1b5486c996c3746a6958fb3a1a9)
|
|
10
|
+
- Add theme to teaser stylewrapper [`60eeb28`](https://github.com/eea/volto-eea-website-policy/commit/60eeb28b7793708c59d0af73ffb09895e8f2c87d)
|
|
11
|
+
- Fix className vs class warning [`fea1603`](https://github.com/eea/volto-eea-website-policy/commit/fea1603eefd628d57640a6b94ddbbb7edfb0d841)
|
|
12
|
+
- Custom card view for teaser [`c8eded0`](https://github.com/eea/volto-eea-website-policy/commit/c8eded011b8317cce9f842526f5d86771f54797b)
|
|
13
|
+
|
|
7
14
|
#### [0.2.3](https://github.com/eea/volto-eea-website-policy/compare/0.2.2...0.2.3)
|
|
8
15
|
|
|
16
|
+
> 10 June 2022
|
|
17
|
+
|
|
18
|
+
- Add Item block [`#9`](https://github.com/eea/volto-eea-website-policy/pull/9)
|
|
9
19
|
- prettier fix [`c2a6d2d`](https://github.com/eea/volto-eea-website-policy/commit/c2a6d2d3b12ce771b9b4413c5a6db157ccd9d1fc)
|
|
10
20
|
- Update index.js [`fb73895`](https://github.com/eea/volto-eea-website-policy/commit/fb7389509bc7e207942762c5e02a93d0168a6fba)
|
|
11
21
|
- removed change from commit 719e3778 [`29e636b`](https://github.com/eea/volto-eea-website-policy/commit/29e636b34ab02992c67cc5960f4dc6b21b1b4e71)
|
|
@@ -14,7 +24,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
14
24
|
- Move Item block un components folder [`9fb6ab2`](https://github.com/eea/volto-eea-website-policy/commit/9fb6ab2fb02cc5c1a7e25367de5ebe7109bd3dc4)
|
|
15
25
|
- Set default sizes for image & icon in Item block [`af22ec7`](https://github.com/eea/volto-eea-website-policy/commit/af22ec78b2c6fd1d033dc1acfec5e64f8926cd77)
|
|
16
26
|
- Add helpers functions [`353581c`](https://github.com/eea/volto-eea-website-policy/commit/353581cc6602b5e573eee93c74a67656203c0968)
|
|
17
|
-
- Add Item block [`617bfe2`](https://github.com/eea/volto-eea-website-policy/commit/617bfe2b827708ddb2c5eecd8fe1cc6fee37f60a)
|
|
18
27
|
- Add Teaser block folder's structure [`9457dd4`](https://github.com/eea/volto-eea-website-policy/commit/9457dd4ffaa2631eceb46bfd1ec2d201e8b3d7a8)
|
|
19
28
|
|
|
20
29
|
#### [0.2.2](https://github.com/eea/volto-eea-website-policy/compare/0.2.1...0.2.2)
|
package/package.json
CHANGED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Message } from 'semantic-ui-react';
|
|
4
|
+
import { defineMessages, useIntl } from 'react-intl';
|
|
5
|
+
import imageBlockSVG from '@plone/volto/components/manage/Blocks/Image/block-image.svg';
|
|
6
|
+
import { flattenToAppURL } from '@plone/volto/helpers';
|
|
7
|
+
import { getTeaserImageURL } from './utils';
|
|
8
|
+
import { MaybeWrap } from '@plone/volto/components';
|
|
9
|
+
import { UniversalLink } from '@plone/volto/components';
|
|
10
|
+
import cx from 'classnames';
|
|
11
|
+
|
|
12
|
+
const messages = defineMessages({
|
|
13
|
+
PleaseChooseContent: {
|
|
14
|
+
id: 'Please choose an existing content as source for this element',
|
|
15
|
+
defaultMessage:
|
|
16
|
+
'Please choose an existing content as source for this element',
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const TeaserCardTemplate = (props) => {
|
|
21
|
+
const { data, isEditMode } = props;
|
|
22
|
+
const intl = useIntl();
|
|
23
|
+
const href = data.href?.[0];
|
|
24
|
+
const image = data.preview_image?.[0];
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<>
|
|
28
|
+
{!href && isEditMode && (
|
|
29
|
+
<Message>
|
|
30
|
+
<div className="grid-teaser-item placeholder">
|
|
31
|
+
<img src={imageBlockSVG} alt="" />
|
|
32
|
+
<p>{intl.formatMessage(messages.PleaseChooseContent)}</p>
|
|
33
|
+
</div>
|
|
34
|
+
</Message>
|
|
35
|
+
)}
|
|
36
|
+
{href && (
|
|
37
|
+
<MaybeWrap
|
|
38
|
+
condition={!isEditMode}
|
|
39
|
+
as={UniversalLink}
|
|
40
|
+
href={href['@id']}
|
|
41
|
+
target={data.openLinkInNewTab ? '_blank' : null}
|
|
42
|
+
>
|
|
43
|
+
<div className={cx('ui fluid card', data?.styles?.theme)}>
|
|
44
|
+
{(href.hasPreviewImage || href.image_field || image) && (
|
|
45
|
+
<div className="image">
|
|
46
|
+
<img
|
|
47
|
+
src={flattenToAppURL(getTeaserImageURL(href, image))}
|
|
48
|
+
alt="a"
|
|
49
|
+
/>
|
|
50
|
+
</div>
|
|
51
|
+
)}
|
|
52
|
+
<div className="content">
|
|
53
|
+
{data?.head_title && (
|
|
54
|
+
<div className="meta">{data?.head_title}</div>
|
|
55
|
+
)}
|
|
56
|
+
<div className="header">{data?.title}</div>
|
|
57
|
+
{!data.hide_description && (
|
|
58
|
+
<p className="description">{data?.description}</p>
|
|
59
|
+
)}
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</MaybeWrap>
|
|
63
|
+
)}
|
|
64
|
+
</>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
TeaserCardTemplate.propTypes = {
|
|
69
|
+
data: PropTypes.objectOf(PropTypes.any).isRequired,
|
|
70
|
+
isEditMode: PropTypes.bool,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export default TeaserCardTemplate;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl';
|
|
2
|
+
|
|
3
|
+
const messages = defineMessages({
|
|
4
|
+
Type: {
|
|
5
|
+
id: 'Teaser',
|
|
6
|
+
defaultMessage: 'Teaser',
|
|
7
|
+
},
|
|
8
|
+
Theme: {
|
|
9
|
+
id: 'Theme',
|
|
10
|
+
defaultMessage: 'Theme',
|
|
11
|
+
},
|
|
12
|
+
ThemeHelp: {
|
|
13
|
+
id: 'Theme',
|
|
14
|
+
defaultMessage: 'Theme',
|
|
15
|
+
},
|
|
16
|
+
ThemeDefault: {
|
|
17
|
+
id: 'Default',
|
|
18
|
+
defaultMessage: 'Default',
|
|
19
|
+
},
|
|
20
|
+
ThemePrimary: {
|
|
21
|
+
id: 'Primary',
|
|
22
|
+
defaultMessage: 'Primary',
|
|
23
|
+
},
|
|
24
|
+
ThemeSecondary: {
|
|
25
|
+
id: 'Secondary',
|
|
26
|
+
defaultMessage: 'Secondary',
|
|
27
|
+
},
|
|
28
|
+
ThemeTertiary: {
|
|
29
|
+
id: 'Tertiary',
|
|
30
|
+
defaultMessage: 'Tertiary',
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const StylingSchema = ({ intl }) => ({
|
|
35
|
+
title: intl.formatMessage(messages.Type),
|
|
36
|
+
block: 'teaserGrid',
|
|
37
|
+
fieldsets: [
|
|
38
|
+
{
|
|
39
|
+
id: 'default',
|
|
40
|
+
title: 'Default',
|
|
41
|
+
fields: ['theme'],
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
properties: {
|
|
45
|
+
theme: {
|
|
46
|
+
title: intl.formatMessage(messages.Theme),
|
|
47
|
+
description: intl.formatMessage(messages.ThemeHelp),
|
|
48
|
+
choices: [
|
|
49
|
+
['', intl.formatMessage(messages.ThemeDefault)],
|
|
50
|
+
['primary', intl.formatMessage(messages.ThemePrimary)],
|
|
51
|
+
['secondary', intl.formatMessage(messages.ThemeSecondary)],
|
|
52
|
+
['tertiary', intl.formatMessage(messages.ThemeTertiary)],
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
required: [],
|
|
57
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import TeaserCardTemplate from './Card';
|
|
2
|
+
import { StylingSchema } from './Schema';
|
|
3
|
+
|
|
4
|
+
export default (config) => {
|
|
5
|
+
// Teaser
|
|
6
|
+
if (config.blocks.blocksConfig.teaser) {
|
|
7
|
+
config.blocks.blocksConfig.teaser.variations = [
|
|
8
|
+
...(config.blocks.blocksConfig.teaser.variations || []),
|
|
9
|
+
{
|
|
10
|
+
id: 'card',
|
|
11
|
+
isDefault: true,
|
|
12
|
+
title: 'Card (top image)',
|
|
13
|
+
template: TeaserCardTemplate,
|
|
14
|
+
},
|
|
15
|
+
];
|
|
16
|
+
config.blocks.blocksConfig.teaser.enableStyling = true;
|
|
17
|
+
config.blocks.blocksConfig.teaser.stylesSchema = StylingSchema;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Teaser Grid
|
|
21
|
+
if (config.blocks.blocksConfig.teaserGrid) {
|
|
22
|
+
config.blocks.blocksConfig.teaserGrid.title = 'Teaser (Cards)';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return config;
|
|
26
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { isInternalURL } from '@plone/volto/helpers';
|
|
2
|
+
import config from '@plone/volto/registry';
|
|
3
|
+
|
|
4
|
+
export function getTeaserImageURL(href, image) {
|
|
5
|
+
const imageScale =
|
|
6
|
+
config.blocks.blocksConfig['teaser'].imageScale || 'preview';
|
|
7
|
+
if (image) {
|
|
8
|
+
if (isInternalURL(image['@id'])) {
|
|
9
|
+
return `${image['@id']}/@@images/image/${imageScale}`;
|
|
10
|
+
} else {
|
|
11
|
+
return image['@id'];
|
|
12
|
+
}
|
|
13
|
+
} else {
|
|
14
|
+
return `${href['@id']}/@@images/${
|
|
15
|
+
href.image_field || 'preview_image'
|
|
16
|
+
}/${imageScale}`;
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { runtimeConfig } from '@plone/volto/runtime_config';
|
|
2
2
|
import installCallout from 'volto-slate/editor/plugins/Callout';
|
|
3
3
|
import installItemBlock from '@eeacms/volto-eea-website-policy/components/Blocks/Item';
|
|
4
|
+
import customizeTeaserBlock from '@eeacms/volto-eea-website-policy/components/Blocks/Teaser';
|
|
4
5
|
|
|
5
6
|
const applyConfig = (config) => {
|
|
6
7
|
// if (process.env.NODE_ENV === 'production') {
|
|
@@ -76,9 +77,6 @@ const applyConfig = (config) => {
|
|
|
76
77
|
if (config.blocks.blocksConfig.teaser) {
|
|
77
78
|
config.blocks.blocksConfig.teaser.restricted = true;
|
|
78
79
|
}
|
|
79
|
-
if (config.blocks.blocksConfig.teaserGrid) {
|
|
80
|
-
config.blocks.blocksConfig.teaserGrid.title = 'Teaser (Cards)';
|
|
81
|
-
}
|
|
82
80
|
|
|
83
81
|
// Divider
|
|
84
82
|
if (config.blocks.blocksConfig.dividerBlock) {
|
|
@@ -95,8 +93,16 @@ const applyConfig = (config) => {
|
|
|
95
93
|
config.blocks.blocksConfig.columnsBlock.mostUsed = true;
|
|
96
94
|
}
|
|
97
95
|
|
|
96
|
+
// Listing
|
|
97
|
+
if (config.blocks.blocksConfig.listing) {
|
|
98
|
+
config.blocks.blocksConfig.listing.title = 'Listing (Content)';
|
|
99
|
+
}
|
|
100
|
+
|
|
98
101
|
// Custom blocks
|
|
99
|
-
config = [installItemBlock].reduce(
|
|
102
|
+
config = [installItemBlock, customizeTeaserBlock].reduce(
|
|
103
|
+
(acc, apply) => apply(acc),
|
|
104
|
+
config,
|
|
105
|
+
);
|
|
100
106
|
config.blocks.blocksConfig.item.mostUsed = true;
|
|
101
107
|
|
|
102
108
|
// Done
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/components/index.js
DELETED
|
File without changes
|