-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
add color support to separator block #16784
Conversation
@kjellr Do you think this should be fixed in 2019 or maybe force the styling using |
Twenty Nineteen is likely not the only theme doing this. Since Gutenberg was providing a color here, I'm sure other themes are overriding it too. Even so, I'd prefer not using So yes, we should open a Trac ticket for Twenty Nineteen once this PR is merged in. |
Thanks @kjellr It seems that this PR requires a dev note. |
Code-wise this PR is in a good state, can we get some design thoughts. |
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.
Hey @senadir! Thanks for the PR.
I think this is missing an update to separator/theme.scss in order to get his working correctly on the front end. By default, that provides a light gray bottom border to themes that include theme support for wp-block-styles
. I'm seeing that gray show up alongside the specified color on the front end for the Gutenberg Starter theme:
Editor:
Front end:
I don't think this works as intended — we do want to provide a default front-end color for themes that opt in to Here's what I see testing these latest changes in the Gutenberg Starter Theme (which provides no editor styles, and just uses
This branch, in front end and the editor: As you can see, the first two separators are invisible now. If I specify a color for each one in the editor, they'll show up again: Additionally, it looks like this PR shortens the height of the Default (short) separator style to Thank you! |
this commit should fix this, changes are not scoped to the style (2019 editor style is still inconsistent between the frontend & the preview because it uses height for the frontend & border for the editor) @kjellr Gutenberg starter theme behavior seems the most optimal, but I fear 2019 behavior is common |
I left a quick inline note about one of the updates. Other than that, this is looking pretty good. I'm really hesitant to resort to I'm definitely happy to hear perspective from other theme authors though! |
@kjellr do you think this is ready to merge 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.
👍 This is good to go. I have a patch ready for Twenty Nineteen, and will link back here once I open the Trac ticket.
The trac ticket for Twenty Nineteen is available here: https://core.trac.wordpress.org/ticket/47811 |
* add color support to separator block * add color to frontend render * add support for dots style in frontend * fix review problems, update block.json file * fix border issue with theme.scss * extend border remove in editor * fix problems with no color selected
* add color support to separator block * add color to frontend render * add support for dots style in frontend * fix review problems, update block.json file * fix border issue with theme.scss * extend border remove in editor * fix problems with no color selected
// Override any background themes often set on the hr tag for this style. | ||
// also override the color set in the editor since it's intented for normal HR | ||
background: none !important; |
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 see there was some discussion about the use of !important
here in the pull request comments, and separately a fix addressing a TwentyTwenty-specific incompatibility at Trac#47811.
Which leaves the question: Do we actually need it? Can it be removed?
See also: #19539
Alternatively, I wonder:
- Only including this specific style rule if
.has-text-color
and/or.has-background
, representative of the fact that the default should only need to be reset when the user chooses to apply a custom color (correct me if I'm mistaken) - Can it be addressed by assuring that the specificity of this selector would always "defeat" a theme's styling? Especially considering we would probably want this reset only in the case of applying when a custom color is used, i.e. adding
.has-text-color
and/or.has-background
as additional modifier classes:
.wp-block-separator.is-style-dots.has-background,
.wp-block-separator.is-style-dots.has-text-color {
background: none;
}
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.
What if a different method for generating dots was used?
The current method is a lot of CSS, that is a hassle for themes to override. I was going for the minimal style of making dots with multiple background images using radial gradients, but the current style using !important wouldn't let me.
I also couldn't use a dotted border because all those other styles I would have to override.
So what if the core style is the radial gradient instead of an important no background?
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.
It'd be worth exploring a simpler approach.
tackles a point from #16483
it adds color support to the Separator block.
worth mentioning, the color won't be honored if the theme already defined a color, this is the case for the Dots, not the line, I can extend it to honor the theme color in the case of the line HR but it will require printing direct CSS or that the theme style is defined it using
!important
.so, this is what is happening
!important
)you will see this case in 2019 in which they define a color for the dots
my suggestion is to unify the experience, but this will cause a slight problem.
the Dots are defined using
:before
, in order to unify the experience, we have to do this inside React rather then using:before
but it will break compantility with anything that is already targeting the :before, like 2019