mirror of
https://github.com/home-assistant/frontend.git
synced 2026-02-21 10:17:13 +00:00
* Update dependency prettier to v3.2.0 * Reformat --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Steve Repsher <steverep@users.noreply.github.com>
31 lines
752 B
TypeScript
31 lines
752 B
TypeScript
export function computeCssVariable(
|
|
props: string | string[]
|
|
): string | undefined {
|
|
if (Array.isArray(props)) {
|
|
return props
|
|
.reverse()
|
|
.reduce<
|
|
string | undefined
|
|
>((str, variable) => `var(${variable}${str ? `, ${str}` : ""})`, undefined);
|
|
}
|
|
return `var(${props})`;
|
|
}
|
|
|
|
export function computeCssValue(
|
|
prop: string | string[],
|
|
computedStyles: CSSStyleDeclaration
|
|
): string | undefined {
|
|
if (Array.isArray(prop)) {
|
|
for (const property of prop) {
|
|
const value = computeCssValue(property, computedStyles);
|
|
if (value) return value;
|
|
}
|
|
return undefined;
|
|
}
|
|
|
|
if (!prop.endsWith("-color")) {
|
|
return undefined;
|
|
}
|
|
return computedStyles.getPropertyValue(prop).trim() || undefined;
|
|
}
|