Skip to content

Commit

Permalink
Add custom class for columns
Browse files Browse the repository at this point in the history
  • Loading branch information
kreafox committed Oct 12, 2021
1 parent 35aa796 commit 0e4783f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/ColumnsBlock/ColumnsBlockView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import config from '@plone/volto/registry';
import { Grid } from 'semantic-ui-react';
import { RenderBlocks } from '@plone/volto/components';
import { COLUMNSBLOCK } from '@eeacms/volto-columns-block/constants';
import cx from 'classnames';

import { getColumns } from './utils';
import { getStyle } from '@eeacms/volto-columns-block/Styles';
Expand All @@ -17,6 +18,7 @@ const ColumnsBlockView = (props) => {
?.replace(/[^a-zA-Z-\s]/gi, '')
?.trim()
?.replace(/\s+/gi, '-');

return (
<div className="columns-view" id={customId}>
<Grid columns={gridSize} className="column-grid">
Expand All @@ -25,7 +27,10 @@ const ColumnsBlockView = (props) => {
<Grid.Column
key={id}
{...(gridSizes[gridCols[index]] || gridCols[index])}
className="column-blocks-wrapper"
className={cx(
'column-blocks-wrapper',
column.settings?.column_class,
)}
{...getStyle(column.settings || {})}
>
<RenderBlocks {...props} metadata={metadata} content={column} />
Expand Down
6 changes: 5 additions & 1 deletion src/Styles/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const StyleSchema = () => ({
{
id: 'default',
title: 'Style',
fields: ['backgroundColor', 'grid_vertical_align'],
fields: ['backgroundColor', 'grid_vertical_align', 'column_class'],
},
],
properties: {
Expand All @@ -21,6 +21,10 @@ export const StyleSchema = () => ({
['top', 'Top'],
],
},
column_class: {
title: 'Custom CSS Class',
description: 'A custom CSS class, aplicable to this column',
},
},
required: [],
});
Expand Down

0 comments on commit 0e4783f

Please sign in to comment.