pl-fe: rename legacy colors to basic colors
Signed-off-by: mkljczk <git@mkljczk.pl>
This commit is contained in:
parent
329d4e89bd
commit
13ec182390
3 changed files with 9 additions and 9 deletions
|
@ -71,7 +71,7 @@ const plFeConfigSchema = v.pipe(coerceObject({
|
||||||
appleAppId: v.fallback(v.nullable(v.string()), null),
|
appleAppId: v.fallback(v.nullable(v.string()), null),
|
||||||
logo: v.fallback(v.string(), ''),
|
logo: v.fallback(v.string(), ''),
|
||||||
logoDarkMode: v.fallback(v.nullable(v.string()), null),
|
logoDarkMode: v.fallback(v.nullable(v.string()), null),
|
||||||
brandColor: v.fallback(v.string(), ''),
|
brandColor: v.fallback(v.string(), '#d80482'),
|
||||||
accentColor: v.fallback(v.string(), ''),
|
accentColor: v.fallback(v.string(), ''),
|
||||||
colors: v.any(),
|
colors: v.any(),
|
||||||
copyright: v.fallback(v.string(), `♥${new Date().getFullYear()}. Copying is an act of love. Please copy and share.`),
|
copyright: v.fallback(v.string(), `♥${new Date().getFullYear()}. Copying is an act of love. Please copy and share.`),
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Map as ImmutableMap } from 'immutable';
|
import { Map as ImmutableMap } from 'immutable';
|
||||||
|
|
||||||
import { toTailwind, fromLegacyColors, expandPalette } from './tailwind';
|
import { toTailwind, fromBasicColors, expandPalette } from './tailwind';
|
||||||
|
|
||||||
describe('toTailwind()', () => {
|
describe('toTailwind()', () => {
|
||||||
it('handles empty pl-fe config', () => {
|
it('handles empty pl-fe config', () => {
|
||||||
|
@ -68,7 +68,7 @@ describe('toTailwind()', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('fromLegacyColors()', () => {
|
describe('fromBasicColors()', () => {
|
||||||
it('converts only brandColor', () => {
|
it('converts only brandColor', () => {
|
||||||
const plFeConfig = ImmutableMap({ brandColor: '#0482d8' });
|
const plFeConfig = ImmutableMap({ brandColor: '#0482d8' });
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ describe('fromLegacyColors()', () => {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = fromLegacyColors(plFeConfig);
|
const result = fromBasicColors(plFeConfig);
|
||||||
expect(result).toEqual(expected);
|
expect(result).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ describe('fromLegacyColors()', () => {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = fromLegacyColors(plFeConfig);
|
const result = fromBasicColors(plFeConfig);
|
||||||
expect(result).toEqual(expected);
|
expect(result).toEqual(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,7 +29,7 @@ const maybeGenerateAccentColor = (brandColor: string): string | null =>
|
||||||
isHex(brandColor) ? generateAccent(brandColor) : null;
|
isHex(brandColor) ? generateAccent(brandColor) : null;
|
||||||
|
|
||||||
/** Build a color object from legacy colors */
|
/** Build a color object from legacy colors */
|
||||||
const fromLegacyColors = ({ brandColor, accentColor }: {
|
const fromBasicColors = ({ brandColor, accentColor }: {
|
||||||
brandColor: string;
|
brandColor: string;
|
||||||
accentColor: string | null;
|
accentColor: string | null;
|
||||||
}): TailwindColorPalette => {
|
}): TailwindColorPalette => {
|
||||||
|
@ -50,16 +50,16 @@ const toTailwind = (config: {
|
||||||
colors: Record<string, Record<string, string>>;
|
colors: Record<string, Record<string, string>>;
|
||||||
}): Record<string, Record<string, string> | string> => {
|
}): Record<string, Record<string, string> | string> => {
|
||||||
const colors: PlFeColors = config.colors;
|
const colors: PlFeColors = config.colors;
|
||||||
const legacyColors = fromLegacyColors(config);
|
const basicColors = fromBasicColors(config);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...colors,
|
...colors,
|
||||||
...Object.fromEntries(Object.entries(legacyColors).map(([key, value]) => [key, typeof value === 'string' ? colors[key] || value : { ...value, ...colors[key] }])),
|
...Object.fromEntries(Object.entries(basicColors).map(([key, value]) => [key, typeof value === 'string' ? colors[key] || value : { ...value, ...colors[key] }])),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
expandPalette,
|
expandPalette,
|
||||||
fromLegacyColors,
|
fromBasicColors,
|
||||||
toTailwind,
|
toTailwind,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue