generated from eea/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change(policy): added styling schema as a block enhancer useful for s…
…everal packages
- Loading branch information
1 parent
6670763
commit 1cc294f
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { cloneDeep } from 'lodash'; | ||
import imageFitSVG from '@eeacms/volto-eea-website-policy/components/Blocks/icons/image-narrow.svg'; | ||
import imageWideSVG from '@plone/volto/icons/image-wide.svg'; | ||
import imageFullSVG from '@plone/volto/icons/image-full.svg'; | ||
|
||
const ALIGN_INFO_MAP = { | ||
narrow_width: [imageFitSVG, 'Narrow width'], | ||
container_width: [imageFitSVG, 'Container width'], | ||
wide_width: [imageWideSVG, 'Wide width'], | ||
full: [imageFullSVG, 'Full width'], | ||
}; | ||
|
||
export const addStylingFieldsetSchemaEnhancer = ({ schema }) => { | ||
const applied = schema?.properties?.styles; | ||
|
||
if (!applied) { | ||
const resSchema = cloneDeep(schema); | ||
|
||
resSchema.fieldsets.push({ | ||
id: 'styling', | ||
fields: ['styles'], | ||
title: 'Styling', | ||
}); | ||
resSchema.properties.styles = { | ||
widget: 'object', | ||
title: 'Styling', | ||
schema: { | ||
fieldsets: [ | ||
{ | ||
id: 'default', | ||
title: 'Default', | ||
fields: ['size'], | ||
}, | ||
], | ||
properties: { | ||
size: { | ||
widget: 'style_align', | ||
title: 'Section size', | ||
actions: Object.keys(ALIGN_INFO_MAP), | ||
actionsInfoMap: ALIGN_INFO_MAP, | ||
}, | ||
}, | ||
required: [], | ||
}, | ||
}; | ||
return resSchema; | ||
} | ||
|
||
return schema; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters