Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update README.md
Update utils.ts - change type to StyleValue
  • Loading branch information
ramonjd committed Aug 15, 2024
commit 44de6888a833878970b0bec0e70359e289a3d7f8
4 changes: 2 additions & 2 deletions packages/style-engine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) -->

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