diff --git a/.changeset/twenty-sloths-carry.md b/.changeset/twenty-sloths-carry.md new file mode 100644 index 000000000..bd8355229 --- /dev/null +++ b/.changeset/twenty-sloths-carry.md @@ -0,0 +1,5 @@ +--- +"@launchpad-ui/tokens": patch +--- + +Use CSS `@property` for primitive tokens diff --git a/packages/tokens/build.ts b/packages/tokens/build.ts index 706f3d885..402eb68e5 100644 --- a/packages/tokens/build.ts +++ b/packages/tokens/build.ts @@ -10,7 +10,7 @@ const sd = new StyleDictionary({ css: { prefix: 'lp', transformGroup: 'css', - transforms: ['name/kebab', 'time/seconds', 'size/rem', 'color/rgb', 'attribute/font'], + transforms: ['name/kebab', 'time/seconds', 'size/remToPx', 'color/rgb', 'attribute/font'], buildPath: 'dist/', options: { outputReferences: true, @@ -19,7 +19,7 @@ const sd = new StyleDictionary({ files: [ { destination: 'index.css', - format: 'css/variables', + format: 'css/property', filter: (token) => token.filePath !== 'src/color-aliases.json', }, { @@ -214,6 +214,42 @@ sd.registerFormat({ }, }); +sd.registerFormat({ + name: 'css/property', + format: async ({ dictionary, file }) => { + const header = await fileHeader({ file }); + return ( + header + + dictionary.allTokens + .map((token) => { + let syntax = '*'; + switch (token.$type) { + case 'color': + syntax = token.name.includes('gradient') ? '*' : ''; + break; + case 'duration': + syntax = '