Skip to content

Commit c3f44dd

Browse files
Update separator block to use margin block support
1 parent aa15ff1 commit c3f44dd

File tree

4 files changed

+6
-59
lines changed

4 files changed

+6
-59
lines changed

packages/block-library/src/separator/block.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
},
99
"customColor": {
1010
"type": "string"
11-
},
12-
"style": {
13-
"type": "object"
1411
}
1512
},
1613
"supports": {
1714
"anchor": true,
18-
"align": ["center","wide","full"]
15+
"align": ["center","wide","full"],
16+
"spacing": {
17+
"margin": [ "top", "bottom" ]
18+
}
1919
},
2020
"editorStyle": "wp-block-separator-editor",
2121
"style": "wp-block-separator"

packages/block-library/src/separator/edit.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ function SeparatorEdit( props ) {
3939
'wp-block-separator',
4040
'wp-block-separator-wrapper'
4141
) }
42+
style={ {} }
4243
>
4344
<BoxControlVisualizer
4445
values={ style?.spacing?.margin }

packages/block-library/src/separator/save.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ export default function separatorSave( { attributes } ) {
2727
const style = {
2828
backgroundColor: backgroundClass ? undefined : customColor,
2929
color: colorClass ? undefined : customColor,
30-
marginBottom: attributes.style?.spacing?.margin?.bottom,
31-
marginTop: attributes.style?.spacing?.margin?.top,
3230
};
3331

3432
return <hr { ...useBlockProps.save( { className, style } ) } />;

packages/block-library/src/separator/separator-settings.js

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,8 @@
33
*/
44
import { __ } from '@wordpress/i18n';
55
import { InspectorControls, PanelColorSettings } from '@wordpress/block-editor';
6-
import {
7-
PanelBody,
8-
__experimentalBoxControl as BoxControl,
9-
} from '@wordpress/components';
10-
11-
/**
12-
* Internal dependencies
13-
*/
14-
import { CSS_UNITS } from './shared';
15-
16-
const SeparatorSettings = ( {
17-
color,
18-
setColor,
19-
attributes: { style },
20-
setAttributes,
21-
} ) => {
22-
const updateMargins = ( { top, bottom } ) => {
23-
setAttributes( {
24-
style: {
25-
...style,
26-
spacing: {
27-
...style?.spacing,
28-
margin: { top, bottom },
29-
},
30-
},
31-
} );
32-
};
33-
34-
const onChangeShowVisualizer = ( { top, bottom } ) => {
35-
setAttributes( {
36-
style: {
37-
...style,
38-
visualizers: {
39-
margin: { top, bottom },
40-
},
41-
},
42-
} );
43-
};
446

7+
const SeparatorSettings = ( { color, setColor } ) => {
458
return (
469
<InspectorControls>
4710
<PanelColorSettings
@@ -54,21 +17,6 @@ const SeparatorSettings = ( {
5417
},
5518
] }
5619
/>
57-
<PanelBody title={ __( 'Separator settings' ) }>
58-
<BoxControl
59-
label={ __( 'Margin' ) }
60-
onChange={ updateMargins }
61-
sides={ {
62-
top: true,
63-
right: false,
64-
bottom: true,
65-
left: false,
66-
} }
67-
units={ CSS_UNITS }
68-
values={ style?.spacing?.margin || {} }
69-
onChangeShowVisualizer={ onChangeShowVisualizer }
70-
/>
71-
</PanelBody>
7220
</InspectorControls>
7321
);
7422
};

0 commit comments

Comments
 (0)