Skip to content

Commit

Permalink
Fix(exporter-tokens): Use correct casing in collections filter
Browse files Browse the repository at this point in the history
  • Loading branch information
crishpeen committed Nov 26, 2024
1 parent f3f9f73 commit 031061a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion exporters/tokens/exporter.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Spirit Tokens Exporter allows you to export a tokens from Supernova",
"author": "Spirit Design System Team <[email protected]>",
"organization": "Alma Career",
"version": "1.0.0",
"version": "1.0.1",
"usesBrands": true,
"usesThemes": true,
"executable": "/generated/exporter.cjs",
Expand Down
2 changes: 1 addition & 1 deletion exporters/tokens/generated/exporter.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
2 changes: 1 addition & 1 deletion exporters/tokens/src/helpers/colorHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ export const filterColorCollections = (tokens: Token[]) => {
return false;
}

return item.propertyValues?.Collection === themeTokenOption.id;
return item.propertyValues?.collection === themeTokenOption.id;
});
};
4 changes: 2 additions & 2 deletions exporters/tokens/tests/fixtures/exampleCollectionTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exampleCollectionTokens.set('colorCollectionRef1', {
],
},
],
propertyValues: { Collection: 'theme-tokens-id' },
propertyValues: { collection: 'theme-tokens-id' },
} as unknown as ColorToken);

exampleCollectionTokens.set('colorCollectionRef2', {
Expand Down Expand Up @@ -113,7 +113,7 @@ export const expectedCollectionValue = [
],
},
],
propertyValues: { Collection: 'theme-tokens-id' },
propertyValues: { collection: 'theme-tokens-id' },
tokenType: 'Color',
},
{
Expand Down

0 comments on commit 031061a

Please sign in to comment.