Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename variable
  • Loading branch information
thecrypticace committed Jan 5, 2024
commit 0e02e860542e94facf8eb11fb2d8c621f1cc9c02
22 changes: 11 additions & 11 deletions src/corePlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export let variantPlugins = {
},

darkVariants: ({ config, addVariant }) => {
let [mode, className = '.dark'] = [].concat(config('darkMode', 'media'))
let [mode, selector = '.dark'] = [].concat(config('darkMode', 'media'))

if (mode === false) {
mode = 'media'
Expand All @@ -229,12 +229,12 @@ export let variantPlugins = {

if (mode === 'variant') {
let formats
if (Array.isArray(className)) {
formats = className
} else if (typeof className === 'function') {
formats = className
} else if (typeof className === 'string') {
formats = [className]
if (Array.isArray(selector)) {
formats = selector
} else if (typeof selector === 'function') {
formats = selector
} else if (typeof selector === 'string') {
formats = [selector]
}

// TODO: We could also add these warnings if the user passes a function that returns string | string[]
Expand All @@ -257,19 +257,19 @@ export let variantPlugins = {
}
}

className = formats
selector = formats
}

if (mode === 'selector') {
// New preferred behavior
addVariant('dark', `&:where(${className}, ${className} *)`)
addVariant('dark', `&:where(${selector}, ${selector} *)`)
} else if (mode === 'media') {
addVariant('dark', '@media (prefers-color-scheme: dark)')
} else if (mode === 'variant') {
addVariant('dark', className)
addVariant('dark', selector)
} else if (mode === 'class') {
// Old behavior
addVariant('dark', `:is(${className} &)`)
addVariant('dark', `:is(${selector} &)`)
}
},

Expand Down