-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
RSS: Border & Spacing support #66411
base: trunk
Are you sure you want to change the base?
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @benazeerhassan1909. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @benazeer-ben! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you again for helping move these block supports PRs forward 🙇🏻
✅ Block styles are working well.
We just need to ensure padding overwrites the block's styles for global + theme.json styles.
@@ -41,3 +41,10 @@ ul.wp-block-rss { // The ul is needed for specificity to override the reset styl | |||
display: block; | |||
font-size: 0.8125em; | |||
} | |||
.wp-block-rss { | |||
box-sizing: border-box; | |||
.wp-block-rss { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, a comment might help future contributors to know what this does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these styles are to prevent the double-up of block support styles within the editor when server-side rendering, hence the nested .wp-block-rss
classes.
Given they are editor-only styles, they shouldn't be added to the styles sent to the frontend, instead editor.scss
might be a better home for them.
These styles are missing the padding reset and the border reset might be too simplistic when Global Styles are taken into account. The tag cloud block went through these same edge cases so it's a good example to follow for the style resets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My memory failed me during my review but finally kicked into gear. There's a slightly cleaner way to wrangle resetting all the various block support styles when skipping block supports in the server-side rendering. It should also be more forward compatible for future block supports.
It was first proposed for the Tag Cloud block that runs into similar issues.
.wp-block-rss .wp-block-rss {
all: inherit; /* This addresses borders, background colors etc. */
margin: 0;
padding: 0;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Moved the nested style in editor.scss as per the discussion, since it is editor only style.
-
One scenario, while we adding
all: inherit;
list style get inherited and bullets will display in the editor part.So in that case, just updated the style as follows:
.wp-block-rss .wp-block-rss {
margin: 0;
padding: 0;
border: 0;
border-radius: inherit;
background: inherit;
}
Please share your thought on this @aaronrobertshaw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please share your thought on this @aaronrobertshaw
I think we should still use the all: inherit;
rule.
The issue with the list-style: none
rule not being applied is just that the main style adding it targets the ul
element. When the block is server-side rendered, it's wrapper becomes a div
.
The fix is as simple as moving the existing list-style: none;
rule to the new style you've added using the straightforward 0-1-0
specificity .wp-block-rss
selector. Along with that move, we can also clean up the unneeded &.is-grid
style's rule for list style as well.
The reset.scss
styles are scoped with :where(.editor-styles-wrapper)
nowadays so the block doesn't need the bumped specificity. Once this PR is updated though we'll need to double check a non-iframed editor and ensure everything still works as expected.
The benefit of the all: inherit
rule is that it is more robust in the face of changes than arbitrarily adding all possible resets. As the list of CSS properties that need to be reset grows, it also means more CSS. The all: inherit;
approach keeps that to a minimum.
}, | ||
"spacing": { | ||
"margin": true, | ||
"padding": true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theme.json and user global styles are being overwritten on the frontend by the RSS block's styles:
gutenberg/packages/block-library/src/rss/style.scss
Lines 2 to 3 in 11696c1
list-style: none; | |
padding: 0; |
It's there to remove the default list padding.
Here's the PR that introduced it: #33294
Reducing specificity might work:
:where(ul.wp-block-rss) {
padding: 0;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clarity, I believe the suggestion here is to extract the padding to a new style with the reduced specificity, as shown above, rather than change the selector of the entire block of styles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, thanks for translating my fly-by comment 👍🏻 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted the padding to a new style in the recent commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, the original padding style wasn't removed so the problem still exists on the frontend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work here @benazeer-ben, appreciate it 👍
In addition to Ramon's feedback, I've spotted a few other tweaks we should make while iterating here.
- The last direction I had was that all the blocks that needed spacing support as a "primary use-case" had already had it added. New blocks adopting the support probably shouldn't have the spacing controls shown by default.
- This would be good to confirm again with our design and product experts though.
- If we err on the side of caution and don't make the spacing controls display by default, the border controls should match.
- For now, I'd make both sets of controls optional (hidden by default). It's easier to expose them later than hide them which might confuse users that have grown use to them shown by default.
- The server-side rendering style resets should be in the editor-only stylesheet.
- The server-side rendering style resets are missing padding styles and the border resets might not be complete.
All that said, this is coming along nicely, great work so far ✨
}, | ||
"spacing": { | ||
"margin": true, | ||
"padding": true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clarity, I believe the suggestion here is to extract the padding to a new style with the reduced specificity, as shown above, rather than change the selector of the entire block of styles.
@@ -41,3 +41,10 @@ ul.wp-block-rss { // The ul is needed for specificity to override the reset styl | |||
display: block; | |||
font-size: 0.8125em; | |||
} | |||
.wp-block-rss { | |||
box-sizing: border-box; | |||
.wp-block-rss { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these styles are to prevent the double-up of block support styles within the editor when server-side rendering, hence the nested .wp-block-rss
classes.
Given they are editor-only styles, they shouldn't be added to the styles sent to the frontend, instead editor.scss
might be a better home for them.
These styles are missing the padding reset and the border reset might be too simplistic when Global Styles are taken into account. The tag cloud block went through these same edge cases so it's a good example to follow for the style resets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for iterating here @benazeer-ben 👍
There's a few more tweaks needed before we can merge this one.
- The spacing controls still need to be made optional i.e. not displayed by default.
- It's easier to make something show by default later than hide them when users might have already grown accustomed to their location.
- The
padding: 0
underul.wp-block-rss
wasn't removed so the original issue Ramon flagged is still there when checking the frontend, despite the new style.- Global Styles also only requires a specificity of
0-1-0
or lower for the block library styles. Thepadding: 0;
rule can live under the.wp-block-rss
selector. - I don't think the comment stating the padding rule was extracted is needed.
- Global Styles also only requires a specificity of
- There's now in effect a duplicate
box-sizing: border-box
rule. We should only need one.- The reset.scss styles are now scoped by
:where(.editor-styles-wrapper)
so the originalbox-sizing
rule's specificity bump isn't required. - We should remove it in favour of the new rule you added under the simple
.wp-block-rss
selector. - The comment relating to
box-sizing
can then be moved above the rule it relates to. - A lot of blocks set the
box-sizing: border-box
rule and use the following comment. It might be best to reuse that comment too so that when a generic solution lands, it's easier to make sure this gets cleaned up as well.// This block has customizable padding, border-box makes that more predictable.
- The reset.scss styles are now scoped by
- The addition of the
background: inherit
reset style should probably only happen in the PR that adds color support. Keep this PR's scope only to the spacing and border supports.- Better yet, we should use the
all: inherit;
approach, suggested in my last review. - The
list-style
issue you flagged can be solved by moving thelist-style: none
styles to the.wp-block-rss
style (note the lack oful
in that selector). - While on the
list-style
rules, the one associated with the grid layout for the RSS block doesn't look to be needed.
- Better yet, we should use the
- Nit: The multiline comment in
edit.js
should probably start with/*
instead of/**
as it isn't a docblock comment. At least I think that's the reasoning behind the style guideline.
Sorry for the wall of text but I thought it might be easier to tick off all that's left if you had a single list to work from rather than fragmented comments left inline.
Despite my long-winded review, I don't think these tweaks will take much to achieve.
I hope that helps! 🙏
Thanks again for the detailed review on this @aaronrobertshaw , it helped to figure out the scenarios easily. I have worked on the points as per the above explanation. If it still miss something or misunderstood, kindly let me know, will look into that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for iterating again @benazeer-ben 🚀
There were a couple more minor things missed. I've added suggested tweaks below.
Co-authored-by: Aaron Robertshaw <[email protected]>
Co-authored-by: Aaron Robertshaw <[email protected]>
What?
Adding border support & spacing support for RSS block.
Part of #43247 and #43243
Why?
RSS block is missing border & spacing support
How?
Adds the border & spacing support via block.json.
Testing Instructions
Screenshots or screencast
Backend:
Frontend: