mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Allow modules: [...variants] syntax to bulk apply variants
This commit is contained in:
parent
0ca7f7a69c
commit
76691a563d
@ -80,6 +80,33 @@ test('setting modules to "all" creates all variants for all modules', () => {
|
||||
})
|
||||
})
|
||||
|
||||
test('setting modules to an array of variants applies those variants to all modules', () => {
|
||||
const userConfig = {
|
||||
modules: ['responsive', 'focus', 'hover', 'custom-variant'],
|
||||
options: {},
|
||||
}
|
||||
|
||||
const defaultConfig = {
|
||||
modules: {
|
||||
flexbox: ['responsive'],
|
||||
textAlign: ['hover'],
|
||||
textColors: ['focus'],
|
||||
},
|
||||
options: {},
|
||||
}
|
||||
|
||||
const result = mergeConfigWithDefaults(userConfig, defaultConfig)
|
||||
|
||||
expect(result).toEqual({
|
||||
modules: {
|
||||
flexbox: ['responsive', 'focus', 'hover', 'custom-variant'],
|
||||
textAlign: ['responsive', 'focus', 'hover', 'custom-variant'],
|
||||
textColors: ['responsive', 'focus', 'hover', 'custom-variant'],
|
||||
},
|
||||
options: {},
|
||||
})
|
||||
})
|
||||
|
||||
test('user options are merged with default options', () => {
|
||||
const userConfig = {
|
||||
modules: {},
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
import _ from 'lodash'
|
||||
|
||||
function mergeModules(userModules, defaultModules) {
|
||||
if (_.isArray(userModules)) {
|
||||
return _.mapValues(defaultModules, () => userModules)
|
||||
}
|
||||
|
||||
if (userModules === 'all') {
|
||||
return _.mapValues(defaultModules, () => [
|
||||
'responsive',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user