Skip to content
This repository has been archived by the owner on Feb 17, 2025. It is now read-only.

Blockbase: remove margin-top from first descendants of columns and groups #4436

Merged
merged 3 commits into from
Aug 26, 2021

Conversation

jffng
Copy link
Contributor

@jffng jffng commented Aug 17, 2021

Changes proposed in this Pull Request:

This PR removes the top margin of first children of columns and groups. It started as an exploration to add a default padding to all groups with borders.

Related issue(s):

Helps with #4412

@jffng jffng added the [Theme] Skatepark Automatically generated label for Skatepark. label Aug 17, 2021
@jffng jffng requested review from melchoyce and a team August 17, 2021 21:08
@@ -1,4 +1,12 @@
// Text selection text color
::selection {
color: var(--wp--preset--color--background);
}

.wp-block-column, .wp-block-group {
Copy link
Contributor Author

@jffng jffng Aug 17, 2021

Choose a reason for hiding this comment

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

These styles might better belong if blockbase, but I'm not sure about this idea in general.

My reasoning for adding it is — I don't think that the first piece of text should have a top margin when contained in a column or group, because it ends up stacking if there is a padding declared. But maybe there is a better way of solving this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we would do this for every theme, it feels kind of opinionated, it makes sense for Skatepark because of the border but that's it. When I first saw the pattern using the border I was thinking about it having a block style even but this approach makes sense too, but just in the scope of this specific theme.

Copy link
Contributor

@kjellr kjellr Aug 18, 2021

Choose a reason for hiding this comment

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

... it makes sense for Skatepark because of the border but that's it.

Since Blockbase opts into border controls, there's a UI for users to create this bordered effect on any Group block though — using Blockbase or any of its children.

I don't love these rules (and I hope Gutenberg adds greater per-block margin controls so folks can manually fix this sort of thing in the editor), but I think if we add these, they should be in Blockbase.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, putting them in Blockbase would mean more universal expectations around this behavior for our themes, and also would make it easier to strip this out if it's not needed in the future. (Or if we come up with a better solution)

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, I see what you mean, I don't like it but I agree, and having it on Blockbase is easier to control and go back to it when it eventually can be done better. I just hope we don't have to do this too much, Blockbase is growing instead of shrinking.

@jffng
Copy link
Contributor Author

jffng commented Aug 20, 2021

I tinkered with this some more and am coming to a different conclusion — I don't think we should add these rules at all. My reasoning:

  • This PR should solve the editor and front-end mismatch reported in the original issue.
  • The .has-border-color class is only applied when a border color is specified. The default border is applied via inline css directly to the element, so we do not have a reliable way to add padding to all groups with borders because not all of them have the has-border-color class.

That leaves us with two options:

  1. Apply a default padding to all group blocks via theme.json. This approach seems like it could be okay, because the user can overwrite this default padding it in the block inspector.
  2. Apply the padding in our patterns via the group's block style attributes, as we're doing here:
    <!-- wp:group {"align":"wide","style":{"border":{"style":"solid"},"spacing":{"padding":{"top":"1%","right":"2.5%","bottom":"2.5%","left":"2.5%"}}},"className":"skatepark-mixed-media-in-container"} -->
    The downside here is that if a user creates a group block and adds a border on their own, it will have no padding and they will have to add it themselves.

@scruffian scruffian force-pushed the fix/skatepark-group-border-padding branch from 4bbe6a2 to 34fd79b Compare August 25, 2021 07:28
@scruffian
Copy link
Member

I agree that these rules should live in blockbase. I have removed the border rules from skatepark altogether, I agree that they should live in the pattern.

@jffng jffng force-pushed the fix/skatepark-group-border-padding branch from 2645a50 to 72f4aad Compare August 25, 2021 15:43
@jffng
Copy link
Contributor Author

jffng commented Aug 25, 2021

Hi @melchoyce — would you mind retesting with the markup you provided in #4412?

To simplify my long winded comment above, we do not have a reliable way to add padding to groups with borders. Despite this, I think this PR is still an improvement.

@jffng jffng changed the title Skatepark: fix group block with border padding Blockbase: remove margin-top from first descendants of columns and groups Aug 25, 2021
@melchoyce
Copy link
Contributor

Just checking, the end goal is it should look like this by default?

image

@jffng
Copy link
Contributor Author

jffng commented Aug 25, 2021

That's right.

@melchoyce
Copy link
Contributor

Cool. Let's merge this, and talk about this option more when @kjellr is back:

Apply a default padding to all group blocks via theme.json. This approach seems like it could be okay, because the user can overwrite this default padding it in the block inspector.

We should also consider bumping this issue upstream, if that's possible (I might be understanding the problem)

@scruffian
Copy link
Member

We should also consider bumping this issue upstream, if that's possible (I might be understanding the problem)

Added an issue for this WordPress/gutenberg#34315

@scruffian scruffian merged commit 45bb8e3 into trunk Aug 26, 2021
@scruffian scruffian deleted the fix/skatepark-group-border-padding branch August 26, 2021 07:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
[Theme] Skatepark Automatically generated label for Skatepark.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants