diff --git a/packages/colors/tasks/build.js b/packages/colors/tasks/build.js index b84c3bbf..78627310 100644 --- a/packages/colors/tasks/build.js +++ b/packages/colors/tasks/build.js @@ -62,11 +62,35 @@ async function build() { prettier.format(mixins, prettierOptions) ); + const colorMapValues = Object.keys(colors).map(swatch => { + return { + swatch, + value: Object.keys(colors[swatch]).reduce((acc, grade, index) => { + const property = `${grade}: ${colors[swatch][grade]},`; + if (index === 0) { + return property; + } + return acc + '\n' + property; + }, ''), + }; + }); + const colorMap = `$ibm-color-map: ( + ${colorMapValues + .map( + ({ swatch, value }) => `${swatch}: ( + ${value} +),\n` + ) + .join('\n')} +)`; + const colorsFile = `${GENERATED_COMMENT} @import './mixins'; @include color-values(); + +${colorMap} `; await fs.writeFile(