-
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
add theme package #56669
base: trunk
Are you sure you want to change the base?
add theme package #56669
Conversation
Size Change: 0 B Total Size: 1.72 MB ℹ️ View Unchanged
|
Flaky tests detected in 70b277b. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7043227346
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
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's interesting to think about how this will interface with base styles (for example, should the value of the PRIMARY_DEFAULT
color come from @wordpress/base-styles
?)
export { ThemeProvider } from './provider'; | ||
export { defaultTheme } from './theme'; |
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.
These exports should probably be private, so that we can safely iterate over the APIs of the package while we're actively developing it
Also, why is the defaultTheme
an export? Wouldn't consumers of the theme just need the CSS variables ?
@@ -0,0 +1,25 @@ | |||
:root { | |||
--wp-theme-color-neutral-bg-surface: var(--wp-theme-color-neutral-1); |
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.
Looking at the naming convention, what would be other values that could be used instead of "neutral"? Would "primary" be such an alternative? If so, why aren't there any --wp-theme-color-primary
variables in this file?
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'm not sure it's a good idea to commit a file that could be generated at build time?
color, | ||
fun, | ||
isDark, |
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.
To avoid a lot of props in the ThemeProvider
component, should there be a color
prop of type
{
primary: string;
fun: number;
isDark: boolean;
}
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.
Can we add some docs (README) and/or unit tests to clarify how this package should be used?
can we clarify which config objects we support at the moment, is it the whole object like shown in the description? I'd rather we do a curated approach personally and start only with what we have (I guess mainly one color at the moment) and add theme variables one by one. |
Edit: apologies, I commented on the wrong thread here. |
This is a slimmed down version of #54541 and just contains the theme package.
color-change.mp4
What?
Introduces a theme package that aims to standardise how we name, generate and use the css variables that make up the foundation of an admin theme.
Why?
This is a big part of the admin redesign work as it lays the groundwork for tokens in future.
To reference #53612
How?
A naming convention
You can see how this looks here
A theme object
The theme object is the central part of the theme and all variables are built from it. It should be familiar to anyone who has used other frameworks like Tailwind or Theme-UI or even theme.json of WP themes. It looks a little something like:
Color generation
To make WordPress customisable in an accessible and aesthetically pleasing way we need to be clever with the way we generate colours. In this example we take a single color prop that acts as your accent along with whether you want darkMode enabled or not as well as a fun prop. Treating dark mode like a mode vs a theme is important as it allows platforms to white-label WordPress but still support light/dark. The fun prop just increases saturation in the neutral scale.
Colour generation in this PR offers us a simple starting point but we should eventually look at more complex ways of generating colours like what was explored in the
try/theming-test
branch that rotates hues and adjusts saturation as you go up/down the scale.Default CSS
The package should also include an importable CSS file that includes defaults. Ideally this file is built automatically any time the color generator is changed (started that work here)
Theme provider
This also includes a very lightweight theme provider that is used to generate theme variables which are included in a CSS class added to document head.
Testing Instructions
packages/edit-site/src/components/app/index.js
and adjust theme values on line 46.