diff --git a/packages/block-library/src/separator/block.json b/packages/block-library/src/separator/block.json
index 70060a329cdfd1..98bcbb9150609f 100644
--- a/packages/block-library/src/separator/block.json
+++ b/packages/block-library/src/separator/block.json
@@ -1,4 +1,12 @@
{
"name": "core/separator",
- "category": "layout"
+ "category": "layout",
+ "attributes": {
+ "color": {
+ "type": "string"
+ },
+ "customColor": {
+ "type": "string"
+ }
+ }
}
diff --git a/packages/block-library/src/separator/edit.js b/packages/block-library/src/separator/edit.js
index 26ca8d04f2295d..050bd7423fb665 100644
--- a/packages/block-library/src/separator/edit.js
+++ b/packages/block-library/src/separator/edit.js
@@ -1,8 +1,49 @@
+/**
+ * External dependencies
+ */
+import classnames from 'classnames';
+
/**
* WordPress dependencies
*/
+import { __ } from '@wordpress/i18n';
import { HorizontalRule } from '@wordpress/components';
+import {
+ InspectorControls,
+ withColors,
+ PanelColorSettings,
+} from '@wordpress/block-editor';
-export default function SeparatorEdit( { className } ) {
- return ;
+function SeparatorEdit( { color, setColor, className } ) {
+ return (
+ <>
+
+
+
+
+
+ >
+ );
}
+
+export default withColors( 'color', { textColor: 'color' } )( SeparatorEdit );
diff --git a/packages/block-library/src/separator/save.js b/packages/block-library/src/separator/save.js
index 72ddec8db51cee..d9b899486233c8 100644
--- a/packages/block-library/src/separator/save.js
+++ b/packages/block-library/src/separator/save.js
@@ -1,3 +1,41 @@
-export default function save() {
- return
;
+/**
+ * External dependencies
+ */
+import classnames from 'classnames';
+
+/**
+ * WordPress dependencies
+ */
+import {
+ getColorClassName,
+} from '@wordpress/block-editor';
+
+export default function separatorSave( { attributes } ) {
+ const {
+ color,
+ customColor,
+ } = attributes;
+
+ // the hr support changing color using border-color, since border-color
+ // is not yet supported in the color palette, we use background-color
+ const backgroundClass = getColorClassName( 'background-color', color );
+ // the dots styles uses text for the dots, to change those dots color is
+ // using color, not backgroundColor
+ const colorClass = getColorClassName( 'color', color );
+
+ const separatorClasses = classnames( {
+ 'has-text-color has-background': color || customColor,
+ [ backgroundClass ]: backgroundClass,
+ [ colorClass ]: colorClass,
+ } );
+
+ const separatorStyle = {
+ backgroundColor: backgroundClass ? undefined : customColor,
+ color: colorClass ? undefined : customColor,
+ };
+
+ return (
);
}
diff --git a/packages/block-library/src/separator/style.scss b/packages/block-library/src/separator/style.scss
index 57175b5f83bedb..a4cf1f2fdb6d27 100644
--- a/packages/block-library/src/separator/style.scss
+++ b/packages/block-library/src/separator/style.scss
@@ -8,7 +8,9 @@
// Dots style
&.is-style-dots {
- background: none; // Override any background themes often set on the hr tag for this style.
+ // Override any background themes often set on the hr tag for this style.
+ // also override the color set in the editor since it's intented for normal HR
+ background: none !important;
border: none;
text-align: center;
max-width: none;
@@ -17,7 +19,7 @@
&::before {
content: "\00b7 \00b7 \00b7";
- color: $dark-gray-900;
+ color: currentColor;
font-size: 20px;
letter-spacing: 2em;
padding-left: 2em;
diff --git a/packages/block-library/src/separator/theme.scss b/packages/block-library/src/separator/theme.scss
index 80834e1ebf8392..f0673d7bb6f5d4 100644
--- a/packages/block-library/src/separator/theme.scss
+++ b/packages/block-library/src/separator/theme.scss
@@ -8,4 +8,13 @@
&:not(.is-style-wide):not(.is-style-dots) {
max-width: 100px;
}
+
+ &.has-background:not(.is-style-dots) {
+ border-bottom: none;
+ height: 1px;
+ }
+
+ &.has-background:not(.is-style-wide):not(.is-style-dots) {
+ height: 2px;
+ }
}