Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
primogenial
/
plugins
/
woocommerce
/
packages
/
woocommerce-blocks
/
assets
/
js
/
base
/
hooks
:
use-color-props.ts
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
/* eslint-disable @wordpress/no-unsafe-wp-apis */ /** * External dependencies */ import { __experimentalUseColorProps } from '@wordpress/block-editor'; import { isFeaturePluginBuild } from '@woocommerce/block-settings'; import { isObject } from '@woocommerce/types'; import { parseStyle } from '@woocommerce/base-utils'; type WithClass = { className: string; }; type WithStyle = { style: Record< string, unknown >; }; export const useColorProps = ( attributes: unknown ): WithStyle & WithClass => { if ( ! isFeaturePluginBuild() ) { return { className: '', style: {}, }; } const attributesObject = isObject( attributes ) ? attributes : {}; const style = parseStyle( attributesObject.style ); return __experimentalUseColorProps( { ...attributesObject, style } ); };