-
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
Show opacity controls even when custom colors are disabled #41342
Comments
@aaronrobertshaw curious if you have any insights or thoughts here :) |
Thanks for the ping 👍 This is an interesting idea and would be a nice feature. I'm not sure there is an easy win here though. Possible issuesThe predefined colors in a restricted theme palette could be anything including CSS custom properties. This would make modifying the color value itself via a generic opacity control trickier. There's be some design challenges to address as well. Primarily, the proliferation of opacity controls. We generally have text, background, and link colors but we could also have hover states, secondary colors such as striped table rows etc. That's a lot of opacity controls if we can't wrap those within existing components. The Cover block's opacity control is a bespoke solution that is surprisingly complex and prone to causing some backwards compatibility issues as we refine the Cover block. That gives some extra cause for proceeding with caution. Ultimately, I'm not sure how portable the Cover block's approach is. Options to explore
|
@aaronrobertshaw skipping that part above, I don't think it would be any different than how it currently works. I assume that the existing solution is getting the rendered color (even if authored as a variable) and then converts it to an rgba value when opacity is adjusted? So it could work the same under the hood, just not expose the entire custom color UI, rather just the opacity slider. |
Okay, I was distracted by the comment stating the desire for it to be like the Cover block opacity.
Another option to explore might then be:
It might also be worth considering what colors we allow this for as transparency has accessibility implications. Enabling the alpha channel on text colors already impacts our contrast checking etc. Not a blocker just something to consider in the bigger picture. |
Currently the editor uses an inline style to accomplish this. Here's the same theme color swatch in Twenty Twenty-Two, but with the opacity adjusted on the second paragraph:
Enabling the opacity control with custom colors disabled would also lead to inline styles embedded into content, and I can't think of a way to avoid that1 outside of revamping the way the editor handles colors to rely on the split property trick, which would really bloat the CSS generated. If this option is added I hope it will be not be the default, as one reason we disable custom colors is to avoid polluting our markup with inline styles. Footnotes
|
I wouldn't expect it to be the default either. It's more of a niche use case in my view and would require opt-in. |
Yes your option 4 sounds just like what I'd expect to happen. As far as accessibility, are you saying that the contrast checker cannot properly work with alpha values yet? Or are you saying that setting opacity could lead to bad contrast? If the latter, users are already warned about that with a message in the panel right? I don't see any reason to disallow certain colors, as ultimately it's the end-users' choice to have "inaccessible" content. |
There are difficulties in accounting for multiple alpha layers to be able to determine whether minimum contrast levels have actually been attained. As a result, when transparent text is chosen, a generic "Transparent text may be hard to read" message is displayed. Some history can be found in the PR enabling the alpha channel for color block supports. My point was that it is something to consider when the time comes to allow opacity changes to preset colors and what shape the potential flags in theme.json may take. Is it all or nothing? Or, should we allow more fine grained control such as allowing it for backgrounds but not text etc?
I agree we should respect and allow a user's choice. We also have a responsibility to help guide better decisions, design, and accessibility. |
What problem does this address?
6.0 introduced opacity control for colors. It only appears though if custom colors are enabled. If you disable those and only allow a theme palette, you cannot control the color opacity.
It would be very cool to be able to limit colors while at the same time allowing an opacity of the theme's palette to be used.
What is your proposed solution?
Perhaps move opacity to a separate control inside the Colors panel. Currently setting an opacity changes the color to a custom color. Would be neat to keep the reference to the selected color, but allow opacity. Just like how the Cover block overlay colors works basically.
@annezazu
The text was updated successfully, but these errors were encountered: