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

RSS: Border & Spacing support #66411

Open
wants to merge 9 commits into
base: trunk
Choose a base branch
from

Conversation

benazeer-ben
Copy link
Contributor

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

  • Go to Global Styles setting ( under appearance > editor > styles > edit styles > blocks ).
  • Make sure that RSS block's border is configurable via Global Styles.
  • Verify that Global Styles are applied correctly in the editor and frontend.
  • Edit template/page, Add Page List block and apply the border, spacing( padding & margin) styles.
  • Verify that block styles take precedence over global styles.
  • Verify that block styles display correctly in both the editor and frontend.

Screenshots or screencast

Backend:
rssbackend

Frontend:
rssfrontend

Copy link

github-actions bot commented Oct 24, 2024

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 props-bot label.

Unlinked Accounts

The 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.

Unlinked contributors: benazeerhassan1909.

Co-authored-by: benazeer-ben <[email protected]>
Co-authored-by: ramonjd <[email protected]>
Co-authored-by: aaronrobertshaw <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Oct 24, 2024
Copy link

👋 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.

@akasunil akasunil added [Type] Enhancement A suggestion for improvement. [Block] RSS Affects the RSS Block - used to display entries from an RSS/Atom feed labels Oct 24, 2024
Copy link
Member

@ramonjd ramonjd left a 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.

packages/block-library/src/rss/edit.js Show resolved Hide resolved
@@ -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 {
Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Contributor

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;
}

Copy link
Contributor Author

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

Copy link
Contributor

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
Copy link
Member

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:

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;
}

Copy link
Contributor

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.

Copy link
Member

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 👍🏻 😄

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

@aaronrobertshaw aaronrobertshaw left a 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.

  1. 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.
  2. 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.
  3. The server-side rendering style resets should be in the editor-only stylesheet.
  4. 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 ✨

packages/block-library/src/rss/block.json Outdated Show resolved Hide resolved
},
"spacing": {
"margin": true,
"padding": true
Copy link
Contributor

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 {
Copy link
Contributor

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.

Copy link
Contributor

@aaronrobertshaw aaronrobertshaw left a 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.

  1. 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.
  2. The padding: 0 under ul.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. The padding: 0; rule can live under the .wp-block-rss selector.
    • I don't think the comment stating the padding rule was extracted is needed.
  3. 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.
  4. 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 the list-style: none styles to the .wp-block-rss style (note the lack of ul 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.
  5. 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! 🙏

@benazeer-ben
Copy link
Contributor Author

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.

Copy link
Contributor

@aaronrobertshaw aaronrobertshaw left a 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.

packages/block-library/src/rss/editor.scss Outdated Show resolved Hide resolved
packages/block-library/src/rss/style.scss Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] RSS Affects the RSS Block - used to display entries from an RSS/Atom feed First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants