mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
20 lines
419 B
JavaScript
20 lines
419 B
JavaScript
import _ from 'lodash'
|
|
|
|
export default function flattenColorPalette(colors) {
|
|
const result = _(colors)
|
|
.flatMap((color, name) => {
|
|
if (!_.isObject(color)) {
|
|
return [[name, color]]
|
|
}
|
|
|
|
return _.map(color, (value, key) => {
|
|
const suffix = key === 'default' ? '' : `-${key}`
|
|
return [`${name}${suffix}`, value]
|
|
})
|
|
})
|
|
.fromPairs()
|
|
.value()
|
|
|
|
return result
|
|
}
|