diff --git a/packages/style-engine/README.md b/packages/style-engine/README.md index e8ed04fb11484..a3e302fab4bb9 100644 --- a/packages/style-engine/README.md +++ b/packages/style-engine/README.md @@ -270,11 +270,11 @@ Example: _Parameters_ -- _styleValue_ `CSSStyleValue`: A raw style value. +- _styleValue_ `StyleValue`: A string representing a raw CSS value. Non-strings won't be processed. _Returns_ -- `CSSStyleValue`: A CSS var value. +- `StyleValue`: A CSS custom var value if the incoming style value is a preset value. diff --git a/packages/style-engine/src/styles/utils.ts b/packages/style-engine/src/styles/utils.ts index f82b05edd7644..74a18d2c2a6e4 100644 --- a/packages/style-engine/src/styles/utils.ts +++ b/packages/style-engine/src/styles/utils.ts @@ -136,14 +136,14 @@ export function generateBoxRules( * * `getCSSValueFromRawStyle( 'var:preset|color|heavenlyBlue' )` // returns 'var(--wp--preset--color--heavenly-blue)' * - * @param styleValue A raw style value. + * @param styleValue A string representing a raw CSS value. Non-strings won't be processed. * - * @return A CSS var value. + * @return A CSS custom var value if the incoming style value is a preset value. */ -export function getCSSValueFromRawStyle< CSSStyleValue = string >( - styleValue: CSSStyleValue -): CSSStyleValue { +export function getCSSValueFromRawStyle< StyleValue = string >( + styleValue: StyleValue +): StyleValue { if ( typeof styleValue === 'string' && styleValue.startsWith( VARIABLE_REFERENCE_PREFIX ) @@ -162,7 +162,7 @@ export function getCSSValueFromRawStyle< CSSStyleValue = string >( } ) ) .join( VARIABLE_PATH_SEPARATOR_TOKEN_STYLE ); - return `var(--wp--${ variable })` as CSSStyleValue; + return `var(--wp--${ variable })` as StyleValue; } return styleValue; }