Skip to content

Commit

Permalink
breaking(columns): removed extra div that wrapped the column children
Browse files Browse the repository at this point in the history
- it was added to set padding custom padding for that column area but we
  can simply add the padding as inline style to the column just like we
  do with background color and vertical align
  • Loading branch information
ichim-david committed Nov 7, 2023
1 parent 69b8fd5 commit a9a4b00
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 35 deletions.
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-columns-block",
"version": "6.4.0",
"version": "7.0.0",
"description": "volto-columns-block: Volto add-on",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand Down
1 change: 1 addition & 0 deletions src/ColumnsBlock/ColumnVariations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ test('renders column variations component', () => {
intl: {
locale: 'en',
formatMessage: () => 'Select layout',
messages: {},
},
});

Expand Down
34 changes: 6 additions & 28 deletions src/ColumnsBlock/ColumnsBlockView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@ import cx from 'classnames';
import { getColumns } from './utils';
import { getStyle } from '@eeacms/volto-columns-block/Styles';

const getSide = (side, v) => {
const v_unit = v.unit ? v.unit : 'px';
return `${v?.[side] ? `${v[side]}${v_unit}` : '0'}`;
};

const getSides = (v) => {
return `${getSide('top', v)} ${getSide('right', v)} ${getSide(
'bottom',
v,
)} ${getSide('left', v)}`;
};

const ColumnsBlockView = (props) => {
const location = useLocation();
const { gridSizes } = config.blocks.blocksConfig[COLUMNSBLOCK];
Expand Down Expand Up @@ -52,22 +40,12 @@ const ColumnsBlockView = (props) => {
)}
{...getStyle(column.settings || {})}
>
<div
style={
column.settings?.padding
? {
padding: getSides(column.settings?.padding),
}
: {}
}
>
<RenderBlocks
{...props}
location={location}
metadata={metadata}
content={column}
/>
</div>
<RenderBlocks
{...props}
location={location}
metadata={metadata}
content={column}
/>
</Grid.Column>
);
})}
Expand Down
8 changes: 2 additions & 6 deletions src/ColumnsBlock/__snapshots__/ColumnsBlockView.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ exports[`renders 2 columns 1`] = `
<div
class="six wide computer twelve wide mobile six wide tablet column column-blocks-wrapper"
>
<div>
left marker
</div>
left marker
</div>
<div
class="six wide computer twelve wide mobile six wide tablet column column-blocks-wrapper"
>
<div>
right
</div>
right
</div>
</div>
</div>
Expand Down
14 changes: 14 additions & 0 deletions src/Styles/utils.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
const getSide = (side, v) => {
const v_unit = v.unit ? v.unit : 'px';
return `${v?.[side] ? `${v[side]}${v_unit}` : '0'}`;
};

const getSides = (v) => {
if (!v) return null;
return `${getSide('top', v)} ${getSide('right', v)} ${getSide(
'bottom',
v,
)} ${getSide('left', v)}`;
};

export function getStyle(props) {
return {
verticalAlign: props.grid_vertical_align,
style: {
backgroundColor: props.backgroundColor,
padding: getSides(props.padding),
},
};
}

0 comments on commit a9a4b00

Please sign in to comment.