From 5c040921fb7b7b823c08d2d58a39dfe6416cc674 Mon Sep 17 00:00:00 2001 From: Luigi Date: Tue, 4 Jan 2022 16:52:07 +0100 Subject: [PATCH] Enable global style for category list block #4965 Enable global style for category list block --- .../blocks/product-elements/category-list/block.tsx | 12 +++++++++++- .../blocks/product-elements/category-list/edit.tsx | 7 +++++-- .../blocks/product-elements/category-list/index.ts | 11 +++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/assets/js/atomic/blocks/product-elements/category-list/block.tsx b/assets/js/atomic/blocks/product-elements/category-list/block.tsx index 59a4dd628fe..dc359a74c19 100644 --- a/assets/js/atomic/blocks/product-elements/category-list/block.tsx +++ b/assets/js/atomic/blocks/product-elements/category-list/block.tsx @@ -16,6 +16,10 @@ import { HTMLAttributes } from 'react'; */ import './style.scss'; import { Attributes } from './types'; +import { + useColorProps, + useTypographyProps, +} from '../../../../utils/style-attributes-utils'; type Props = Attributes & HTMLAttributes< HTMLDivElement >; @@ -26,10 +30,14 @@ type Props = Attributes & HTMLAttributes< HTMLDivElement >; * @param {string} [props.className] CSS Class name for the component. * @return {*} The component. */ -const Block = ( { className }: Props ): JSX.Element | null => { +const Block = ( props: Props ): JSX.Element | null => { + const { className } = props; const { parentClassName } = useInnerBlockLayoutContext(); const { product } = useProductDataContext(); + const colorProps = useColorProps( props ); + const typographyProps = useTypographyProps( props ); + if ( isEmpty( product.categories ) ) { return null; } @@ -39,10 +47,12 @@ const Block = ( { className }: Props ): JSX.Element | null => { className={ classnames( className, 'wc-block-components-product-category-list', + colorProps.className, { [ `${ parentClassName }__product-category-list` ]: parentClassName, } ) } + style={ { ...colorProps.style, ...typographyProps.style } } > { __( 'Categories:', 'woo-gutenberg-products-block' ) }{ ' ' }