Skip to content

Commit

Permalink
Refactor legacyColors logic to silence warnings in the terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonmcconnell committed Jul 21, 2022
1 parent 7333f3f commit e2a4e9d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ const lerpColors = (colorsObj, options = {}) => {
if (isOptionInvalid('mode', v => validColorModes.includes(v)))
throw new Error(`tailwind-lerp-colors option \`mode\` must be one of the following values: ${validColorModes.map(modeName => '`modeName`').join(', ')}.`);

const [baseColors, legacyColors] = Object.entries(builtInColors).reduce(
([base, legacy], [name, values]) => {
if (legacyNames.includes(name)) legacy[name] = values;
else base[name] = values;
return [base, legacy];
}, [{}, {}]
);
const { includeBase, includeLegacy, lerpEnds, interval, mode } = {
...defaultOptions,
...options,
};
const baseColors = {};
if (includeBase) {
for (const key of Object.keys(builtInColors)) {
if (!legacyNames.includes(key) || includeLegacy) {
baseColors[key] = builtInColors[key];
}
}
}
const initialColors = Object.entries({
...(includeBase ? baseColors : {}),
...(includeLegacy ? legacyColors : {}),
...baseColors,
...colorsObj,
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tailwind-lerp-colors",
"version": "1.1.4",
"version": "1.1.5",
"description": "Interpolate between defined colors in Tailwind config for additional color stops",
"main": "index.js",
"publishConfig": {
Expand Down

0 comments on commit e2a4e9d

Please # to comment.