15 lines
459 B
TypeScript
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;
|
|
}
|