Skip to content

Commit

Permalink
chore: use enums
Browse files Browse the repository at this point in the history
  • Loading branch information
Niznikr committed Jan 16, 2025
1 parent 422aa3f commit 2210a38
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions packages/tokens/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Config, TransformedToken } from 'style-dictionary/types';

import JsonToTS from 'json-to-ts';
import StyleDictionary from 'style-dictionary';
import { formats, transformGroups, transforms } from 'style-dictionary/enums';
import { fileHeader, minifyDictionary } from 'style-dictionary/utils';

const themes = ['dark', 'default'].map(
Expand All @@ -11,16 +12,16 @@ const themes = ['dark', 'default'].map(
platforms: {
css: {
prefix: 'lp',
transformGroup: 'css',
transforms: ['color/rgb'],
transformGroup: transformGroups.css,
transforms: [transforms.colorRgb],
options: {
outputReferences: true,
usesDtcg: true,
},
files: [
{
destination: `${theme}.css`,
format: 'css/variables',
format: formats.cssVariables,
options: {
selector: theme === 'default' ? ':root, [data-theme]' : `[data-theme='${theme}']`,
},
Expand All @@ -46,8 +47,13 @@ const sd = new StyleDictionary({
css: {
prefix: 'lp',
basePxFontSize: 16,
transformGroup: 'css',
transforms: ['name/kebab', 'size/pxToRem', 'color/rgb', 'attribute/font'],
transformGroup: transformGroups.css,
transforms: [
transforms.nameKebab,
transforms.sizePxToRem,
transforms.colorRgb,
'attribute/font',
],
buildPath: 'dist/',
options: {
outputReferences: true,
Expand All @@ -56,7 +62,7 @@ const sd = new StyleDictionary({
files: [
{
destination: 'index.css',
format: 'css/variables',
format: formats.cssVariables,
filter: (token) => !token.filePath.includes('aliases'),
},
{
Expand All @@ -78,8 +84,8 @@ const sd = new StyleDictionary({
},
js: {
basePxFontSize: 16,
transformGroup: 'js',
transforms: ['size/pxToRem', 'color/rgb'],
transformGroup: transformGroups.js,
transforms: [transforms.sizePxToRem, transforms.colorRgb],
buildPath: 'dist/',
options: {
outputReferences: true,
Expand All @@ -102,7 +108,7 @@ const sd = new StyleDictionary({
},
json: {
buildPath: 'dist/',
transforms: ['name/kebab', 'custom/value/name'],
transforms: [transforms.nameKebab, 'custom/value/name'],
options: {
outputReferences: true,
usesDtcg: true,
Expand All @@ -117,8 +123,8 @@ const sd = new StyleDictionary({
vscode: {
basePxFontSize: 16,
buildPath: 'dist/',
transformGroup: 'css',
transforms: ['name/kebab', 'size/pxToRem', 'color/rgb'],
transformGroup: transformGroups.css,
transforms: [transforms.nameKebab, transforms.sizePxToRem, transforms.colorRgb],
options: {
outputReferences: true,
usesDtcg: true,
Expand Down

0 comments on commit 2210a38

Please sign in to comment.