Skip to content

Instantly share code, notes, and snippets.

@germain-gg
Created January 30, 2023 16:15
Show Gist options
  • Save germain-gg/edfd5d7352593ea6c01c99ca5e562a0f to your computer and use it in GitHub Desktop.
Save germain-gg/edfd5d7352593ea6c01c99ca5e562a0f to your computer and use it in GitHub Desktop.
function fromLeonardoColorToTokenStudio(leonardoColors) {
return {
"colors": leonardoColors.reduce(function (memo, entry) {
if (entry.values) {
for (const value of entry.values) {
const [name, shade] = value.name.split(/(?=[1-9])/g);
memo[name] = {
...(memo[name] || {}),
[shade]: {
value: value.value,
type: "color"
}
}
if (value.contrast) {
memo[name][shade].description = `WCAG: ${value.contrast}`;
}
}
}
return memo;
}, {})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment