Skip to content

Commit

Permalink
WEB-2085 json sort
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Ladaria committed Nov 6, 2024
1 parent 858d045 commit b9916a6
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 163 deletions.
19 changes: 18 additions & 1 deletion packages/generate-design-tokens/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
const toCamelCase = (str) => str.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
const toPascalCase = (str) => capitalize(toCamelCase(str));

const jsonSort = (obj) => {
if (Array.isArray(obj)) {
return obj.map(jsonSort);
}

if (typeof obj !== 'object' || obj === null) {
return obj;
}

return Object.keys(obj)
.sort((a, b) => a.localeCompare(b, undefined, {numeric: true, sensitivity: 'base'}))
.reduce((acc, key) => {
acc[key] = jsonSort(obj[key]);
return acc;
}, {});
};

/**
* @param {{angle: number, colors: Array<{
* value: string,
Expand Down Expand Up @@ -127,7 +144,7 @@ export const get${toPascalCase(skinName)}Skin: GetKnownSkin = () => {
)
.join(',')}
},
textPresets: ${JSON.stringify(textTokens)},
textPresets: ${JSON.stringify(jsonSort(textTokens))},
};
return skin;
};
Expand Down
34 changes: 17 additions & 17 deletions src/skins/blau.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -328,29 +328,29 @@ export const getBlauSkin: GetKnownSkin = () => {
mediaSmall: '8px',
},
textPresets: {
cardTitle: {weight: 'regular'},
button: {weight: 'medium'},
cardTitle: {weight: 'regular'},
indicator: {weight: 'medium'},
link: {weight: 'medium'},
navigationBar: {weight: 'medium'},
tabsLabel: {
lineHeight: {desktop: 24, mobile: 24},
size: {desktop: 18, mobile: 16},
weight: 'medium',
size: {mobile: 16, desktop: 18},
lineHeight: {mobile: 24, desktop: 24},
},
link: {weight: 'medium'},
text1: {lineHeight: {desktop: 20, mobile: 16}, size: {desktop: 14, mobile: 12}},
text2: {lineHeight: {desktop: 24, mobile: 20}, size: {desktop: 16, mobile: 14}},
text3: {lineHeight: {desktop: 24, mobile: 24}, size: {desktop: 18, mobile: 16}},
text4: {lineHeight: {desktop: 28, mobile: 24}, size: {desktop: 20, mobile: 18}},
text5: {lineHeight: {desktop: 32, mobile: 24}, size: {desktop: 28, mobile: 20}, weight: 'light'},
text6: {lineHeight: {desktop: 40, mobile: 32}, size: {desktop: 32, mobile: 24}, weight: 'light'},
text7: {lineHeight: {desktop: 48, mobile: 32}, size: {desktop: 40, mobile: 28}, weight: 'light'},
text8: {lineHeight: {desktop: 56, mobile: 40}, size: {desktop: 48, mobile: 32}, weight: 'light'},
text9: {lineHeight: {desktop: 64, mobile: 48}, size: {desktop: 56, mobile: 40}, weight: 'light'},
text10: {lineHeight: {desktop: 72, mobile: 56}, size: {desktop: 64, mobile: 48}, weight: 'light'},
title1: {weight: 'medium'},
title2: {weight: 'light'},
title3: {weight: 'light', size: {mobile: 20, desktop: 28}, lineHeight: {mobile: 24, desktop: 32}},
indicator: {weight: 'medium'},
navigationBar: {weight: 'medium'},
text5: {weight: 'light', size: {mobile: 20, desktop: 28}, lineHeight: {mobile: 24, desktop: 32}},
text6: {weight: 'light', size: {mobile: 24, desktop: 32}, lineHeight: {mobile: 32, desktop: 40}},
text7: {weight: 'light', size: {mobile: 28, desktop: 40}, lineHeight: {mobile: 32, desktop: 48}},
text8: {weight: 'light', size: {mobile: 32, desktop: 48}, lineHeight: {mobile: 40, desktop: 56}},
text9: {weight: 'light', size: {mobile: 40, desktop: 56}, lineHeight: {mobile: 48, desktop: 64}},
text10: {weight: 'light', size: {mobile: 48, desktop: 64}, lineHeight: {mobile: 56, desktop: 72}},
text1: {size: {mobile: 12, desktop: 14}, lineHeight: {mobile: 16, desktop: 20}},
text2: {size: {mobile: 14, desktop: 16}, lineHeight: {mobile: 20, desktop: 24}},
text3: {size: {mobile: 16, desktop: 18}, lineHeight: {mobile: 24, desktop: 24}},
text4: {size: {mobile: 18, desktop: 20}, lineHeight: {mobile: 24, desktop: 28}},
title3: {lineHeight: {desktop: 32, mobile: 24}, size: {desktop: 28, mobile: 20}, weight: 'light'},
},
};
return skin;
Expand Down
34 changes: 17 additions & 17 deletions src/skins/movistar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -346,29 +346,29 @@ export const getMovistarSkin: GetKnownSkin = () => {
mediaSmall: '8px',
},
textPresets: {
cardTitle: {weight: 'bold'},
button: {weight: 'medium'},
cardTitle: {weight: 'bold'},
indicator: {weight: 'medium'},
link: {weight: 'medium'},
navigationBar: {weight: 'medium'},
tabsLabel: {
lineHeight: {desktop: 24, mobile: 24},
size: {desktop: 18, mobile: 16},
weight: 'medium',
size: {mobile: 16, desktop: 18},
lineHeight: {mobile: 24, desktop: 24},
},
link: {weight: 'medium'},
text1: {lineHeight: {desktop: 20, mobile: 16}, size: {desktop: 14, mobile: 12}},
text2: {lineHeight: {desktop: 24, mobile: 20}, size: {desktop: 16, mobile: 14}},
text3: {lineHeight: {desktop: 24, mobile: 24}, size: {desktop: 18, mobile: 16}},
text4: {lineHeight: {desktop: 28, mobile: 24}, size: {desktop: 20, mobile: 18}},
text5: {lineHeight: {desktop: 32, mobile: 24}, size: {desktop: 28, mobile: 20}, weight: 'bold'},
text6: {lineHeight: {desktop: 40, mobile: 32}, size: {desktop: 32, mobile: 24}, weight: 'bold'},
text7: {lineHeight: {desktop: 48, mobile: 32}, size: {desktop: 40, mobile: 28}, weight: 'bold'},
text8: {lineHeight: {desktop: 56, mobile: 40}, size: {desktop: 48, mobile: 32}, weight: 'bold'},
text9: {lineHeight: {desktop: 64, mobile: 48}, size: {desktop: 56, mobile: 40}, weight: 'bold'},
text10: {lineHeight: {desktop: 72, mobile: 56}, size: {desktop: 64, mobile: 48}, weight: 'bold'},
title1: {weight: 'medium'},
title2: {weight: 'bold'},
title3: {weight: 'bold', size: {mobile: 20, desktop: 28}, lineHeight: {mobile: 24, desktop: 32}},
indicator: {weight: 'medium'},
navigationBar: {weight: 'medium'},
text5: {weight: 'bold', size: {mobile: 20, desktop: 28}, lineHeight: {mobile: 24, desktop: 32}},
text6: {weight: 'bold', size: {mobile: 24, desktop: 32}, lineHeight: {mobile: 32, desktop: 40}},
text7: {weight: 'bold', size: {mobile: 28, desktop: 40}, lineHeight: {mobile: 32, desktop: 48}},
text8: {weight: 'bold', size: {mobile: 32, desktop: 48}, lineHeight: {mobile: 40, desktop: 56}},
text9: {weight: 'bold', size: {mobile: 40, desktop: 56}, lineHeight: {mobile: 48, desktop: 64}},
text10: {weight: 'bold', size: {mobile: 48, desktop: 64}, lineHeight: {mobile: 56, desktop: 72}},
text1: {size: {mobile: 12, desktop: 14}, lineHeight: {mobile: 16, desktop: 20}},
text2: {size: {mobile: 14, desktop: 16}, lineHeight: {mobile: 20, desktop: 24}},
text3: {size: {mobile: 16, desktop: 18}, lineHeight: {mobile: 24, desktop: 24}},
text4: {size: {mobile: 18, desktop: 20}, lineHeight: {mobile: 24, desktop: 28}},
title3: {lineHeight: {desktop: 32, mobile: 24}, size: {desktop: 28, mobile: 20}, weight: 'bold'},
},
};
return skin;
Expand Down
34 changes: 17 additions & 17 deletions src/skins/o2-new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,29 +336,29 @@ export const getO2NewSkin: GetKnownSkin = () => {
mediaSmall: '8px',
},
textPresets: {
cardTitle: {weight: 'medium'},
button: {weight: 'medium'},
cardTitle: {weight: 'medium'},
indicator: {weight: 'medium'},
link: {weight: 'medium'},
navigationBar: {weight: 'medium'},
tabsLabel: {
lineHeight: {desktop: 24, mobile: 24},
size: {desktop: 18, mobile: 16},
weight: 'medium',
size: {mobile: 16, desktop: 18},
lineHeight: {mobile: 24, desktop: 24},
},
link: {weight: 'medium'},
text1: {lineHeight: {desktop: 20, mobile: 16}, size: {desktop: 14, mobile: 12}},
text2: {lineHeight: {desktop: 24, mobile: 20}, size: {desktop: 16, mobile: 14}},
text3: {lineHeight: {desktop: 24, mobile: 24}, size: {desktop: 18, mobile: 16}},
text4: {lineHeight: {desktop: 28, mobile: 24}, size: {desktop: 20, mobile: 18}},
text5: {lineHeight: {desktop: 32, mobile: 24}, size: {desktop: 28, mobile: 20}, weight: 'bold'},
text6: {lineHeight: {desktop: 40, mobile: 32}, size: {desktop: 32, mobile: 24}, weight: 'bold'},
text7: {lineHeight: {desktop: 48, mobile: 32}, size: {desktop: 40, mobile: 28}, weight: 'bold'},
text8: {lineHeight: {desktop: 56, mobile: 40}, size: {desktop: 48, mobile: 32}, weight: 'bold'},
text9: {lineHeight: {desktop: 64, mobile: 48}, size: {desktop: 56, mobile: 40}, weight: 'bold'},
text10: {lineHeight: {desktop: 72, mobile: 56}, size: {desktop: 64, mobile: 48}, weight: 'bold'},
title1: {weight: 'medium'},
title2: {weight: 'bold'},
title3: {weight: 'bold', size: {mobile: 20, desktop: 28}, lineHeight: {mobile: 24, desktop: 32}},
indicator: {weight: 'medium'},
navigationBar: {weight: 'medium'},
text5: {weight: 'bold', size: {mobile: 20, desktop: 28}, lineHeight: {mobile: 24, desktop: 32}},
text6: {weight: 'bold', size: {mobile: 24, desktop: 32}, lineHeight: {mobile: 32, desktop: 40}},
text7: {weight: 'bold', size: {mobile: 28, desktop: 40}, lineHeight: {mobile: 32, desktop: 48}},
text8: {weight: 'bold', size: {mobile: 32, desktop: 48}, lineHeight: {mobile: 40, desktop: 56}},
text9: {weight: 'bold', size: {mobile: 40, desktop: 56}, lineHeight: {mobile: 48, desktop: 64}},
text10: {weight: 'bold', size: {mobile: 48, desktop: 64}, lineHeight: {mobile: 56, desktop: 72}},
text1: {size: {mobile: 12, desktop: 14}, lineHeight: {mobile: 16, desktop: 20}},
text2: {size: {mobile: 14, desktop: 16}, lineHeight: {mobile: 20, desktop: 24}},
text3: {size: {mobile: 16, desktop: 18}, lineHeight: {mobile: 24, desktop: 24}},
text4: {size: {mobile: 18, desktop: 20}, lineHeight: {mobile: 24, desktop: 28}},
title3: {lineHeight: {desktop: 32, mobile: 24}, size: {desktop: 28, mobile: 20}, weight: 'bold'},
},
};
return skin;
Expand Down
34 changes: 17 additions & 17 deletions src/skins/o2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,29 +333,29 @@ export const getO2Skin: GetKnownSkin = () => {
mediaSmall: '8px',
},
textPresets: {
cardTitle: {weight: 'regular'},
button: {weight: 'medium'},
cardTitle: {weight: 'regular'},
indicator: {weight: 'medium'},
link: {weight: 'medium'},
navigationBar: {weight: 'medium'},
tabsLabel: {
lineHeight: {desktop: 24, mobile: 24},
size: {desktop: 18, mobile: 16},
weight: 'medium',
size: {mobile: 16, desktop: 18},
lineHeight: {mobile: 24, desktop: 24},
},
link: {weight: 'medium'},
text1: {lineHeight: {desktop: 20, mobile: 16}, size: {desktop: 14, mobile: 12}},
text2: {lineHeight: {desktop: 24, mobile: 20}, size: {desktop: 16, mobile: 14}},
text3: {lineHeight: {desktop: 24, mobile: 24}, size: {desktop: 18, mobile: 16}},
text4: {lineHeight: {desktop: 28, mobile: 24}, size: {desktop: 20, mobile: 18}},
text5: {lineHeight: {desktop: 32, mobile: 24}, size: {desktop: 28, mobile: 20}, weight: 'light'},
text6: {lineHeight: {desktop: 40, mobile: 32}, size: {desktop: 32, mobile: 24}, weight: 'light'},
text7: {lineHeight: {desktop: 48, mobile: 32}, size: {desktop: 40, mobile: 28}, weight: 'light'},
text8: {lineHeight: {desktop: 56, mobile: 40}, size: {desktop: 48, mobile: 32}, weight: 'light'},
text9: {lineHeight: {desktop: 64, mobile: 48}, size: {desktop: 56, mobile: 40}, weight: 'light'},
text10: {lineHeight: {desktop: 72, mobile: 56}, size: {desktop: 64, mobile: 48}, weight: 'light'},
title1: {weight: 'medium'},
title2: {weight: 'light'},
title3: {weight: 'light', size: {mobile: 20, desktop: 28}, lineHeight: {mobile: 24, desktop: 32}},
indicator: {weight: 'medium'},
navigationBar: {weight: 'medium'},
text5: {weight: 'light', size: {mobile: 20, desktop: 28}, lineHeight: {mobile: 24, desktop: 32}},
text6: {weight: 'light', size: {mobile: 24, desktop: 32}, lineHeight: {mobile: 32, desktop: 40}},
text7: {weight: 'light', size: {mobile: 28, desktop: 40}, lineHeight: {mobile: 32, desktop: 48}},
text8: {weight: 'light', size: {mobile: 32, desktop: 48}, lineHeight: {mobile: 40, desktop: 56}},
text9: {weight: 'light', size: {mobile: 40, desktop: 56}, lineHeight: {mobile: 48, desktop: 64}},
text10: {weight: 'light', size: {mobile: 48, desktop: 64}, lineHeight: {mobile: 56, desktop: 72}},
text1: {size: {mobile: 12, desktop: 14}, lineHeight: {mobile: 16, desktop: 20}},
text2: {size: {mobile: 14, desktop: 16}, lineHeight: {mobile: 20, desktop: 24}},
text3: {size: {mobile: 16, desktop: 18}, lineHeight: {mobile: 24, desktop: 24}},
text4: {size: {mobile: 18, desktop: 20}, lineHeight: {mobile: 24, desktop: 28}},
title3: {lineHeight: {desktop: 32, mobile: 24}, size: {desktop: 28, mobile: 20}, weight: 'light'},
},
};
return skin;
Expand Down
58 changes: 29 additions & 29 deletions src/skins/telefonica.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -327,57 +327,57 @@ export const getTelefonicaSkin: GetKnownSkin = () => {
mediaSmall: '0px',
},
textPresets: {
cardTitle: {weight: 'regular'},
button: {weight: 'medium'},
cardTitle: {weight: 'regular'},
indicator: {weight: 'medium'},
link: {weight: 'medium'},
navigationBar: {weight: 'medium'},
tabsLabel: {
lineHeight: {desktop: 24, mobile: 24},
size: {desktop: 18, mobile: 16},
weight: 'medium',
size: {mobile: 16, desktop: 18},
lineHeight: {mobile: 24, desktop: 24},
},
link: {weight: 'medium'},
title1: {weight: 'medium'},
title2: {weight: 'regular'},
title3: {
weight: 'regular',
size: {mobile: 20, desktop: 28},
lineHeight: {mobile: 24, desktop: 32},
},
indicator: {weight: 'medium'},
navigationBar: {weight: 'medium'},
text1: {lineHeight: {desktop: 20, mobile: 16}, size: {desktop: 14, mobile: 12}},
text2: {lineHeight: {desktop: 24, mobile: 20}, size: {desktop: 16, mobile: 14}},
text3: {lineHeight: {desktop: 24, mobile: 24}, size: {desktop: 18, mobile: 16}},
text4: {lineHeight: {desktop: 28, mobile: 24}, size: {desktop: 20, mobile: 18}},
text5: {
lineHeight: {desktop: 32, mobile: 24},
size: {desktop: 28, mobile: 20},
weight: 'regular',
size: {mobile: 20, desktop: 28},
lineHeight: {mobile: 24, desktop: 32},
},
text6: {
lineHeight: {desktop: 40, mobile: 32},
size: {desktop: 32, mobile: 24},
weight: 'regular',
size: {mobile: 24, desktop: 32},
lineHeight: {mobile: 32, desktop: 40},
},
text7: {
lineHeight: {desktop: 48, mobile: 32},
size: {desktop: 40, mobile: 28},
weight: 'regular',
size: {mobile: 28, desktop: 40},
lineHeight: {mobile: 32, desktop: 48},
},
text8: {
lineHeight: {desktop: 56, mobile: 40},
size: {desktop: 48, mobile: 32},
weight: 'regular',
size: {mobile: 32, desktop: 48},
lineHeight: {mobile: 40, desktop: 56},
},
text9: {
lineHeight: {desktop: 64, mobile: 48},
size: {desktop: 56, mobile: 40},
weight: 'regular',
size: {mobile: 40, desktop: 56},
lineHeight: {mobile: 48, desktop: 64},
},
text10: {
lineHeight: {desktop: 72, mobile: 56},
size: {desktop: 64, mobile: 48},
weight: 'regular',
},
title1: {weight: 'medium'},
title2: {weight: 'regular'},
title3: {
lineHeight: {desktop: 32, mobile: 24},
size: {desktop: 28, mobile: 20},
weight: 'regular',
size: {mobile: 48, desktop: 64},
lineHeight: {mobile: 56, desktop: 72},
},
text1: {size: {mobile: 12, desktop: 14}, lineHeight: {mobile: 16, desktop: 20}},
text2: {size: {mobile: 14, desktop: 16}, lineHeight: {mobile: 20, desktop: 24}},
text3: {size: {mobile: 16, desktop: 18}, lineHeight: {mobile: 24, desktop: 24}},
text4: {size: {mobile: 18, desktop: 20}, lineHeight: {mobile: 24, desktop: 28}},
},
};
return skin;
Expand Down
Loading

0 comments on commit b9916a6

Please sign in to comment.