Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update README.md
Browse files Browse the repository at this point in the history
Update utils.ts - change type to StyleValue
ramonjd committed Aug 15, 2024
1 parent d3d16f4 commit 44de688
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/style-engine/README.md
Original file line number Diff line number Diff line change
@@ -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.

<!-- END TOKEN(Autogenerated API docs) -->

12 changes: 6 additions & 6 deletions packages/style-engine/src/styles/utils.ts
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 44de688

Please sign in to comment.