Skip to content

Commit 1852504

Browse files
committed
Remove variant dark mode strategy
1 parent 2433d99 commit 1852504

File tree

2 files changed

+0
-97
lines changed

2 files changed

+0
-97
lines changed

src/corePlugins.js

-35
Original file line numberDiff line numberDiff line change
@@ -227,45 +227,10 @@ export let variantPlugins = {
227227
])
228228
}
229229

230-
if (mode === 'variant') {
231-
let formats
232-
if (Array.isArray(className)) {
233-
formats = className
234-
} else if (typeof className === 'function') {
235-
formats = className
236-
} else if (typeof className === 'string') {
237-
formats = [className]
238-
}
239-
240-
// TODO: We could also add these warnings if the user passes a function that returns string | string[]
241-
// But this is an advanced enough use case that it's probably not necessary
242-
if (Array.isArray(formats)) {
243-
for (let format of formats) {
244-
if (format === '.dark') {
245-
mode = false
246-
log.warn('darkmode-variant-without-selector', [
247-
'When using `variant` for `darkMode`, you must provide a selector.',
248-
'Example: `darkMode: ["variant", ".your-selector &"]`',
249-
])
250-
} else if (!format.includes('&')) {
251-
mode = false
252-
log.warn('darkmode-variant-without-ampersand', [
253-
'When using `variant` for `darkMode`, your selector must contain `&`.',
254-
'Example `darkMode: ["variant", ".your-selector &"]`',
255-
])
256-
}
257-
}
258-
}
259-
260-
className = formats
261-
}
262-
263230
if (mode === 'selector') {
264231
addVariant('dark', `&:where(${className}, ${className} *)`)
265232
} else if (mode === 'media') {
266233
addVariant('dark', '@media (prefers-color-scheme: dark)')
267-
} else if (mode === 'variant') {
268-
addVariant('dark', className)
269234
} else if (mode === 'class') {
270235
// Exists for pre v3.4 compatibility
271236
addVariant('dark', `:is(${className} &)`)

tests/dark-mode.test.js

-62
Original file line numberDiff line numberDiff line change
@@ -229,65 +229,3 @@ it('should use modern sorting otherwise', () => {
229229
`)
230230
})
231231
})
232-
233-
it('should allow customization of the dark mode variant', () => {
234-
let config = {
235-
darkMode: ['variant', '&:not(.light *)'],
236-
content: [{ raw: html`<div class="dark:font-bold"></div>` }],
237-
corePlugins: { preflight: false },
238-
}
239-
240-
let input = css`
241-
@tailwind utilities;
242-
`
243-
244-
return run(input, config).then((result) => {
245-
expect(result.css).toMatchFormattedCss(css`
246-
.dark\:font-bold:not(.light *) {
247-
font-weight: 700;
248-
}
249-
`)
250-
})
251-
})
252-
253-
it('should support parallel selectors for the dark mode variant', () => {
254-
let config = {
255-
darkMode: ['variant', ['&:not(.light *)', '&:not(.extralight *)']],
256-
content: [{ raw: html`<div class="dark:font-bold"></div>` }],
257-
corePlugins: { preflight: false },
258-
}
259-
260-
let input = css`
261-
@tailwind utilities;
262-
`
263-
264-
return run(input, config).then((result) => {
265-
expect(result.css).toMatchFormattedCss(css`
266-
.dark\:font-bold:not(.light *),
267-
.dark\:font-bold:not(.extralight *) {
268-
font-weight: 700;
269-
}
270-
`)
271-
})
272-
})
273-
274-
it('should support fn selectors for the dark mode variant', () => {
275-
let config = {
276-
darkMode: ['variant', () => ['&:not(.light *)', '&:not(.extralight *)']],
277-
content: [{ raw: html`<div class="dark:font-bold"></div>` }],
278-
corePlugins: { preflight: false },
279-
}
280-
281-
let input = css`
282-
@tailwind utilities;
283-
`
284-
285-
return run(input, config).then((result) => {
286-
expect(result.css).toMatchFormattedCss(css`
287-
.dark\:font-bold:not(.light *),
288-
.dark\:font-bold:not(.extralight *) {
289-
font-weight: 700;
290-
}
291-
`)
292-
})
293-
})

0 commit comments

Comments
 (0)