Skip to content

Commit 61af02f

Browse files
fix: check color transform value string (#317)
1 parent 8b70914 commit 61af02f

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

.changeset/nice-scissors-think.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tokens-studio/sd-transforms': patch
3+
---
4+
5+
Check for color transforms that the value is of type string, since other color object types could occur from previously ran transforms.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/css/transformHEXRGBa.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export function transformHEXRGBaForCSS(token: DesignToken): DesignToken['value']
2424
});
2525
};
2626

27-
const transformProp = (val: Record<string, string>, prop: string) => {
28-
if (val[prop] !== undefined) {
27+
const transformProp = (val: Record<string, unknown>, prop: string) => {
28+
if (val[prop] !== undefined && typeof val[prop] === 'string') {
2929
val[prop] = transformHEXRGBa(val[prop]);
3030
}
3131
return val;

src/register.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ export async function register(sd: typeof StyleDictionary, transformOpts?: Trans
167167
type: 'value',
168168
transitive: true,
169169
filter: token =>
170+
typeof (token.$value ?? token.value) === 'string' &&
170171
(token.$type ?? token.type) === 'color' &&
171172
token.$extensions &&
172173
token.$extensions['studio.tokens']?.modify,

0 commit comments

Comments
 (0)