From fbe64ec8d383cd7c6af608afd09baf6054d131cc Mon Sep 17 00:00:00 2001 From: Alex Lende Date: Mon, 18 Apr 2022 09:34:32 -0500 Subject: [PATCH] Fix duotone rendering in site editor (#37727) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alex Lende Co-authored-by: Ben Dwyer Co-authored-by: André <583546+oandregal@users.noreply.github.com> --- packages/block-editor/src/hooks/duotone.js | 160 +++++++++++------- packages/block-editor/src/hooks/index.js | 1 + packages/block-editor/src/index.js | 1 + packages/blocks/src/api/constants.js | 4 + .../block-editor/resizable-editor.js | 8 +- .../editor/global-styles-renderer.js | 3 +- .../global-styles/use-global-styles-output.js | 94 ++++++++-- .../src/components/global-styles/utils.js | 6 + 8 files changed, 201 insertions(+), 76 deletions(-) diff --git a/packages/block-editor/src/hooks/duotone.js b/packages/block-editor/src/hooks/duotone.js index 163846d52e415a..27866f580d7373 100644 --- a/packages/block-editor/src/hooks/duotone.js +++ b/packages/block-editor/src/hooks/duotone.js @@ -60,82 +60,109 @@ export function getValuesFromColors( colors = [] ) { */ /** - * SVG and stylesheet needed for rendering the duotone filter. + * Stylesheet for rendering the duotone filter. * * @param {Object} props Duotone props. * @param {string} props.selector Selector to apply the filter to. * @param {string} props.id Unique id for this duotone filter. - * @param {Values} props.values R, G, B, and A values to filter with. * * @return {WPElement} Duotone element. */ -function DuotoneFilter( { selector, id, values } ) { - const stylesheet = ` +function DuotoneStylesheet( { selector, id } ) { + const css = ` ${ selector } { filter: url( #${ id } ); } `; + return ; +} +/** + * SVG for rendering the duotone filter. + * + * @param {Object} props Duotone props. + * @param {string} props.id Unique id for this duotone filter. + * @param {Values} props.values R, G, B, and A values to filter with. + * + * @return {WPElement} Duotone element. + */ +function DuotoneFilter( { id, values } ) { return ( - <> - - - - + + + + + + + - - - - - - - - - - -