mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-30 11:47:55 +01:00
fix(module): safelist all colors for toast.add
Resolves #375, resolves #440
This commit is contained in:
@@ -204,7 +204,7 @@ const colorsAsRegex = (colors: string[]): string => colors.join('|')
|
|||||||
|
|
||||||
export const excludeColors = (colors: object) => Object.keys(omit(colors, colorsToExclude)).map(color => kebabCase(color)) as string[]
|
export const excludeColors = (colors: object) => Object.keys(omit(colors, colorsToExclude)).map(color => kebabCase(color)) as string[]
|
||||||
|
|
||||||
export const generateSafelist = (colors: string[]) => {
|
export const generateSafelist = (colors: string[], globalColors) => {
|
||||||
const baseSafelist = Object.keys(safelistByComponent).flatMap(component => safelistByComponent[component](colorsAsRegex(colors)))
|
const baseSafelist = Object.keys(safelistByComponent).flatMap(component => safelistByComponent[component](colorsAsRegex(colors)))
|
||||||
|
|
||||||
// Ensure `red` color is safelisted for form elements so that `error` prop of `UFormGroup` always works
|
// Ensure `red` color is safelisted for form elements so that `error` prop of `UFormGroup` always works
|
||||||
@@ -213,6 +213,8 @@ export const generateSafelist = (colors: string[]) => {
|
|||||||
return [
|
return [
|
||||||
...baseSafelist,
|
...baseSafelist,
|
||||||
...formsSafelist,
|
...formsSafelist,
|
||||||
|
// Ensure all global colors are safelisted for the Notification (toast.add)
|
||||||
|
...safelistByComponent['notification'](colorsAsRegex(globalColors)),
|
||||||
// Gray safelist for Avatar & Notification
|
// Gray safelist for Avatar & Notification
|
||||||
'bg-gray-500',
|
'bg-gray-500',
|
||||||
'dark:bg-gray-400',
|
'dark:bg-gray-400',
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ export default defineNuxtModule<ModuleOptions>({
|
|||||||
}
|
}
|
||||||
|
|
||||||
tailwindConfig.safelist = tailwindConfig.safelist || []
|
tailwindConfig.safelist = tailwindConfig.safelist || []
|
||||||
tailwindConfig.safelist.push(...generateSafelist(options.safelistColors))
|
tailwindConfig.safelist.push(...generateSafelist(options.safelistColors, colors))
|
||||||
|
|
||||||
tailwindConfig.plugins = tailwindConfig.plugins || []
|
tailwindConfig.plugins = tailwindConfig.plugins || []
|
||||||
tailwindConfig.plugins.push(iconsPlugin({ collections: getIconCollections(options.icons as any[]) }))
|
tailwindConfig.plugins.push(iconsPlugin({ collections: getIconCollections(options.icons as any[]) }))
|
||||||
|
|||||||
Reference in New Issue
Block a user