Skip to content

Commit

Permalink
feat(ColumnsBlockEdit.jsx): add eraser icon for delete column style b…
Browse files Browse the repository at this point in the history
…utton

fix(ColumnsBlockEdit.jsx): refactor deleteColumnStyle function to be a class method and use it in delete column style button click event
  • Loading branch information
razvanMiu committed Apr 5, 2023
1 parent d6ff598 commit f966f37
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
41 changes: 22 additions & 19 deletions src/ColumnsBlock/ColumnsBlockEdit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ import { makeStyleSchema, getStyle } from '../Styles';

import tuneSVG from '@plone/volto/icons/column.svg';
import upSVG from '@plone/volto/icons/up.svg';
import deleteSVG from '@plone/volto/icons/delete.svg';

import eraserSVG from './icons/eraser.svg';
import '../less/columns.less';

const messages = defineMessages({
Expand Down Expand Up @@ -176,6 +175,25 @@ class ColumnsBlockEdit extends React.Component {
}
};

deleteColumnStyle = () => {
const colId = this.state.activeColumn;
const { onChangeBlock, block, data } = this.props;
const coldata = data.data;
onChangeBlock(block, {
...data,
data: {
...coldata,
blocks: {
...coldata.blocks,
[colId]: {
...coldata.blocks?.[colId],
settings: {},
},
},
},
});
};

onSelectBlock = (
id,
colId,
Expand Down Expand Up @@ -513,26 +531,11 @@ class ColumnsBlockEdit extends React.Component {
/>
</Button>
<button
onClick={() => {
const colId = this.state.activeColumn;
onChangeBlock(block, {
...data,
data: {
...coldata,
blocks: {
...coldata.blocks,
[colId]: {
...coldata.blocks?.[colId],
settings: {},
},
},
},
});
}}
onClick={this.deleteColumnStyle}
style={{ cursor: 'pointer' }}
>
<Icon
name={deleteSVG}
name={eraserSVG}
size="24px"
title="Delete column style"
/>
Expand Down
3 changes: 3 additions & 0 deletions src/ColumnsBlock/icons/eraser.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f966f37

Please sign in to comment.