Skip to content

Commit

Permalink
transform token kind to kebab-case in css var
Browse files Browse the repository at this point in the history
  • Loading branch information
yukukotani committed Oct 14, 2024
1 parent 457153f commit a84213e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/__snapshots__/sheet.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,6 @@ exports[`generateSheets > generates simple single property 1`] = `

exports[`generateThemeSheets > generates a token which refer the other token 1`] = `":root { --j-colors-gray: #666666; --j-colors-primary: var(--j-colors-gray); }"`;

exports[`generateThemeSheets > generates multiple tokens 1`] = `":root { --j-colors-gray-200: #eeeeee; --j-colors-gray-600: #666666; --j-spaces-sm: 4px; --j-sizes-lg: 120px; --j-fontSizes-md: 16px; --j-radii-xs: 2px; }"`;
exports[`generateThemeSheets > generates multiple tokens 1`] = `":root { --j-colors-gray-200: #eeeeee; --j-colors-gray-600: #666666; --j-spaces-sm: 4px; --j-sizes-lg: 120px; --j-font-sizes-md: 16px; --j-radii-xs: 2px; }"`;

exports[`generateThemeSheets > generates single token 1`] = `":root { --j-colors-light-gray: #666666; }"`;
2 changes: 1 addition & 1 deletion src/sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function generateThemeSheets(config: ConfigSchema) {

export function transformTokenToCssVariable(token: string, kind?: string) {
const t = toKebabCase(token).replaceAll(".", "-");
return `--j${kind ? `-${kind}-` : "-"}${t}`;
return `--j${kind ? `-${toKebabCase(kind)}-` : "-"}${t}`;
}

export function resolvePropertyValue(value: unknown) {
Expand Down

0 comments on commit a84213e

Please sign in to comment.