Allow duotone presets to be stored in the "duotone" block attribute#48381
Allow duotone presets to be stored in the "duotone" block attribute#48381ajlende wants to merge 12 commits into
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
|
| if ( isset( $preset['colors'] ) && 'unset' === $preset['colors'] ) { | ||
| return 'none'; | ||
| } |
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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.
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.
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 444434+getdave@users.noreply.github.com