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

Blocks: Proposal: Box-layout attribute #26407

Open
scruffian opened this issue Oct 22, 2020 · 11 comments
Open

Blocks: Proposal: Box-layout attribute #26407

scruffian opened this issue Oct 22, 2020 · 11 comments
Labels
[Feature] Blocks Overall functionality of blocks [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Enhancement A suggestion for improvement.

Comments

@scruffian
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Themes need to treat "text" blocks differently to other kinds of blocks which can result in very verbose CSS. It would be useful if we could make a distinction between "text" blocks and other kinds of blocks so that this could be a bit more future proof.

Describe the solution you'd like
One idea I had was a setting in the block definition which could be used in the render to add a wp-block-text class to the output, but I'm open to other suggestion.

Describe alternatives you've considered

@scruffian scruffian added [Type] Enhancement A suggestion for improvement. [Feature] Blocks Overall functionality of blocks [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. labels Oct 22, 2020
@mtias
Copy link
Member

mtias commented Oct 23, 2020

Can we trace back why themes need to treat these differently? I believe has-background changes came from the decision to add padding / margin within content when a background color is present. An example being the extra padding added on paragraphs when a bg color is set. This behaviour is not ideal since it assumes a little too much. With dimensions being something we can declaratively incorporate into blocks (sometimes exposing a padding control) this is something that could migrate into theme.json spec instead.

@scruffian
Copy link
Contributor Author

That's one instance but it's not the only one. For instance a full width image block should go right to the edge of the screen, but a full width text based block should now.

@mtias
Copy link
Member

mtias commented Oct 23, 2020

I mean, the box should probably still go to the edge, just with some padding. But it should be possible to not have the padding if the design demands it.

@scruffian
Copy link
Contributor Author

Right, it would just be nice to be able to write in the theme:
.alignwide.is-text-based { padding: 0 1em }

rather than having to target each block separately, which won't work if new/custom blocks are added.

@mtias
Copy link
Member

mtias commented Oct 23, 2020

I also don't think that's the text nature that matters there. It's more of a box-layout behaviour — an icon block might also want that extra space, for example, even if it's not text based.

@scruffian
Copy link
Contributor Author

Yeah that's true. Do you think that having a way to define that for each block would be useful?

@mtias
Copy link
Member

mtias commented Oct 23, 2020

Probably, yes, but we need to find the right semantics to express it without excessively increasing complexity

@scruffian
Copy link
Contributor Author

None of the options in block configuration seem to be able to do something like this - perhaps the closest would be to add a new option to supports? Otherwise we could add another top level definition to the options we pass to block registration but that seems like overkill.

@jorgefilipecosta
Copy link
Member

If the idea is to allow one to select apply rules to all text blocks, we have text block category, would it make sense to be able to use the block category on theme.json selectors? Meaning the selector would be compiled the selectors of each individual block using the or CSS ",". cc: @nosolosw

@scruffian
Copy link
Contributor Author

As @mtias pointed out, it's not just text blocks; we have two kinds of blocks - ones that look good when aligned to the edge of the browser window, and ones that don't. It would be useful to be able to declare this in the block rather than having to list all the blocks in the theme.

@scruffian scruffian changed the title Blocks: Proposal: Text block setting Blocks: Proposal: Box-layout attribute Oct 30, 2020
@paaljoachim
Copy link
Contributor

Thanks for opening this issue @scruffian Ben!
I will ping in @annezazu
As I believe aspects of this has likely showed up in calls for testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

4 participants