From 031061a06b170a3d40eb71d0c3dd04b4e8b6854b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kry=C5=A1p=C3=ADn?= Date: Tue, 26 Nov 2024 11:03:17 +0100 Subject: [PATCH] Fix(exporter-tokens): Use correct casing in collections filter --- exporters/tokens/exporter.json | 2 +- exporters/tokens/generated/exporter.cjs | 2 +- exporters/tokens/src/helpers/colorHelper.ts | 2 +- exporters/tokens/tests/fixtures/exampleCollectionTokens.ts | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/exporters/tokens/exporter.json b/exporters/tokens/exporter.json index 166aca57f2..65253fc940 100644 --- a/exporters/tokens/exporter.json +++ b/exporters/tokens/exporter.json @@ -4,7 +4,7 @@ "description": "Spirit Tokens Exporter allows you to export a tokens from Supernova", "author": "Spirit Design System Team ", "organization": "Alma Career", - "version": "1.0.0", + "version": "1.0.1", "usesBrands": true, "usesThemes": true, "executable": "/generated/exporter.cjs", diff --git a/exporters/tokens/generated/exporter.cjs b/exporters/tokens/generated/exporter.cjs index cb0c4ffeb9..4a2c8b5382 100644 --- a/exporters/tokens/generated/exporter.cjs +++ b/exporters/tokens/generated/exporter.cjs @@ -22,7 +22,7 @@ `:o.includes(m)?(r+=`${i.repeat(f)}${o} `,f+=1):o.includes(y)?(f-=1,r+=`${i.repeat(f)}${o} `):r+=`${i.repeat(f)}${o} -`;return r=Rt(r),r=xt(r),r},Te=/#([A-Fa-f0-9]{6,8})\b/g,jt=8,me=4,Bt=3,Ft=n=>n.length%2===0&&[...Array(n.length/2)].every((a,c)=>n[2*c]===n[2*c+1]),Lt=n=>n.split("").map((a,c)=>c%2===0?a:"").join(""),wt=n=>n.length===jt&&n.endsWith("ff")?n.slice(0,-2):n.length===me&&n.endsWith("f")?n.slice(0,-1):n,ye=n=>{const a=[Bt,me].includes(n.length);let c;return a?c=n:Ft(n)?c=Lt(n):c=n,c=wt(c),`#${c}`},X=n=>n.replace(Te,a=>ye(a.slice(1))),Z=(n,a,c,i)=>{let m=1;const y=i?`${i}-`:"";return a.split(",").map(r=>r.replace(Te,t=>{const o=`var(--${c}color-${y}${n}-color-${m.toString().padStart(2,"0")}, ${t})`;return m+=1,o})).join(",").replace(/0px/g,"0")},Mt=n=>n.filter(a=>{var m,y;if(a.tokenType!==k.TokenType.color)return!0;const c=a.properties.find(f=>f.name===Dt);if(!c)return!1;const i=(m=c.options)==null?void 0:m.find(f=>f.name===Nt);return i?((y=a.propertyValues)==null?void 0:y.Collection)===i.id:!1}),Q=n=>({radius:"radii",spacing:"spaces"})[n]||(n.endsWith("s")?n:`${n}s`),E=n=>P.NamingHelper.codeSafeVariableName(n,P.StringCase.camelCase),J={"radius-full":"full"},At=new Map([["breakpoint-mobile",0]]),A=(n,a)=>{const c=At.get(n);return typeof c==typeof a?c:a},Ht=n=>J[n]?J[n]:n,fe=(n,a)=>{const c=Object.entries(a).reduce((y,[f,r])=>{let t;return typeof r=="object"&&r!==null&&typeof y[f]=="object"?t=fe(y[f],r):t=r,{...y,[f]:t}},{...n}),i={},m={};return Object.entries(c).forEach(([y,f])=>{typeof f=="object"&&f!==null&&f.moveToTheEnd==="true"?(delete f.moveToTheEnd,m[y]=f):i[y]=f}),{...i,...m}};function ge(n){return Object.entries(n).map(([a,c])=>{if(typeof c=="object"&&c!==null){const i=ge(c);return`${a}: ( +`;return r=Rt(r),r=xt(r),r},Te=/#([A-Fa-f0-9]{6,8})\b/g,jt=8,me=4,Bt=3,Ft=n=>n.length%2===0&&[...Array(n.length/2)].every((a,c)=>n[2*c]===n[2*c+1]),Lt=n=>n.split("").map((a,c)=>c%2===0?a:"").join(""),wt=n=>n.length===jt&&n.endsWith("ff")?n.slice(0,-2):n.length===me&&n.endsWith("f")?n.slice(0,-1):n,ye=n=>{const a=[Bt,me].includes(n.length);let c;return a?c=n:Ft(n)?c=Lt(n):c=n,c=wt(c),`#${c}`},X=n=>n.replace(Te,a=>ye(a.slice(1))),Z=(n,a,c,i)=>{let m=1;const y=i?`${i}-`:"";return a.split(",").map(r=>r.replace(Te,t=>{const o=`var(--${c}color-${y}${n}-color-${m.toString().padStart(2,"0")}, ${t})`;return m+=1,o})).join(",").replace(/0px/g,"0")},Mt=n=>n.filter(a=>{var m,y;if(a.tokenType!==k.TokenType.color)return!0;const c=a.properties.find(f=>f.name===Dt);if(!c)return!1;const i=(m=c.options)==null?void 0:m.find(f=>f.name===Nt);return i?((y=a.propertyValues)==null?void 0:y.collection)===i.id:!1}),Q=n=>({radius:"radii",spacing:"spaces"})[n]||(n.endsWith("s")?n:`${n}s`),E=n=>P.NamingHelper.codeSafeVariableName(n,P.StringCase.camelCase),J={"radius-full":"full"},At=new Map([["breakpoint-mobile",0]]),A=(n,a)=>{const c=At.get(n);return typeof c==typeof a?c:a},Ht=n=>J[n]?J[n]:n,fe=(n,a)=>{const c=Object.entries(a).reduce((y,[f,r])=>{let t;return typeof r=="object"&&r!==null&&typeof y[f]=="object"?t=fe(y[f],r):t=r,{...y,[f]:t}},{...n}),i={},m={};return Object.entries(c).forEach(([y,f])=>{typeof f=="object"&&f!==null&&f.moveToTheEnd==="true"?(delete f.moveToTheEnd,m[y]=f):i[y]=f}),{...i,...m}};function ge(n){return Object.entries(n).map(([a,c])=>{if(typeof c=="object"&&c!==null){const i=ge(c);return`${a}: ( ${i} ), `}return`${a}: ${c}, diff --git a/exporters/tokens/src/helpers/colorHelper.ts b/exporters/tokens/src/helpers/colorHelper.ts index 37ddabc24a..d51e502864 100644 --- a/exporters/tokens/src/helpers/colorHelper.ts +++ b/exporters/tokens/src/helpers/colorHelper.ts @@ -95,6 +95,6 @@ export const filterColorCollections = (tokens: Token[]) => { return false; } - return item.propertyValues?.Collection === themeTokenOption.id; + return item.propertyValues?.collection === themeTokenOption.id; }); }; diff --git a/exporters/tokens/tests/fixtures/exampleCollectionTokens.ts b/exporters/tokens/tests/fixtures/exampleCollectionTokens.ts index 766753f265..a5b7c8c006 100644 --- a/exporters/tokens/tests/fixtures/exampleCollectionTokens.ts +++ b/exporters/tokens/tests/fixtures/exampleCollectionTokens.ts @@ -24,7 +24,7 @@ exampleCollectionTokens.set('colorCollectionRef1', { ], }, ], - propertyValues: { Collection: 'theme-tokens-id' }, + propertyValues: { collection: 'theme-tokens-id' }, } as unknown as ColorToken); exampleCollectionTokens.set('colorCollectionRef2', { @@ -113,7 +113,7 @@ export const expectedCollectionValue = [ ], }, ], - propertyValues: { Collection: 'theme-tokens-id' }, + propertyValues: { collection: 'theme-tokens-id' }, tokenType: 'Color', }, {