Skip to content

Commit 5939509

Browse files
authored
expose hasDash for the intellisense plugin (#9594)
1 parent 4041c86 commit 5939509

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

src/lib/setupContextUtils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,7 @@ function registerPlugins(plugins, context) {
969969
name,
970970
isArbitrary: options.type === Symbol.for('MATCH_VARIANT'),
971971
values: Object.keys(options.values ?? {}),
972+
hasDash: name !== '@',
972973
selectors({ modifier, value } = {}) {
973974
let candidate = '__TAILWIND_PLACEHOLDER__'
974975

tests/getVariants.test.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ it('should return a list of variants with meta information about the variant', (
1212
expect(variants).toContainEqual({
1313
name: 'hover',
1414
isArbitrary: false,
15+
hasDash: true,
1516
values: [],
1617
selectors: expect.any(Function),
1718
})
1819

1920
expect(variants).toContainEqual({
2021
name: 'group',
2122
isArbitrary: true,
23+
hasDash: true,
2224
values: expect.any(Array),
2325
selectors: expect.any(Function),
2426
})
@@ -138,3 +140,47 @@ it('should work for plugins that still use the modifySelectors API', () => {
138140
let variant = variants.find((v) => v.name === 'foo')
139141
expect(variant.selectors({})).toEqual(['@supports (display: grid) { .foo .foo\\:& }'])
140142
})
143+
144+
it('should special case the `@`', () => {
145+
let config = {
146+
plugins: [
147+
({ matchVariant }) => {
148+
matchVariant(
149+
'@',
150+
(value, { modifier }) => `@container ${modifier ?? ''} (min-width: ${value})`,
151+
{
152+
modifiers: 'any',
153+
values: {
154+
xs: '20rem',
155+
sm: '24rem',
156+
md: '28rem',
157+
lg: '32rem',
158+
xl: '36rem',
159+
'2xl': '42rem',
160+
'3xl': '48rem',
161+
'4xl': '56rem',
162+
'5xl': '64rem',
163+
'6xl': '72rem',
164+
'7xl': '80rem',
165+
},
166+
}
167+
)
168+
},
169+
],
170+
}
171+
let context = createContext(resolveConfig(config))
172+
173+
let variants = context.getVariants()
174+
175+
let variant = variants.find((v) => v.name === '@')
176+
expect(variant).toEqual({
177+
name: '@',
178+
isArbitrary: true,
179+
hasDash: false,
180+
values: expect.any(Array),
181+
selectors: expect.any(Function),
182+
})
183+
expect(variant.selectors({ value: 'xs', modifier: 'foo' })).toEqual([
184+
'@container foo (min-width: 20rem)',
185+
])
186+
})

0 commit comments

Comments
 (0)