-
Notifications
You must be signed in to change notification settings - Fork 809
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
Subscriptions Block: Remove inline styling for colors on status message #19230
Subscriptions Block: Remove inline styling for colors on status message #19230
Conversation
Caution: This PR has changes that must be merged to WordPress.com |
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Jetpack plugin:
|
I may be missing something with theme configuration; should we actually expect all themes to define both |
break; | ||
} | ||
|
||
echo sprintf( "<div style='border: 1px solid #%s; padding-left: 5px; padding-right: 5px; margin-bottom: 10px;'>", esc_attr( $themecolors['border'] ) ); |
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.
During my tests (using Spearhead) I noticed that, where $themecolors['border']
is empty, the following invalid CSS is output:
border: 1px solid #; padding-left: 5px; padding-right: 5px; margin-bottom: 10px;
Do you think it'd be better to only print the inline style border: 1px solid #;
if $themecolors['border']
is empty?
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.
Agreed 👍 I kept the 1px solid
border but removed the empty color value, rather than omitting the border altogether. The border takes on the text-color in this case.
Per the discussion below -- once we can access the theme border color with CSS variables, we can move all of the styling out into the stylesheets and it will be much cleaner :)
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.
Curiously, this didn't work for me on Seedlet, but I re-ran using Spearhead and the fix is noticeable.
The background colour inline style is gone and the success message background reflects the group block setting.
I have one question as to whether we should ensure the inline style is valid, that is, ensure no empty values in the border declaration: border: 1px solid #
<div style="background-color: #FFFFFF; border: 1px solid #; color: #; padding-left: 5px; padding-right: 5px; margin-bottom: 10px;">Congrats, you’re subscribed! You’ll get an email with the details of your subscription and an unsubscribe link.</div>
<div style="border: 1px solid #; padding-left: 5px; padding-right: 5px; margin-bottom: 10px;">Congrats, you’re subscribed! You’ll get an email with the details of your subscription and an unsubscribe link.</div>
IMO we should just not output any styles here and let it fall back to the theme defaults. This will be a lot easier once we have this in place: WordPress/gutenberg#29714 |
@scruffian I think we're on the same page, but to clarify -- in this approach we're removing the inline-styles and not explicitly setting the theme colors on the block, so that it only falls back to theme defaults when more specific colors are not set on it/its container blocks. Does that sound correct to you? The border color is the only style that does not automatically fall back to the theme default, so I'm keeping the inline style for that. The CSS var approach in your linked PR would definitely make that easier. |
Yeah, I think this is the best we can do for now. |
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.
Confirmed this works much better now with the default styles removed, and border color kept in place.
…tyle-theme-color-for-subscriptions
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.
That simplifies quite a bit, nice work. I only have a minor suggestion, below.
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.
This is testing nicely for me @stacimc! Nice work cleaning up the code in the process, too 👍
Great news! One last step: head over to your WordPress.com diff, D59071-code, and commit it. Thank you! |
r223723-wpcom |
Fixes #19113
Changes proposed in this Pull Request:
The post-submit status message for the Subscriptions block had hard-coded inline styles to set the
background-color
and textcolor
to the styles defined in the global$themecolors
. This can cause bugs if the theme only defines a value for one or the other; for example, if the theme sets thebackground-color
to white but does not define a text color, the message's text color may inherit from the parent block -- and if this also happens to be white, the text is not readable.This PR removes the hard-coded inline color styles. It should affect only the post-submit message, not the rest of the block. See screenshots.
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
If testing on a sandbox, you will need to manually copy the changes into your sandbox, as it will not be picked up by the awe sync.
First verify that you can see the bug
$themecolors['bg'] ='FFFFFF'
but does not set$themecolors['text']
)Text partially highlighted so it is visible.
Test that the bug is resolved
The message inside the Group block has black background and white text. The message outside the block has the default green background and dark text from the Twenty Twenty One theme
You can easily test all of the status messages by appending the status type to the URL, like:
<mytestsite.wordpress.com>?p=431&preview=true&blogsub=<status>
, wherestatus
is each of:confirming, blocked, flooded, spammed, subscribed, pending, confirmed
.