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