Conversation
|
Size Change: +70 B (0%) Total Size: 8.76 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in 1a2d189. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23268803708
|
1055d93 to
a73bb9d
Compare
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| data-wpds-root-provider={ isRoot } | ||
| data-wpds-density={ density } | ||
| className={ styles.root } | ||
| style={ cursorStyle } |
There was a problem hiding this comment.
Rather than adding cursorStyle via inline style, should it be part of the output of the cssObjectToText function, which is written in a <style> tag? That would ensure that all CSS generated by theme provider follows the same "pipeline" and is written in the same place (ie. the <style> tag)
There was a problem hiding this comment.
Also adding that the current approach won't apply the cursor styles to the :root tag when the isRoot prop is specified.
There was a problem hiding this comment.
Separately, this also makes me realize that the current approach for propagating density settings (ie. via a data-wpds-density attribute) also lacks :root propagation. We should tackle it separately
# Conflicts: # packages/theme/CHANGELOG.md
ciampo
left a comment
There was a problem hiding this comment.
Good to merge once the split memo comment is addressed 🚀
Great to see theme provider getting more capable and orchestrating style preferences with one click!
| return { | ||
| ...generateStyles( { | ||
| primary: seeds.primary, | ||
| computedColorRamps, | ||
| } ), | ||
| ...( cursorControl && { | ||
| '--wpds-cursor-control': cursorControl, | ||
| } ), | ||
| }; | ||
| }, [ primary, bg, cursorControl ] ); |
There was a problem hiding this comment.
Given that color ramp calculation can be expensive performance-wise, we could split the memo so that color and cursor have separate invalidation
Something like this
const colorStyles = useMemo( () => {
const seeds = { ...DEFAULT_SEED_COLORS, bg, primary };
const computedColorRamps = new Map< string, RampResult >();
const bgRamp = getCachedBgRamp( seeds.bg );
Object.entries( seeds ).forEach( ( [ rampName, seed ] ) => {
if ( rampName === 'bg' ) {
computedColorRamps.set( rampName, bgRamp );
} else {
computedColorRamps.set(
rampName,
getCachedAccentRamp( seed, bgRamp )
);
}
} );
return generateStyles( {
primary: seeds.primary,
computedColorRamps,
} );
}, [ primary, bg ] );
const themeProviderStyles = useMemo( () => ( {
...colorStyles,
...( cursorControl && {
'--wpds-cursor-control': cursorControl,
} ),
} ), [ colorStyles, cursorControl ] );* Theme: Add cursor prop to ThemeProvider * Add changelog * Fix `CSSProperties` type use * Update readme * Move cursor token into <style> tag pipeline * Add cursor to ThemeContext defaults * Split color and cursor style memos Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: ciampo <mciampini@git.wordpress.org>
What?
Part of #76221
Adds a
cursorprop toThemeProvider, allowing the--wpds-cursor-controldesign token to be configured at the theme level. Also adds a "Cursor control" option to the Storybook theme toolbar.Why?
The
--wpds-cursor-controltoken (adopted in #76218) controls the cursor style for interactive non-link controls. WithoutThemeProviderintegration, there's no way to configure this token declaratively — and the value wouldn't propagate to portaled popovers (Select, Dialog, Tooltip), which render outside the ThemeProvider's DOM subtree.How?
cursor?: { control?: 'default' | 'pointer' }toThemeProviderSettings.ThemeProvidersets--wpds-cursor-controlvia an inlinestyleon its wrapper div. The value is resolved through the same prop → inherited → fallback chain ascolor, and included inThemeContextso child providers (used in portals) inherit it.Testing Instructions
npm run storybook:devand navigate to any Design System component story.cursor: pointer.cursor: default.