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

Add "Spacer" block to create empty areas. #6121

Merged
merged 5 commits into from
May 2, 2018
Merged

Add "Spacer" block to create empty areas. #6121

merged 5 commits into from
May 2, 2018

Conversation

mtias
Copy link
Member

@mtias mtias commented Apr 11, 2018

In Progress

This PR adds a "spacer" block to add arbitrary space between blocks.

image

cc @melchoyce

@mtias mtias added [Feature] Blocks Overall functionality of blocks Customization Issues related to Phase 2: Customization efforts New Block Suggestion for a new block [Status] In Progress Tracking issues with work in progress labels Apr 11, 2018
@ZebulanStanphill
Copy link
Member

Is there any reason why the Divider block can't just have a setting to make the divider invisible and add the ability to change the height of the block?

box-sizing: border-box;
cursor: se-resize;
left: 50% !important;
margin-left: -7.5px;
Copy link
Member

Choose a reason for hiding this comment

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

Mixed whitespace.

display: none;
border-radius: 50%;
border: 2px solid white;
width: 15px !important;
Copy link
Member

Choose a reason for hiding this comment

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

Why !important ? Can we just add more specificity if we're trying to defeat some other style?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is coming from the re-resizable library — the image block does the same. We should wrap this library so this is handled for a block author, regardless of the !important.

return [
<ResizableBox
size={ {
height: height,
Copy link
Member

Choose a reason for hiding this comment

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

/>,
isSelected &&
<InspectorControls key="inspector">
<input
Copy link
Member

Choose a reason for hiding this comment

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

Assume we want a proper labeled control here, though guessing this is in progress.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we don't have an exposed control for a numbered input.

@mtias mtias force-pushed the add/spacer-block branch from 3047223 to 9f00437 Compare April 11, 2018 18:17
@karmatosed
Copy link
Member

In using this it feels pretty natural and what I would expect from a spacer. The only issue I felt was if it's the top block or there is no space to grow above, it feels a little odd when you drag from the top but it grows from the bottom. I now also don't like this in images, but this totally could be a personal comment as I'm interacting and totally not a blocker.

@melchoyce
Copy link
Contributor

I dig it!

@mtias mtias force-pushed the add/spacer-block branch from 9f00437 to 4b5500f Compare May 1, 2018 10:58
@mtias
Copy link
Member Author

mtias commented May 1, 2018

@SuperGeniusZeb it sounds harder to discover and generally more convoluted than a separate single purpose block. We could add transforms from a separator to a spacer, though, that sounds very useful.

@mtias mtias removed the [Status] In Progress Tracking issues with work in progress label May 1, 2018
@mtias mtias added this to the 2.8 milestone May 1, 2018
edit( { attributes, setAttributes, isSelected, toggleSelection } ) {
const { height } = attributes;

return [
Copy link
Member

Choose a reason for hiding this comment

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

I refactored all existing blocks to use <Fragment /> component instead of [] to avoid using key attributes and to be consistent. Can we update this block, too?

What do you think about having edit method in its own file? It was raised by the mobile team, as they experiment with replacing edit method with RN alternatives. See #5816 for reference. It would help them immensely to iterate before we come up with a set of primitives and other restrictions (if ever).

Copy link
Member Author

Choose a reason for hiding this comment

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

For "edit" we have to sort out block server registration. It could be a possibility.

@mtias mtias force-pushed the add/spacer-block branch from cbe6d5b to 979d675 Compare May 2, 2018 12:43
bottom: 'wp-block-spacer__resize-handler-bottom',
} }
enable={ {
top: true,
Copy link
Member

Choose a reason for hiding this comment

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

Sidenote: so bad API which enforces you to provide all those false values ...

Copy link
Member Author

Choose a reason for hiding this comment

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

@gziolo yes :( At the very least we should abstract this with our own component. I also don't like the styles I had to supply.

@gziolo
Copy link
Member

gziolo commented May 2, 2018

We should look later in separate PR how to extract ResizableBox and move to wp.components and wrap with our own simplified API :)

This component looks good 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Customization Issues related to Phase 2: Customization efforts [Feature] Blocks Overall functionality of blocks New Block Suggestion for a new block
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants