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

Fix separator and spacer blocks after api v2 refactoring. #26157

Merged
merged 2 commits into from
Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 8 additions & 8 deletions packages/block-library/src/separator/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ import SeparatorSettings from './separator-settings';
function SeparatorEdit( { color, setColor, className } ) {
return (
<>
<div { ...useBlockProps() }>
<HorizontalRule
className={ classnames( className, {
<HorizontalRule
{ ...useBlockProps( {
className: classnames( className, {
'has-background': color.color,
[ color.class ]: color.class,
} ) }
style={ {
} ),
style: {
backgroundColor: color.color,
color: color.color,
} }
/>
</div>
},
} ) }
/>
<SeparatorSettings color={ color } setColor={ setColor } />
</>
);
Expand Down
5 changes: 3 additions & 2 deletions packages/block-library/src/spacer/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { PanelBody, ResizableBox, RangeControl } from '@wordpress/components';
import { compose, withInstanceId } from '@wordpress/compose';
import { withDispatch } from '@wordpress/data';
import { useState } from '@wordpress/element';
import { View } from '@wordpress/primitives';

const MIN_SPACER_HEIGHT = 1;
const MAX_SPACER_HEIGHT = 500;
Expand Down Expand Up @@ -48,7 +49,7 @@ const SpacerEdit = ( {

return (
<>
<div { ...useBlockProps() }>
Copy link
Member

Choose a reason for hiding this comment

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

Ideally we should avoid this and make the wrapper itself resizable. I'll look into that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, I tried it and I believe there's something with the "ref" not being forwarded properly to the third-party dependency.

<View { ...useBlockProps() }>
<ResizableBox
className={ classnames(
'block-library-spacer__resize-container',
Expand Down Expand Up @@ -80,7 +81,7 @@ const SpacerEdit = ( {
isVisible: isResizing,
} }
/>
</div>
</View>
<InspectorControls>
<PanelBody title={ __( 'Spacer settings' ) }>
<RangeControl
Expand Down
1 change: 1 addition & 0 deletions packages/primitives/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './svg';
export * from './horizontal-rule';
export * from './block-quotation';
export * from './view';
3 changes: 3 additions & 0 deletions packages/primitives/src/view/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# View

A drop-in replacement for the div element that works across devices.
Copy link
Contributor

Choose a reason for hiding this comment

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

Really like this 😍

1 change: 1 addition & 0 deletions packages/primitives/src/view/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const View = 'div';
4 changes: 4 additions & 0 deletions packages/primitives/src/view/index.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* External dependencies
*/
export { View } from 'react-native';