fix: use khebab case

This commit is contained in:
Ephraim Atta-Duncan
2024-12-11 15:55:35 +00:00
parent 50a7b59371
commit 4f822414cf

View File

@ -1,4 +1,5 @@
import { colord } from 'colord';
import { toKebabCase } from 'remeda';
import { z } from 'zod';
export const ZCssVarsSchema = z
@ -46,9 +47,7 @@ export const toNativeCssVars = (vars: TCssVarsSchema) => {
const color = colord(value);
const { h, s, l } = color.toHsl();
// Convert camelCase to kebab-case (e.g., mutedForeground -> muted-foreground)
const kebabKey = key.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
cssVars[`--${kebabKey}`] = `${h} ${s} ${l}`;
cssVars[`--${toKebabCase(key)}`] = `${h} ${s} ${l}`;
}
}