tailwindcss/src/util/flattenColorPalette.js
2020-08-18 22:35:10 +02:00

19 lines
442 B
JavaScript

import _ from 'lodash'
export default function flattenColorPalette(colors) {
const result = _(colors)
.flatMap((color, name) => {
if (_.isFunction(color) || !_.isObject(color)) {
return [[name, color]]
}
return _.map(color, (value, key) => {
const suffix = key === 'default' ? '' : `-${key}`
return [`${name}${suffix}`, value]
})
})
.fromPairs()
.value()
return result
}