-
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
Allow duotone presets to be stored in the "duotone" block attribute #48381
Conversation
Flaky tests detected in 360af4d. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4261031277
|
Size Change: +404 B (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
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.
@getdave I think I mostly finished the PHP side of things, but the JS still needs to be updated to set the right attributes.
if ( isset( $preset['colors'] ) && 'unset' === $preset['colors'] ) { | ||
return '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.
gutenberg_get_duotone_filter_property
is used externally by WP_Theme_JSON
, so we want to keep the original behavior.
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.
Oh man. Its so horrible having to remember that everything is public in PHP. Thank you for catching this.
$scoped[] = $scope . ' ' . trim( $sel ); | ||
} | ||
$selector = implode( ', ', $scoped ); | ||
$selector = WP_Theme_JSON_Gutenberg::scope_selector( '.' . $filter_id, $duotone_support ); |
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 forget—when doing backports, renaming things like WP_Theme_JSON_Gutenberg
to WP_Theme_JSON
is part of the normal process, right? Or will this need special attention?
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 think this is fine, we just need to to rename it when we do the backport.
if ( isset( $preset['colors'] ) && 'unset' === $preset['colors'] ) { | ||
return '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.
Oh man. Its so horrible having to remember that everything is public in PHP. Thank you for catching this.
$filter_key = $is_duotone_colors_array ? implode( '-', $duotone_attr ) : $duotone_attr; | ||
$filter_preset = array( | ||
$filter_key = is_array( $duotone_attr ) ? implode( '-', $duotone_attr ) : $duotone_attr; | ||
$filter_data = array( |
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.
filter_data
is much better name now - thank you.
$scoped[] = $scope . ' ' . trim( $sel ); | ||
} | ||
$selector = implode( ', ', $scoped ); | ||
$selector = WP_Theme_JSON_Gutenberg::scope_selector( '.' . $filter_id, $duotone_support ); |
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.
Nice! That bit of code was on my refactor this. Glad you found it.
const duotonePresetOrColors = duotonePreset | ||
? getColorsFromDuotonePreset( duotonePreset, duotonePalette ) | ||
: duotoneColors; |
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.
TODO
Bug: the "unset" value is stored in the style attribute so we need a custom condition here to handle when duotone is hard value "unset" otherwise this code will retriebe the colors from the default duotone palette.
I'm now working on the JS side. Nearly done. |
We'll need to pull in changes from #48401 once it's merged. |
Closing in favor of #48426 |
What?
Why?
Fixes #48371
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
Co-authored-by: Dave Smith [email protected]