-
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
Theming Blocks and Components #16347
Comments
Related: #16274 |
👍 wc-admin currently uses postcss to run What would fallbacks look like? button {
background-color: yellow;
background-color: var(--primary);
} This would mean unsupported browsers render Gutenberg components in their default colors, not Woo-themed, in our case. Is that an acceptable side affect? |
Probably a lead call. But in my opinion, it is absolutely and thoroughly an acceptable side-effect, since it does not affect accessibility, and because of the browsers we support it only visually affects IE11 (released 2013). |
CSS variables offer a lot of potential! One potential blocker could be the current design's use of color functions. Some components use color functions on the color variable e.g. button contains code like I don't know of any color functions that are built into CSS which might mean that moving to CSS variables will require some alteration of the design (@davewhitley has been experimenting with some aspects of this). |
The reason we use this I think it's probably possible to avoid these entirely if we rely on CSS variables and just have each admin schemes define its own variables. We'd probably need more "shades" than the one available in the config of each Admin Scheme, but that's fine. |
To support the current design, the following color variations will require an additional 13 variables on top of the existing color variables and their shades. While that can be implemented it feels like an intimidating interface for a theme author to achieve their goal.
The color variations are limited to a small number of components and a simplified design for these components could be feasible, offering a simplified theming interface for theme authors. |
yes, I like that. I think we should explore reducing the number of these shades. |
the alerts ones are not important though as these don't rely on "theme" functions, they can be just static to begin with. |
Going to close this as a duplicate of #9534 where we explore similar ideas |
Gutenberg uses a global
_variables.scss
and_colors.scss
SASS variables to share common styling (fonts, colors, spacing, ...) across the code base. In addition to that we can use The PostCSS themes plugin to support WordPress Admin Schemes. For example usingtheme( primary )
as a color will result in the primary color of the Selected Admin Theme to be used.This solves the consistency and the admin schemes support issues but it falls short when it comes to:
One way of solving this is the usage of CSS variables:
for example, all blocks that render headings (core and third-party blocks) could do:
and a theme would be able to change all heading colors from all blocks (even non core blocks) by doing so in the editor styles:
This also suggests that these variables are identified, documented and used consistently across core and third-party blocks.
Caveats
CSS variables are not available across all of our supported browsers. https://caniuse.com/#feat=css-variables
We could implement this as a "progressive enhancement" with fallbacks. If the user's browser support the CSS variables, the UI is adapted, otherwise we fallback to the defaults.
The text was updated successfully, but these errors were encountered: