Allow passing CSS properties to theme(…)

This commit is contained in:
Jordan Pittman 2024-07-26 16:02:21 -04:00
parent 0b69c4c915
commit f463878ecb

View file

@ -466,6 +466,14 @@ export function compile(
},
theme(path: string, fallback?: any) {
if (path.startsWith('--')) {
if (path.endsWith('-*')) {
return Object.fromEntries(theme.namespace(path.slice(0, -2) as any).entries())
}
return theme.resolveValue(null, [path] as any) ?? fallback ?? null
}
path = path
// Escape dots used inside square brackets
.replace(/\[(.*?)\]/g, (_, value) => `-${value.replace('.', '_')}`)