Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

Columns Block: Try adding a "negative margins" block style #337

Merged
merged 18 commits into from
Oct 8, 2020

Conversation

kjellr
Copy link
Collaborator

@kjellr kjellr commented Oct 7, 2020

This was an idea I had to achieve a couple of the block styles in #50.

Image underlapping text box Two overlapping blocks of text

The PR adds a "Overlap" block style to the columns block that applies a negative margin to each second column. It looks really weird in the preview:

Screen Shot 2020-10-07 at 2 59 57 PM

But you can do some interesting things with it:

Screen Shot 2020-10-07 at 2 55 38 PM

It also lets you achieve something similar to #277, but by using single image blocks and spacers:

Screen Shot 2020-10-07 at 3 05 34 PM

In general, it seems a little hacky to me, but I like the effect, so I'm curious what others think.

@kjellr kjellr changed the title Try adding a "negative margins" block style Columns Block: Try adding a "negative margins" block style Oct 7, 2020
@kjellr kjellr self-assigned this Oct 7, 2020
@kjellr kjellr added [Component] Block patterns Issues related to block patterns shipped with theme [Component] Default blocks Issues related to adjusting default blocks Design labels Oct 7, 2020
@melchoyce
Copy link
Contributor

Looks cool, fun to play around with 👍

I wonder if this should also be a style on the Media & Text block?

@kjellr
Copy link
Collaborator Author

kjellr commented Oct 7, 2020

I wonder if this should also be a style on the Media & Text block?

It definitely could be. I'll give it a try tomorrow.

@kjellr
Copy link
Collaborator Author

kjellr commented Oct 8, 2020

I wonder if this should also be a style on the Media & Text block?

@melchoyce I tried a quick version of this, but I think it's a little less suited for that block for a couple reasons:

  • The block uses a CSS grid which is defined inline. So in order to replace that grid rule with a grid that allows for overlap, I need to use an !important rule. Unfortunately, an !important rule prevents the image area from being resized properly.
  • Even though the block can't be resized with this implementation, the control is still present, and it overlaps the overlapping content. 😄

media-text

@carolinan
Copy link
Contributor

I like these column effects, can you share some screenshots of the responsive view?

@kjellr
Copy link
Collaborator Author

kjellr commented Oct 8, 2020

can you share some screenshots of the responsive view?

By default, the columns block stacks its columns below ~600px wide, and this PR doesn't change that. So these new styles only apply on screens larger than that.

Mobile 760px 1024px 1400px
gutenberg test__p=1 preview_id=1 preview_nonce=eb614508dd preview=true gutenberg test__p=1 preview_id=1 preview_nonce=eb614508dd preview=true (1) gutenberg test__p=1 preview_id=1 preview_nonce=eb614508dd preview=true (2) gutenberg test__p=1 preview_id=1 preview_nonce=eb614508dd preview=true (4)

(at 760px wide, you'll notice there's no vertical margin between the two images. That's default columns block behavior and is not modified by this PR)


I had a good chat with @jasmussen earlier about this PR and #277. He had some great input and helped me solidify my thoughts about these two PRs:

  • This PR is pretty solid, and the code is really simple (3 CSS rules!). As noted above, it allows us to achieve the stacked images pattern, as well as most of the other pending block patterns too. Given the options we have available, it seems like the simplest way to achieve what we're aiming to achieve.
  • Try: Overlapping Gallery Block Pattern #277 is complicated, and I worry that it's fragile too. The gallery block may soon shift to use standard image inner blocks, which will possibly complicate things. The columns block seems comparatively stable and simple code-wise.
  • It's definitely weird and unreadable to have the overlap in the preview, and in general when users don't add a background color to their text. We could set defaults to avoid this (for example: we could manually give all text-based blocks a background color and padding), but this seems like something we could explore in a followup PR.

So in general, my recommendation is:

How do folks feel about that?

@kjellr
Copy link
Collaborator Author

kjellr commented Oct 8, 2020

A short addendum to the comment above:

We could set defaults to avoid this (for example: we could manually give all text-based blocks a background color and padding), but this seems like something we could explore in a followup PR.

I added this in 9850f6f, and it works pretty well to ensure that text in the second column is readable by default. Users are still able to modify colors using the standard Gutenberg color controls. And it's only for direct children.

default-background

@carolinan
Copy link
Contributor

I think this will be great and that it can be merged.

@kjellr
Copy link
Collaborator Author

kjellr commented Oct 8, 2020

Thanks, all! I'll open some followup PRs for block patterns that use this.

@kjellr kjellr merged commit 6c5a2e8 into trunk Oct 8, 2020
@kjellr kjellr deleted the try/negative-margin-columns branch October 8, 2020 15:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
[Component] Block patterns Issues related to block patterns shipped with theme [Component] Default blocks Issues related to adjusting default blocks Design
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants