2024-05-08 07:36:45 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { BlockInstance } from '@wordpress/blocks';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is temporary solution to change the button color on the cover block when the color palette is New - Neutral.
|
|
|
|
* The real fix should be done on Gutenberg side: https://github.com/WordPress/gutenberg/issues/58004
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
export const findButtonBlockInsideCoverBlockProductHeroPatternAndUpdate = (
|
|
|
|
blocks: BlockInstance[],
|
|
|
|
callback: ( buttonBlock: BlockInstance ) => void
|
|
|
|
) => {
|
2024-05-14 14:05:09 +00:00
|
|
|
const coverBlock = blocks.find(
|
2024-05-08 07:36:45 +00:00
|
|
|
( block ) =>
|
|
|
|
block.name === 'core/cover' &&
|
|
|
|
block.attributes.url.includes(
|
|
|
|
'music-black-and-white-white-photography.jpg'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
const buttonsBlock = coverBlock?.innerBlocks[ 0 ].innerBlocks.find(
|
|
|
|
( block ) => block.name === 'core/buttons'
|
|
|
|
);
|
|
|
|
|
|
|
|
const buttonBlock = buttonsBlock?.innerBlocks[ 0 ];
|
|
|
|
|
|
|
|
if ( ! buttonBlock ) {
|
2024-05-14 14:05:09 +00:00
|
|
|
return blocks;
|
2024-05-08 07:36:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
callback( buttonBlock );
|
2024-05-14 14:05:09 +00:00
|
|
|
return blocks;
|
2024-05-08 07:36:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const PRODUCT_HERO_PATTERN_BUTTON_STYLE = {
|
|
|
|
color: { background: '#ffffff', text: '#000000' },
|
|
|
|
};
|