Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(exporter-tokens): Use correct casing in collections filter #1777

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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