Skip to content

Commit e2a4e9d

Browse files
Refactor legacyColors logic to silence warnings in the terminal
1 parent 7333f3f commit e2a4e9d

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

index.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,20 @@ const lerpColors = (colorsObj, options = {}) => {
3636
if (isOptionInvalid('mode', v => validColorModes.includes(v)))
3737
throw new Error(`tailwind-lerp-colors option \`mode\` must be one of the following values: ${validColorModes.map(modeName => '`modeName`').join(', ')}.`);
3838

39-
const [baseColors, legacyColors] = Object.entries(builtInColors).reduce(
40-
([base, legacy], [name, values]) => {
41-
if (legacyNames.includes(name)) legacy[name] = values;
42-
else base[name] = values;
43-
return [base, legacy];
44-
}, [{}, {}]
45-
);
4639
const { includeBase, includeLegacy, lerpEnds, interval, mode } = {
4740
...defaultOptions,
4841
...options,
4942
};
43+
const baseColors = {};
44+
if (includeBase) {
45+
for (const key of Object.keys(builtInColors)) {
46+
if (!legacyNames.includes(key) || includeLegacy) {
47+
baseColors[key] = builtInColors[key];
48+
}
49+
}
50+
}
5051
const initialColors = Object.entries({
51-
...(includeBase ? baseColors : {}),
52-
...(includeLegacy ? legacyColors : {}),
52+
...baseColors,
5353
...colorsObj,
5454
});
5555

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tailwind-lerp-colors",
3-
"version": "1.1.4",
3+
"version": "1.1.5",
44
"description": "Interpolate between defined colors in Tailwind config for additional color stops",
55
"main": "index.js",
66
"publishConfig": {

0 commit comments

Comments
 (0)