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

Site Editor: Remove empty space above header and below footer #29357

Closed
creativecoder opened this issue Feb 25, 2021 · 6 comments
Closed

Site Editor: Remove empty space above header and below footer #29357

creativecoder opened this issue Feb 25, 2021 · 6 comments
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing")

Comments

@creativecoder
Copy link
Contributor

Ported from WordPress/theme-experiments#222

Currently we have margins around header and footer template parts in the editing view of the Site Editor.

Header

Footer

Would it make sense to remove them so as to align the header and footer with the beginning and ending of the page respectively?

cc @vindl

@jasmussen
Copy link
Contributor

As @carolinan correctly identifies on the older post, the problematic rule is this one:

.block-editor-block-list__block {
    margin-top: 28px;
    margin-bottom: 28px;
}

It is applied to every block, and is what pushes the content inwards:

Screenshot 2021-02-26 at 10 14 20

In #22208, I tried removing that. But there are two problems.

1. Every block has this margin

Screenshot 2021-02-26 at 10 14 16

That means every block, both the column singular block inside Columns, which really shouldn't have any margin, but also social icons or buttons in horizontal containers. As soon as something registers itself as a block, whether it's just an invisible passthrough or not, it gets this CSS.

This is both the primary reason why we should remove it, so there's less CSS to unset and handle. But it's also why it's a difficult change to make — we've had this margin for long enough that themes and blocks have had to compensate for it. There's a chance that by removing it, some blocks and themes will need to do some updates.

2. If those margins weren't there, we'd inherit margins from wp-admin

While the site editor is now inside an iframe which protects from CSS bleed, the post editor still isn't. Which means we inherit blanket rules from wp-admin, like this one:

Screenshot 2021-02-26 at 10 21 48

By outputting blanket rules for the editor, at least we level that playing field.


Ultimately I think we should remove those default margins, and let themes and block developers handle their good defaults. But because it's a bigger change than it seems, and per suggestions in the conversations of #22208, I believe the best way to approach this is by applying the iframe to the post editor also, and by letting the Global Styles project enable a baseline margin to replace it.

In the mean time, it would be non-trivial to write generic CSS to override those margins just in the block editor, because we can't know which blocks to target. In most themes it might be a header and footer at the top and bottom, in others it might not be.

So it seems like an interim solution would be to fix this in the theme editor style.

@mtias
Copy link
Member

mtias commented Feb 26, 2021

With semantic template parts we could reset the top margin for header and bottom margin for footer. I agree the spacing between blocks is a configuration setting that needs to be absorbed as soon as possible in theme.json / global styles. The other setting that needs control is the padding of the site.

image

@carolinan carolinan added the [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") label Feb 26, 2021
@jasmussen
Copy link
Contributor

Related: #27315

@creativecoder
Copy link
Contributor Author

I attempted this in #29453

Header Footer
Screen Shot 2021-03-01 at 15 51 17 Screen Shot 2021-03-01 at 15 50 49

There are a couple issues that suggest to me that outright removal of these margins may not be a good idea:

For the header, block toolbars are either hidden under the top edge of the container or overlapping the block content

Screen Shot 2021-03-01 at 15 37 16

Screen Shot 2021-03-01 at 15 37 37

Screen Shot 2021-03-01 at 15 38 10

For the footer, the change doesn't seem to make much difference, as the empty placeholder block is usually present underneath the template (see above)... though maybe it makes sense separately to remove or hide the empty placeholder block?


Another approach that occurs to me is adding a darkened overlay of the margin/padding between the header/footer template parts and the editor container, giving a visual indication that the space is a functional placeholder in the editor rather than a preview of what's on the site. I'll try that next.

@jasmussen
Copy link
Contributor

For the header, block toolbars are either hidden under the top edge of the container or overlapping the block content

This feels like a separate issue to address, I created #29464 as a way to potentially tackle that.

For the footer, the change doesn't seem to make much difference, as the empty placeholder block is usually present underneath the template (see above)... though maybe it makes sense separately to remove or hide the empty placeholder block?

Yes, I'd say that once the extraneous margins are removed from the editor (see also discussion in #27315), there's an opportunity to make the templates simpler and leaner.

Another approach that occurs to me is adding a darkened overlay of the margin/padding between the header/footer template parts and the editor container, giving a visual indication that the space is a functional placeholder in the editor rather than a preview of what's on the site. I'll try that next.

We tried this in the past, and it did not work as well as we had hoped. I would think that something like #29464 is worth waiting for, if the overlap is problematic, and accept the current margins until then.

@creativecoder creativecoder removed their assignment Apr 7, 2021
@creativecoder
Copy link
Contributor Author

This is resolved now, with only a "browser default" padding of 8px left around the edges (#30277)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing")
Projects
None yet
Development

No branches or pull requests

4 participants