Skip to content

Commit

Permalink
refactor(Styling): Use schemaEnhancer in favor of StyleWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
avoinea committed Nov 15, 2022
1 parent 176d6fe commit e6506d6
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 32 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@

## Features

###

![Divider](https://github.com/eea/volto-block-divider/raw/develop/docs/divider.gif)

## Upgrade

### Upgrading to 5.x

This version requires: `@plone/volto >= 16.0.0.alpha.46` (schemaEnhancer / addStyling).

## Getting started

1. Create new volto project if you don't already have one:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-block-divider",
"version": "4.0.0",
"version": "5.0.0",
"description": "volto-block-divider: Volto add-on",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand Down
60 changes: 33 additions & 27 deletions src/components/Divider/Schema.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineMessages } from 'react-intl';
import { addStyling } from '@plone/volto/helpers';

const messages = defineMessages({
Type: {
Expand Down Expand Up @@ -130,31 +131,36 @@ export const DividerEditSchema = ({ intl }) => ({
required: [],
});

export const DividerStylingSchema = ({ intl }) => ({
title: intl.formatMessage(messages.Type),
block: 'divider',
fieldsets: [
{
id: 'default',
title: 'Default',
fields: ['theme', 'inverted'],
},
],
properties: {
theme: {
title: intl.formatMessage(messages.Theme),
description: intl.formatMessage(messages.ThemeHelp),
choices: [
['primary', intl.formatMessage(messages.ThemePrimary)],
['secondary', intl.formatMessage(messages.ThemeSecondary)],
['tertiary', intl.formatMessage(messages.ThemeTertiary)],
],
},
inverted: {
title: intl.formatMessage(messages.Inverted),
description: intl.formatMessage(messages.InvertedHelp),
type: 'boolean',
export const DividerStylingSchema = (args) => {
const schema = addStyling(args);
const { intl } = args;
schema.properties.styles.schema = {
title: intl.formatMessage(messages.Type),
block: 'divider',
fieldsets: [
{
id: 'default',
title: 'Default',
fields: ['theme', 'inverted'],
},
],
properties: {
theme: {
title: intl.formatMessage(messages.Theme),
description: intl.formatMessage(messages.ThemeHelp),
choices: [
['primary', intl.formatMessage(messages.ThemePrimary)],
['secondary', intl.formatMessage(messages.ThemeSecondary)],
['tertiary', intl.formatMessage(messages.ThemeTertiary)],
],
},
inverted: {
title: intl.formatMessage(messages.Inverted),
description: intl.formatMessage(messages.InvertedHelp),
type: 'boolean',
},
},
},
required: [],
});
required: [],
};
return schema;
};
3 changes: 1 addition & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ export default (config) => {
view: DividerView,
edit: DividerEdit,
editSchema: DividerEditSchema,
stylesSchema: DividerStylingSchema,
schemaEnhancer: DividerStylingSchema,
restricted: false,
mostUsed: false,
sidebarTab: 1,
enableStyling: true,
security: {
addPermission: [],
view: [],
Expand Down

0 comments on commit e6506d6

Please sign in to comment.