Files
webstudio/packages/template/src/css.ts
T
Bogdan Chadkin 8a89f8e6b2 refactor: rewrite radix label template with jsx (#4665)
- added radix templates to components panel
- support interpolations in css tagged template
- added theme with static values
2024-12-28 16:58:56 +07:00

21 lines
589 B
TypeScript

import { parseCss } from "@webstudio-is/css-data";
import type { StyleProperty, StyleValue } from "@webstudio-is/css-engine";
export type TemplateStyleDecl = {
state?: string;
property: StyleProperty;
value: StyleValue;
};
export const css = (
strings: TemplateStringsArray,
...values: string[]
): TemplateStyleDecl[] => {
const cssString = `.styles{ ${String.raw({ raw: strings }, ...values)} }`;
const styles: TemplateStyleDecl[] = [];
for (const { state, property, value } of parseCss(cssString)) {
styles.push({ state, property, value });
}
return styles;
};