mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
feat: allow for deeply nested color objects (#2148)
This commit is contained in:
parent
15d6fc4715
commit
58a600816c
@ -43,3 +43,35 @@ test('it flattens nested color objects', () => {
|
||||
'blue-3': 'rgb(0,0,100)',
|
||||
})
|
||||
})
|
||||
|
||||
test('it flattens deeply nested color objects', () => {
|
||||
expect(
|
||||
flattenColorPalette({
|
||||
primary: 'purple',
|
||||
secondary: {
|
||||
DEFAULT: 'blue',
|
||||
hover: 'cyan',
|
||||
focus: 'red',
|
||||
},
|
||||
button: {
|
||||
primary: {
|
||||
DEFAULT: 'magenta',
|
||||
hover: 'green',
|
||||
focus: {
|
||||
DEFAULT: 'yellow',
|
||||
variant: 'orange',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
).toEqual({
|
||||
primary: 'purple',
|
||||
secondary: 'blue',
|
||||
'secondary-hover': 'cyan',
|
||||
'secondary-focus': 'red',
|
||||
'button-primary': 'magenta',
|
||||
'button-primary-hover': 'green',
|
||||
'button-primary-focus': 'yellow',
|
||||
'button-primary-focus-variant': 'orange',
|
||||
})
|
||||
})
|
||||
|
||||
@ -7,7 +7,7 @@ export default function flattenColorPalette(colors) {
|
||||
return [[name, color]]
|
||||
}
|
||||
|
||||
return _.map(color, (value, key) => {
|
||||
return _.map(flattenColorPalette(color), (value, key) => {
|
||||
const suffix = key === 'DEFAULT' ? '' : `-${key}`
|
||||
return [`${name}${suffix}`, value]
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user