Skip to content

Commit

Permalink
fix: suppress Tailwind duplication warning (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcaidev committed Sep 6, 2024
1 parent 3af6234 commit 0d28936
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,16 @@ function resolvePalette(
options.aliases ?? {},
);

const normalizedTailwindPalette = normalizeTailwindPalette(tailwindPalette);

const checkInclusion = createInclusionChecker(options);
const filteredRadixPalette = Object.fromEntries(
Object.entries(aliasedRadixPalette).filter(([colorName]) =>
checkInclusion(colorName),
),
);
const filteredTailwindPalette = Object.fromEntries(
Object.entries(tailwindPalette).filter(([colorName]) =>
Object.entries(normalizedTailwindPalette).filter(([colorName]) =>
checkInclusion(colorName),
),
);
Expand Down Expand Up @@ -140,6 +142,26 @@ function aliasRadixPalette(
return aliasedPalette;
}

/**
* Remove deprecated color names from the Tailwind palette.
*/
function normalizeTailwindPalette(tailwindPalette: Palette): Palette {
const deprecatedColorNames = [
"lightBlue",
"warmGray",
"trueGray",
"coolGray",
"blueGray",
];

return Object.keys(tailwindPalette)
.filter((colorName) => !deprecatedColorNames.includes(colorName))
.reduce<Palette>((palette, colorName) => {
palette[colorName] = tailwindPalette[colorName]!;
return palette;
}, {});
}

/**
* Create a function that checks whether a Radix color name should be included,
* i.e. be transformed and added to the new palette.
Expand Down

0 comments on commit 0d28936

Please sign in to comment.