Skip to content

Commit

Permalink
Accordion schema
Browse files Browse the repository at this point in the history
  • Loading branch information
sneridagh committed Jun 28, 2023
1 parent f8e4d66 commit 8002387
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/components/Blocks/Accordion/schema.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@ const messages = defineMessages({
});

export function AccordionSchemaEnhancer({ schema, formData, intl }) {
schema.required = [];
// Opinionated removal of the options fieldset
schema.fieldsets = schema.fieldsets.filter((item) => item.id !== 'options');

// Some other opinionated defaults
schema.required = [];
schema.properties.right_arrows.default = true;
schema.properties.collapsed.default = false;
schema.properties.non_exclusive.default = false;

// Add headline - TODO: Remove when https://github.com/eea/volto-accordion-block/pull/71
// is merged
schema.fieldsets[0].fields = ['headline', ...schema.fieldsets[0].fields];
schema.properties.headline = {
title: intl.formatMessage(messages.headline),
};

return schema;
}
1 change: 1 addition & 0 deletions src/components/Blocks/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ export const defaultStylingSchema = ({ schema, formData, intl }) => {
colors,
default: defaultBGColor,
};

return schema;
};
17 changes: 16 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,22 @@ const applyConfig = (config) => {
...config.blocks.blocksConfig.accordion,
icon: accordionSVG,
allowedBlocks: ['slate', 'teaser', 'image', 'listing', 'slateTable'],
schemaEnhancer: AccordionSchemaEnhancer,
colors: BG_COLORS,
schemaEnhancer: composeSchema(
AccordionSchemaEnhancer,
defaultStylingSchema,
),
sidebarTab: 1,
blocksConfig: {
...config.blocks.blocksConfig,
teaser: {
...config.blocks.blocksConfig.teaser,
schemaEnhancer: composeSchema(
gridTeaserDisableStylingSchema,
teaserSchemaEnhancer,
),
},
},
};

config.blocks.blocksConfig.__grid = {
Expand Down

0 comments on commit 8002387

Please sign in to comment.