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 margin support to Separator block #28451

Closed
wants to merge 3 commits into from

Conversation

stokesman
Copy link
Contributor

Some folks would like to be able to control the height of the Separator block #25989. This PR enables that by adding support for custom margins. It depends on the changes from #25988 that introduce the margin support flag and also includes those for ease of testing.

Testing this requires a theme that enables Spacing block support so Twenty Twenty One is a good one.

This would, I think, satisfy and close #25989.

How has this been tested?

Trying various margin settings on a Separator block and previewing on the frontend.

Screenshots

separator-margin.mp4

Types of changes

feature

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

achariyska and others added 2 commits January 23, 2021 18:18
Adding visualizers for margin

Visualizer for inner blocks

remove padding visualizer flickering

fix spread values

extract styles to a separate configuration object

Allow auto margin unit

Fix spreading of values

Patch Current UnitControl

Allow only margin to have an auto value

unit validation

fixed dragging on spacing units

fixed unlink on default state

fix: Initial value not set up
@stokesman stokesman changed the title Add margin support separator to Separator block Add margin support to Separator block Jan 25, 2021
@paaljoachim
Copy link
Contributor

paaljoachim commented Jan 25, 2021

Wow I did not even think of that!
What a super interesting idea to use margin to better control where the line shows up in the Separator block!
Margin can also be used for changing the width of the line in addition to having space below or above the line.

Margin creates a multi faceted approach to width, alignment (want the line to the left add a lot of right margin), and placement of space. It gives the user a lot of creativity in how to design the separator line.

Now would using padding change the thickness of the line?

I believe that the PR would need some feedback
@ItsJonQ @jasmussen
To get some perspective on the design tools used in such a way.

@stokesman
Copy link
Contributor Author

Now would using padding change the thickness of the line?

It does but not in all cases as it depends on the block style (and CSS implementation) of the line. The Dots style just gets space added around it. Then there are cases like Twenty Twenty style of separator:
image
The slanted pair of lines in the center are pseudo-elements so aren't affected. While they could be styled to inherit padding I don't think using padding to support line weight/thickness is a technically or conceptually sound way to do so.

I'd actually tried using padding to support only the height control feature a few months ago but it was too tricky to make it work for all styles of separator (I was aiming to maintain their thickness and only adjust spacing).

@paaljoachim
Copy link
Contributor

Jon @ItsJonQ and Joen @jasmussen would probably want to know about the PR as well.

@jasmussen
Copy link
Contributor

Cool work! Thanks for all your effort 🏅

There's an important conversation to be had about how spacing like this should be a global style property that can then be enabled on a per-block basis. Both because I could see spacing properties be surfaced on many more blocks than just the separator, but also because for that to happen in a way that doesn't explode the sidebar interface, we need a design and system for surfacing such controls in the sidebar.

#27331 just happens to touch on both of those issues.

So my primary question here isn't around the feature — big fan — but rather about the order in which we do things. If we do this now, for the separator block, does that cause headaches for us in the future when a spacing block property lands in global styles and becomes more of an opt-in?

Something to think about, and when you feel this is ready for more eyes, maybe ping the gutenberg-core group for review!

@stokesman
Copy link
Contributor Author

@jasmussen Thanks for the thoughts. I'm not sure the feedback is entirely applicable. In this PR, the spacing support is added by a block support property and can be theme-controlled (which seems to be the same thing you are referring to as a global style property, not sure).

I have no strong opinion about this feature. The PR was made as an exploration to offer a different approach to #28409. To which your feedback may be more relevant as it adds the feature and controls in an ad hoc manner.

@skorasaurus skorasaurus added the [Block] Separator Affects the Separator Block label Feb 23, 2021
Base automatically changed from master to trunk March 1, 2021 15:45
@stokesman stokesman closed this Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Separator Affects the Separator Block
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Controlling the height of the Separator block
5 participants