Files
Toju/toju-app/src/app/domains/theme/feature/theme-style-application.logic.ts
2026-04-27 03:02:13 +02:00

15 lines
459 B
TypeScript

export function toCssStylePropertyName(propertyName: string): string {
if (propertyName.startsWith('--')) {
return propertyName;
}
return propertyName.replace(/([A-Z])/g, '-$1').toLowerCase();
}
export function applyThemeStyleDeclaration(host: HTMLElement, propertyName: string, value: string): string {
const cssPropertyName = toCssStylePropertyName(propertyName);
host.style.setProperty(cssPropertyName, value);
return cssPropertyName;
}