WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.5k stars 4.19k forks source link

Utilize the new selectors API for duotone #49342

Open ajlende opened 1 year ago

ajlende commented 1 year ago

Duotone filter support has been added in block.json under the supports.color.__experimentalDuotone since it was introduced. It was marked as experimental because it required a special selector different from the supports.color.__experimentalSelector.

With the selectors API stabilized in #46496, the duotone supports can now utilize it.

Duotone filters were initially added under color support when they were only part of block supports and theme.json presets. Then, when global styles support was added, that functionality was nested under filter instead. https://github.com/WordPress/gutenberg/pull/34667#issuecomment-929384846

I lean towards styles.filters.duotone conceptually even if we were to have settings.color.palette.duotone for a palette definition it’s conceivable duotone palettes could be used for more than duotone filters either as gradient backgrounds or masks or something else

The new stabilized duotone block supports should be nested under filter following that reasoning.

Two changes to block.json (including the schema) are required:

  1. Add a boolean block support under supports.filter.duotone that enables/disables the feature. It was previously handled by supports.color.__experimentalDuotone being set to true to use the default block selector or supports.__experimentalSelector or set to a string if a custom selector was needed.
  2. Add selectors.filter.duotone that specifies the custom selector previously nested under supports.color.__experimentalDuotone for the case mentioned in 1.

Duotone uses the block.json metadata directly, unlike some of the other supports. And there were special cases added for __experimentalDuotone throughout the code. So anywhere that was using that should provide an upgrade path by providing a migration or continuing to support it if a migration isn't possible.

aaronrobertshaw commented 1 year ago

There was a PR created last week that begins updating Duotone to use the new Selectors API (https://github.com/WordPress/gutenberg/pull/49325).