chore: copy
This commit is contained in:
parent
3b8b2d9efa
commit
4e69255d0d
|
|
@ -88,29 +88,28 @@ export function applyColorMapping(
|
||||||
if (input.includes(' border '))
|
if (input.includes(' border '))
|
||||||
input = input.replace(' border ', ' border border-border ')
|
input = input.replace(' border ', ' border border-border ')
|
||||||
|
|
||||||
// Build color mappings.
|
|
||||||
const classNames = input.split(' ')
|
const classNames = input.split(' ')
|
||||||
const lightMode: string[] = []
|
const lightMode = new Set<string>()
|
||||||
const darkMode: string[] = []
|
const darkMode = new Set<string>()
|
||||||
for (const className of classNames) {
|
for (const className of classNames) {
|
||||||
const [variant, value, modifier] = splitClassName(className)
|
const [variant, value, modifier] = splitClassName(className)
|
||||||
const prefix = PREFIXES.find(prefix => value?.startsWith(prefix))
|
const prefix = PREFIXES.find(prefix => value?.startsWith(prefix))
|
||||||
if (!prefix) {
|
if (!prefix) {
|
||||||
if (!lightMode.includes(className))
|
if (!lightMode.has(className))
|
||||||
lightMode.push(className)
|
lightMode.add(className)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
const needle = value?.replace(prefix, '')
|
const needle = value?.replace(prefix, '')
|
||||||
if (needle && needle in mapping.light) {
|
if (needle && needle in mapping.light) {
|
||||||
lightMode.push(
|
lightMode.add(
|
||||||
[variant, `${prefix}${mapping.light[needle]}`]
|
[variant, `${prefix}${mapping.light[needle]}`]
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.join(':') + (modifier ? `/${modifier}` : ''),
|
.join(':') + (modifier ? `/${modifier}` : ''),
|
||||||
)
|
)
|
||||||
|
|
||||||
darkMode.push(
|
darkMode.add(
|
||||||
['dark', variant, `${prefix}${mapping.dark[needle]}`]
|
['dark', variant, `${prefix}${mapping.dark[needle]}`]
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.join(':') + (modifier ? `/${modifier}` : ''),
|
.join(':') + (modifier ? `/${modifier}` : ''),
|
||||||
|
|
@ -118,9 +117,9 @@ export function applyColorMapping(
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lightMode.includes(className))
|
if (!lightMode.has(className))
|
||||||
lightMode.push(className)
|
lightMode.add(className)
|
||||||
}
|
}
|
||||||
const combined = `${lightMode.join(' ').replace(/\'/g, '')} ${darkMode.join(' ').trim()}`.trim()
|
|
||||||
return `${combined}`
|
return [...Array.from(lightMode), ...Array.from(darkMode)].join(' ').trim()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user