Skip to content

Commit 92c1274

Browse files
committed
Add 'without' helper to variant function API
1 parent d35973c commit 92c1274

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

__tests__/resolveConfig.test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,7 +1747,9 @@ test('variants can be defined as a function', () => {
17471747
borderWidth: ({ after }) => after(['active']),
17481748
backgroundImage: ({ after }) => after(['disabled'], 'hover'),
17491749
opacity: ({ after }) => after(['hover'], 'focus'),
1750-
cursor: ({ before, after }) => before(['checked'], 'hover', after(['hover'], 'focus')),
1750+
rotate: ({ without }) => without(['hover']),
1751+
cursor: ({ before, after, without }) =>
1752+
without(['responsive'], before(['checked'], 'hover', after(['hover'], 'focus'))),
17511753
},
17521754
}
17531755

@@ -1770,6 +1772,7 @@ test('variants can be defined as a function', () => {
17701772
borderWidth: ['responsive', 'focus'],
17711773
backgroundImage: ['responsive', 'hover', 'focus'],
17721774
opacity: ['responsive'],
1775+
rotate: ['responsive', 'hover', 'focus'],
17731776
cursor: ['responsive', 'focus'],
17741777
},
17751778
}
@@ -1789,7 +1792,8 @@ test('variants can be defined as a function', () => {
17891792
borderWidth: ['responsive', 'focus', 'active'],
17901793
backgroundImage: ['responsive', 'hover', 'disabled', 'focus'],
17911794
opacity: ['hover', 'responsive'],
1792-
cursor: ['responsive', 'focus', 'checked', 'hover'],
1795+
rotate: ['responsive', 'focus'],
1796+
cursor: ['focus', 'checked', 'hover'],
17931797
},
17941798
plugins: userConfig.plugins,
17951799
})

src/util/resolveConfig.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ function resolveVariants([firstConfig, ...variantConfigs]) {
174174
...existingPluginVariants.slice(index + 1),
175175
]
176176
},
177+
without(toRemove, existingPluginVariants = get(resolved, plugin, [])) {
178+
return existingPluginVariants.filter(v => !toRemove.includes(v))
179+
},
177180
})
178181
} else {
179182
resolved[plugin] = pluginVariants

0 commit comments

Comments
 (0)