Created
January 30, 2023 16:15
-
-
Save germain-gg/edfd5d7352593ea6c01c99ca5e562a0f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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