Skip to content

Commit

Permalink
fix(module): safelist all colors for toast.add
Browse files Browse the repository at this point in the history
Resolves #375, resolves #440
  • Loading branch information
benjamincanac committed Jul 27, 2023
1 parent 0300be8 commit 2cd6208
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 generateSafelist = (colors: string[]) => {
export const generateSafelist = (colors: string[], globalColors) => {
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
Expand All @@ -213,6 +213,8 @@ export const generateSafelist = (colors: string[]) => {
return [
...baseSafelist,
...formsSafelist,
// Ensure all global colors are safelisted for the Notification (toast.add)
...safelistByComponent['notification'](colorsAsRegex(globalColors)),
// Gray safelist for Avatar & Notification
'bg-gray-500',
'dark:bg-gray-400',
Expand Down
2 changes: 1 addition & 1 deletion src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default defineNuxtModule<ModuleOptions>({
}

tailwindConfig.safelist = tailwindConfig.safelist || []
tailwindConfig.safelist.push(...generateSafelist(options.safelistColors))
tailwindConfig.safelist.push(...generateSafelist(options.safelistColors, colors))

tailwindConfig.plugins = tailwindConfig.plugins || []
tailwindConfig.plugins.push(iconsPlugin({ collections: getIconCollections(options.icons as any[]) }))
Expand Down

1 comment on commit 2cd6208

@vercel
Copy link

@vercel vercel bot commented on 2cd6208 Jul 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ui – ./

ui-nuxtlabs.vercel.app
ui.nuxtlabs.com
ui-git-dev-nuxtlabs.vercel.app

Please sign in to comment.