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: Added Colour support #66419

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

Conversation

benazeer-ben
Copy link
Contributor

@benazeer-ben benazeer-ben commented Oct 24, 2024

What?

Add color support to the RSS block.
Part of #43245

Why?

RSS block is missing color support.

How?

Adds the color support via block.json

Testing Instructions

  • Go to the Global Styles setting ( under appearance > editor > styles > edit styles > blocks ).
  • Make sure that the RSS block's color is configurable via Global Styles.
  • Verify that Global Styles are applied correctly in the editor and frontend.
  • Edit the template/page, Add RSS block and apply the color for text, background and links .
  • Verify that block color styles take precedence over global block settings.
  • Verify that block color display correctly in both the editor and frontend.

NOTE:
This PR is dependent on some style changes in another PR

Screenshots or screencast

Backend:
rsscolor

Frontend:
rsscolorfront

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.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

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.

@benazeer-ben benazeer-ben changed the title RSS: Added Colour support RSS: Added Colour & Typography support Oct 25, 2024
@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 25, 2024
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove the __experimental prefixes now that #63401 has merged 👍🏻

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__experimental prefixes removed in recent commit.

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.

Great to see the RSS block getting some love. I think this will work well in conjunction with #66411

Here's my ghastly example:

Screenshot 2024-11-11 at 12 38 44 pm

"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalLetterSpacing": true,
"__experimentalTextDecoration": true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not a big deal, but the underline control in text decoration won't affect .wp-block-rss__item-title > a elements as they're being directly controlled by this rule:

a:where(:not(.wp-element-button)) {
    text-decoration: underline;
}

I'm not sure whether users will expect text decoration to affect all text within the RSS block 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be some options here to apply text decoration more effectively.

Individual block support features, e.g. text-decoration, can have their serialization of styles and classes skipped. They can then be manually applied to the appropriate inner elements. For the Global Styles side of that equation, the Block Selectors API allows custom selectors for individual features so they target the same inner elements.

For an example of skipping serialization of onlytextDecoration, see the Navigation block.

Note: The navigation block skipped that serialization before the Selector's API was implemented so I'm not sure if it covers Global Styles or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @aaronrobertshaw for the reference and suggestion.

Tried to follow the same way as in the Navigation block. Bu as you mentioned, it doesn't covers Global Styles. We need to tweak more on this.

I have added all the changes in recent commit.

More suggestions are welcome for this scenario.

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.

Great work on all these block support PRs @benazeer-ben and thank you for your patience handling all the edge cases 🙇

I've left some comments piggy-backing on Ramon's earlier review. In particular, we might be able to improve the adoption of text-decoration support as detailed in this comment.

Also, with the block being server-side rendered, there's a small issue with the background color needing to be reset on the inner rendering of the block (once server-side rendering skips block support attributes as proposed in your border and spacing support PR).

The Tag Cloud block has a PR adopting color support and the background reset issue came up there.

These style resets are similar to the ones added in your PR adopting border and spacing support for this block.

While reviewing the Tag Cloud PR, I found the cleanest approach to reset the styles to avoid issues with the server-side rendering was the following:

.wp-block-rss .wp-block-rss {
	all: inherit; /* This addresses borders, background colors etc. */
	margin: 0;
	padding: 0;
}

@benazeer-ben
Copy link
Contributor Author

These style resets are similar to the ones added in your PR adopting border and spacing support for this block.

Yes, this is handling in that PR.

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.

This is working pretty well for me, thanks again.

Editor

Kapture.2024-11-14.at.13.18.14.mp4

Frontend

Screenshot 2024-11-14 at 1 18 29 pm

I think I left more questions than answers, sorry.

I also noticed in the editor, block attributes are applied to wrapper and server side rendered component.

I'm not sure this is an issue for color and typography, at least from what I can tell, but I assume other styles like border will have to be handled in a way similar to tag cloud, that is, by modifying the attributes sent to the serverside component.

@@ -27,6 +27,41 @@ ul.wp-block-rss { // The ul is needed for specificity to override the reset styl
}
}

// The following rules provide class based application of user selected text
// decoration via block supports.
&.has-text-decoration-underline li.wp-block-rss__item a {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious about whether we leave out text decoration altogether.

The reason I ask is because here it's being applied to the RSS links only. Is that the intention?

There are other text fields such as date and author and description excerpt.

Should we not allow text-decoration styles on these?

It's tricky, and I don't know the right answer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is some merit to omitting the text-decoration support and revisiting it once the general color, border, and spacing supports for the block land.

@benazeer-ben this is also where keeping PRs atomic helps. For example, one PR for color support only, another for typography, means that the issues with text-decoration and typography supports don't hold up the adoption of color supports. Does that make sense?

Comment on lines 59 to 63
& :where(a),
& :where(a:focus),
& :where(a:active) {
text-decoration: none;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While these styles will override the link element's global text-decoration styles, all other typography styles set in Global styles > Typography > Links will affect links within the RSS block, making the behaviour selective and inconsistent.

What would be ideal I guess is for the RSS block's links to inherit from (in order of lowest specificity to highest):

  1. The links element styles
  2. Global styles RSS block
  3. Block styles

I'm thinking we could delete these lines, and, to make sure Global styles RSS block styles overwrite link elements, bump the selector in the block.json under "typography", e.g., "__experimentalSelector": ".wp-block-rss .wp-block-rss__item-title a"

That way, RSS block global styles will override any defaults in Global styles > Typography > Links > text decoration, and the block styles are inline anyway and will take priority.

I could be overthinking it too.

What do you think?

Copy link
Contributor

@aaronrobertshaw aaronrobertshaw Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to make sure Global styles RSS block styles overwrite link elements, bump the selector in the block.json under "typography", e.g., "__experimentalSelector": ".wp-block-rss .wp-block-rss__item-title a"

The __experimentalSelector support flag is deprecated and shouldn't be used. Try the Block Selectors API instead.

This approach Ramon has outlined is what I suggested in my earlier comment (well other than using the deprecated flag 😅):

For the Global Styles side of that equation, the Block Selectors API allows custom selectors for individual features so they target the same inner elements.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The __experimentalSelector support flag is deprecated and shouldn't be used. Try the Block Selectors API instead.

Oh 🤦🏻 Thanks for setting me straight on that one @aaronrobertshaw Went straight over my head.
Carry on.

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.

Appreciate the patience iterating on these PRs @benazeer-ben 👍

I'd like to propose splitting this PR into two. One that adopts color support and another adopting typography support. Any hold-ups to one (looking at you text-decoration) won't delay the other.

These style resets are similar to the ones added in your PR adopting border and spacing support for this block.

Yes, this is handling in that #66411.

If this PR is dependent on changes in another PR, we need that to be communicated in the PR description and testing instructions.

I know it involves more juggling, but basing this PR off the one it depends on makes things easier for reviewers and testers who lack full context. This way, the branch being tested includes all necessary changes and integrates well with them. Once the other PR is merged, a quick rebase is all that’s needed before merging this one.

@ramonjd
Copy link
Member

ramonjd commented Nov 14, 2024

I'd like to propose splitting this PR into two.

+1

@benazeer-ben
Copy link
Contributor Author

Hi @aaronrobertshaw

Sure, I will keep this PR only for color support and move typography support from here to a new one.

@benazeer-ben benazeer-ben changed the title RSS: Added Colour & Typography support RSS: Added Colour support Nov 14, 2024
@benazeer-ben
Copy link
Contributor Author

Hi @aaronrobertshaw @ramonjd

For the information:

I have moved the typography support form this PR to new one. So for typography related updates we can discuss the things over there.

Now this PR is only for color support and some of its style changes are dependent on another PR.

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.

Thanks for splitting the PRs up @benazeer-ben

It's a lot easier to test!

Here's what I tested:

✅ RSS titles reflect global styles Link element colors (including hover)
✅ Changes to RSS global styles colors affect all blocks. Links colors overwrite Link element defaults. Background gradients work as expected.
✅ Block-level colors work as expected and take precedence over everything.
✅ Tested the above hierarchy with theme.json (see below)

I think this is good to go if @aaronrobertshaw agrees.

Example theme.json
{
	"$schema": "https://schemas.wp.org/trunk/theme.json",
	"version": 2,
	"settings": {
		"appearanceTools": true
	},
	"styles": {
		"elements": {
			"link": {
				"color": {
					"background": "red",
					"text": "green"
				},
				":hover": {
					"color": {
						"background": "orange",
						"text": "teal"
					}
				},
				":active": {
					"color": {
						"background": "peach",
						"text": "cottoncandy"
					}
				}
			}
		},
		"blocks": {
			"core/rss": {
				"color": {
					"background": "yellow",
					"text": "pink"
				},
				"elements": {
					"link": {
						"color": {
							"background": "aquamarine",
							"text": "white"
						},
						":hover": {
							"color": {
								"background": "purple",
								"text": "black"
							}
						}
					}
				}
			}
		}
	}
}


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.

4 participants