Skip to content

Commit

Permalink
fix: check color transform value string (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenbroekema authored Sep 13, 2024
1 parent 8b70914 commit 61af02f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/nice-scissors-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tokens-studio/sd-transforms': patch
---

Check for color transforms that the value is of type string, since other color object types could occur from previously ran transforms.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/css/transformHEXRGBa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export function transformHEXRGBaForCSS(token: DesignToken): DesignToken['value']
});
};

const transformProp = (val: Record<string, string>, prop: string) => {
if (val[prop] !== undefined) {
const transformProp = (val: Record<string, unknown>, prop: string) => {
if (val[prop] !== undefined && typeof val[prop] === 'string') {
val[prop] = transformHEXRGBa(val[prop]);
}
return val;
Expand Down
1 change: 1 addition & 0 deletions src/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export async function register(sd: typeof StyleDictionary, transformOpts?: Trans
type: 'value',
transitive: true,
filter: token =>
typeof (token.$value ?? token.value) === 'string' &&
(token.$type ?? token.type) === 'color' &&
token.$extensions &&
token.$extensions['studio.tokens']?.modify,
Expand Down

0 comments on commit 61af02f

Please sign in to comment.