mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-18 05:58:07 +01:00
fix(module): handle tailwindMerge config from app.config
This commit is contained in:
@@ -1,19 +1,21 @@
|
||||
import { defu, createDefu } from 'defu'
|
||||
import { extendTailwindMerge } from 'tailwind-merge'
|
||||
import type { Strategy } from '../types'
|
||||
// @ts-ignore
|
||||
import appConfig from '#build/app.config'
|
||||
|
||||
const customTwMerge = extendTailwindMerge<string, string>({
|
||||
export const twMerge = extendTailwindMerge<string, string>(defu({
|
||||
extend: {
|
||||
classGroups: {
|
||||
icons: [(classPart: string) => /^i-/.test(classPart)]
|
||||
}
|
||||
}
|
||||
})
|
||||
}, appConfig.ui?.tailwindMerge))
|
||||
|
||||
const defuTwMerge = createDefu((obj, key, value, namespace) => {
|
||||
if (namespace !== 'default' && !namespace.startsWith('default.') && typeof obj[key] === 'string' && typeof value === 'string' && obj[key] && value) {
|
||||
// @ts-ignore
|
||||
obj[key] = customTwMerge(obj[key], value)
|
||||
obj[key] = twMerge(obj[key], value)
|
||||
return true
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user