Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract separator component out of nextpage block #14175

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/block-library/src/nextpage/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { Separator } from '@wordpress/components';

export default function NextPageEdit() {
return (
<div className="wp-block-nextpage">
<span>{ __( 'Page break' ) }</span>
</div>
<Separator customText={ __( 'Page break' ) } />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this moment it might be considered as a breaking change to stop using wp-block-nextpage class in here. I'm sure that themes already apply their customizations based on this class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be fine to pass a className prop to Separator and have it render it that way, or do we want to ensure there's a wrapper div around whatever the implementation for separator is?

);
}
31 changes: 0 additions & 31 deletions packages/block-library/src/nextpage/editor.scss
Original file line number Diff line number Diff line change
@@ -1,34 +1,3 @@
.editor-visual-editor__block[data-type="core/nextpage"] {
max-width: 100%;
}

.wp-block-nextpage {
display: block;
text-align: center;
white-space: nowrap;

// Label
> span {
font-size: $default-font-size;
position: relative;
display: inline-block;
text-transform: uppercase;
font-weight: 600;
font-family: $default-font;
color: $dark-gray-300;
border-radius: 4px;
background: $white;
padding: 6px 8px;
height: $icon-button-size-small;
}

// Dashed line
&::before {
content: "";
position: absolute;
top: calc(50%);
left: 0;
right: 0;
border-top: 3px dashed $light-gray-700;
}
}
1 change: 1 addition & 0 deletions packages/components/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export { default as ResizableBox } from './resizable-box';
export { default as ResponsiveWrapper } from './responsive-wrapper';
export { default as SandBox } from './sandbox';
export { default as SelectControl } from './select-control';
export { default as Separator } from './separator';
export { default as Spinner } from './spinner';
export { default as ServerSideRender } from './server-side-render';
export { default as TabPanel } from './tab-panel';
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export { default as Spinner } from './spinner';
export { createSlotFill, Slot, Fill, Provider as SlotFillProvider } from './slot-fill';
export { default as BaseControl } from './base-control';
export { default as TextareaControl } from './textarea-control';
export { default as Separator } from './separator';

// Higher-Order Components
export { default as withFilters } from './higher-order/with-filters';
Expand Down
10 changes: 10 additions & 0 deletions packages/components/src/separator/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

export default function Separator( props ) {
const { customText } = props;

return (
<div className="components-separator">
{ customText && ( <span>{ customText }</span> ) }
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@
import { View } from 'react-native';
import Hr from 'react-native-hr';

/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import styles from './editor.scss';
import styles from './style.scss';

export default function NextPageEdit( { attributes } ) {
const { customText = __( 'Page break' ) } = attributes;
export default function Separator( props ) {
const { customText } = props;

return (
<View style={ styles[ 'block-library-nextpage__container' ] }>
Expand Down
30 changes: 30 additions & 0 deletions packages/components/src/separator/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.components-separator {
display: block;
text-align: center;
white-space: nowrap;

// Label
> span {
font-size: $default-font-size;
position: relative;
display: inline-block;
text-transform: uppercase;
font-weight: 600;
font-family: $default-font;
color: $dark-gray-300;
border-radius: 4px;
background: $white;
padding: 6px 8px;
height: $icon-button-size-small;
}

// Dashed line
&::before {
content: "";
position: absolute;
top: calc(50%);
left: 0;
right: 0;
border-top: 3px dashed $light-gray-700;
}
}
1 change: 1 addition & 0 deletions packages/components/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
@import "./sandbox/style.scss";
@import "./scroll-lock/style.scss";
@import "./select-control/style.scss";
@import "./separator/style.scss";
@import "./spinner/style.scss";
@import "./text-control/style.scss";
@import "./textarea-control/style.scss";
Expand Down