Skip to content

Commit

Permalink
fix(module): ensure red color is safelisted for form elements
Browse files Browse the repository at this point in the history
Resolves #423, resolves #373
  • Loading branch information
benjamincanac committed Jul 19, 2023
1 parent 82e152b commit 208acca
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,14 @@ 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[]) => {
const safelist = 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
const formsSafelist = ['input', 'radio', 'checkbox', 'toggle', 'range'].flatMap(component => safelistByComponent[component](colorsAsRegex(['red'])))

return [
...safelist,
...baseSafelist,
...formsSafelist,
// Gray safelist for Avatar & Notification
'bg-gray-500',
'dark:bg-gray-400',
Expand Down

0 comments on commit 208acca

Please sign in to comment.