@eeacms/volto-eea-website-policy 1.0.2 → 1.0.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 +9 -0
- package/package.json +1 -1
- package/src/components/Blocks/LayoutSettings/LayoutSettingsEdit.jsx +32 -0
- package/src/components/Blocks/LayoutSettings/LayoutSettingsView.jsx +15 -0
- package/src/components/Blocks/LayoutSettings/edit.less +4 -0
- package/src/components/Blocks/LayoutSettings/index.js +24 -0
- package/src/components/Blocks/LayoutSettings/schema.js +31 -0
- package/src/components/Blocks/schema-utils.js +16 -0
- package/src/components/Blocks/schema.js +1 -1
- package/src/index.js +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,15 @@ 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.4](https://github.com/eea/volto-eea-website-policy/compare/1.0.3...1.0.4) - 22 November 2022
|
|
8
|
+
|
|
9
|
+
#### :nail_care: Enhancements
|
|
10
|
+
|
|
11
|
+
- change(policy): Enable styling schema enhancer for listing block #27 from eea/listing [ichim-david - [`d4c679a`](https://github.com/eea/volto-eea-website-policy/commit/d4c679a11a0dd84bb891a4f4396c4fc671da028c)]
|
|
12
|
+
- change(policy): Enable styling schema enhancer for listing block [kreafox - [`79d6059`](https://github.com/eea/volto-eea-website-policy/commit/79d6059ece37553436bc7d937063c1c53b533cc8)]
|
|
13
|
+
|
|
14
|
+
### [1.0.3](https://github.com/eea/volto-eea-website-policy/compare/1.0.2...1.0.3) - 16 November 2022
|
|
15
|
+
|
|
7
16
|
### [1.0.2](https://github.com/eea/volto-eea-website-policy/compare/1.0.1...1.0.2) - 16 November 2022
|
|
8
17
|
|
|
9
18
|
#### :nail_care: Enhancements
|
package/package.json
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { EditSchema } from '@eeacms/volto-eea-website-policy/components/Blocks/LayoutSettings/schema';
|
|
3
|
+
import { BlockDataForm, SidebarPortal } from '@plone/volto/components';
|
|
4
|
+
import LayoutSettingsView from '@eeacms/volto-eea-website-policy/components/Blocks/LayoutSettings/LayoutSettingsView';
|
|
5
|
+
import '@eeacms/volto-eea-website-policy/components/Blocks/LayoutSettings/edit.less';
|
|
6
|
+
|
|
7
|
+
const LayoutSettingsEdit = (props) => {
|
|
8
|
+
const schema = EditSchema();
|
|
9
|
+
return (
|
|
10
|
+
<>
|
|
11
|
+
<h3>Page layout settings</h3>
|
|
12
|
+
<LayoutSettingsView {...props} />
|
|
13
|
+
<SidebarPortal selected={props.selected}>
|
|
14
|
+
{props.selected && (
|
|
15
|
+
<BlockDataForm
|
|
16
|
+
title={schema.title}
|
|
17
|
+
schema={schema}
|
|
18
|
+
formData={props.data}
|
|
19
|
+
onChangeField={(id, value) => {
|
|
20
|
+
props.onChangeBlock(props.block, {
|
|
21
|
+
...props.data,
|
|
22
|
+
[id]: value,
|
|
23
|
+
});
|
|
24
|
+
}}
|
|
25
|
+
/>
|
|
26
|
+
)}
|
|
27
|
+
</SidebarPortal>
|
|
28
|
+
</>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default LayoutSettingsEdit;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BodyClass } from '@plone/volto/helpers';
|
|
3
|
+
import { getVoltoStyles } from '@eeacms/volto-eea-website-policy/components/Blocks/schema-utils';
|
|
4
|
+
import cx from 'classnames';
|
|
5
|
+
|
|
6
|
+
const LayoutSettingsView = (props) => {
|
|
7
|
+
const classNames = getVoltoStyles(props.data);
|
|
8
|
+
return <BodyClass className={cx(classNames)} />;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function propsAreEqual(prevProps, nextProps) {
|
|
12
|
+
return prevProps.data === nextProps.data;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default React.memo(LayoutSettingsView, propsAreEqual);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import codeSVG from '@plone/volto/icons/code.svg';
|
|
2
|
+
import LayoutSettingsView from './LayoutSettingsView';
|
|
3
|
+
import LayoutSettingsEdit from './LayoutSettingsEdit';
|
|
4
|
+
import BlockSettingsSchema from '@plone/volto/components/manage/Blocks/Block/Schema';
|
|
5
|
+
|
|
6
|
+
export default (config) => {
|
|
7
|
+
config.blocks.blocksConfig.layoutSettings = {
|
|
8
|
+
id: 'layoutSettings',
|
|
9
|
+
title: 'Layout settings',
|
|
10
|
+
icon: codeSVG,
|
|
11
|
+
group: 'common',
|
|
12
|
+
view: LayoutSettingsView,
|
|
13
|
+
edit: LayoutSettingsEdit,
|
|
14
|
+
schema: BlockSettingsSchema,
|
|
15
|
+
restricted: ({ properties }) => {
|
|
16
|
+
return !!properties['@type'];
|
|
17
|
+
},
|
|
18
|
+
mostUsed: true,
|
|
19
|
+
blockHasOwnFocusManagement: true,
|
|
20
|
+
sidebarTab: 1,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
return config;
|
|
24
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import imageNarrowSVG from '@eeacms/volto-eea-website-policy/components/Blocks/icons/image-narrow.svg';
|
|
2
|
+
import imageFitSVG from '@plone/volto/icons/image-fit.svg';
|
|
3
|
+
import imageWideSVG from '@plone/volto/icons/image-wide.svg';
|
|
4
|
+
|
|
5
|
+
export const ALIGN_INFO_MAP = {
|
|
6
|
+
narrow_view: [imageNarrowSVG, 'Narrow width'],
|
|
7
|
+
container_view: [imageFitSVG, 'Container width'],
|
|
8
|
+
wide_view: [imageWideSVG, 'Wide width'],
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const EditSchema = () => {
|
|
12
|
+
return {
|
|
13
|
+
title: 'Page layout settings',
|
|
14
|
+
fieldsets: [
|
|
15
|
+
{
|
|
16
|
+
id: 'default',
|
|
17
|
+
title: 'Default',
|
|
18
|
+
fields: ['layout_size'],
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
required: [],
|
|
22
|
+
properties: {
|
|
23
|
+
layout_size: {
|
|
24
|
+
widget: 'style_align',
|
|
25
|
+
title: 'Layout size',
|
|
26
|
+
actions: Object.keys(ALIGN_INFO_MAP),
|
|
27
|
+
actionsInfoMap: ALIGN_INFO_MAP,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const getVoltoStyles = (props) => {
|
|
2
|
+
// return an object with same key and value for cx class setting
|
|
3
|
+
const styles = props ? props : {};
|
|
4
|
+
const output = {};
|
|
5
|
+
for (const [key, value] of Object.entries(styles)) {
|
|
6
|
+
if (key === '@type') {
|
|
7
|
+
continue;
|
|
8
|
+
}
|
|
9
|
+
if (styles[key] === true) {
|
|
10
|
+
output[key] = key;
|
|
11
|
+
} else {
|
|
12
|
+
output[value] = value;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return output;
|
|
16
|
+
};
|
|
@@ -4,7 +4,7 @@ import imageFitSVG from '@plone/volto/icons/image-fit.svg';
|
|
|
4
4
|
import imageWideSVG from '@plone/volto/icons/image-wide.svg';
|
|
5
5
|
import imageFullSVG from '@plone/volto/icons/image-full.svg';
|
|
6
6
|
|
|
7
|
-
const ALIGN_INFO_MAP = {
|
|
7
|
+
export const ALIGN_INFO_MAP = {
|
|
8
8
|
narrow_width: [imageNarrowSVG, 'Narrow width'],
|
|
9
9
|
container_width: [imageFitSVG, 'Container width'],
|
|
10
10
|
wide_width: [imageWideSVG, 'Wide width'],
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { runtimeConfig } from '@plone/volto/runtime_config';
|
|
2
2
|
import installCallout from '@plone/volto-slate/editor/plugins/Callout';
|
|
3
3
|
import installContextNavigationBlock from '@eeacms/volto-eea-website-policy/components/Blocks/ContextNavigation';
|
|
4
|
+
import installLayoutSettingsBlock from '@eeacms/volto-eea-website-policy/components/Blocks/LayoutSettings';
|
|
4
5
|
import { addStylingFieldsetSchemaEnhancer } from '@eeacms/volto-eea-website-policy/components/Blocks/schema';
|
|
5
6
|
|
|
6
7
|
const applyConfig = (config) => {
|
|
@@ -107,14 +108,22 @@ const applyConfig = (config) => {
|
|
|
107
108
|
// Listing
|
|
108
109
|
if (config.blocks.blocksConfig.listing) {
|
|
109
110
|
config.blocks.blocksConfig.listing.title = 'Listing (Content)';
|
|
111
|
+
config.blocks.blocksConfig.listing.schemaEnhancer = addStylingFieldsetSchemaEnhancer;
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
// Custom blocks
|
|
115
|
+
// context navigation
|
|
113
116
|
config = [installContextNavigationBlock].reduce(
|
|
114
117
|
(acc, apply) => apply(acc),
|
|
115
118
|
config,
|
|
116
119
|
);
|
|
117
120
|
|
|
121
|
+
// layout settings
|
|
122
|
+
config = [installLayoutSettingsBlock].reduce(
|
|
123
|
+
(acc, apply) => apply(acc),
|
|
124
|
+
config,
|
|
125
|
+
);
|
|
126
|
+
|
|
118
127
|
// Disable some blocks
|
|
119
128
|
if (config.blocks.blocksConfig.imagecards) {
|
|
120
129
|
config.blocks.blocksConfig.imagecards.restricted = true;
|