From 13ec18239082b1695dde6057fca8bf31c22d1551 Mon Sep 17 00:00:00 2001 From: mkljczk Date: Fri, 6 Dec 2024 10:27:52 +0100 Subject: [PATCH] pl-fe: rename legacy colors to basic colors Signed-off-by: mkljczk --- packages/pl-fe/src/normalizers/pl-fe/pl-fe-config.ts | 2 +- packages/pl-fe/src/utils/tailwind.test.ts | 8 ++++---- packages/pl-fe/src/utils/tailwind.ts | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/pl-fe/src/normalizers/pl-fe/pl-fe-config.ts b/packages/pl-fe/src/normalizers/pl-fe/pl-fe-config.ts index f9d7a1979..0cec38d38 100644 --- a/packages/pl-fe/src/normalizers/pl-fe/pl-fe-config.ts +++ b/packages/pl-fe/src/normalizers/pl-fe/pl-fe-config.ts @@ -71,7 +71,7 @@ const plFeConfigSchema = v.pipe(coerceObject({ appleAppId: v.fallback(v.nullable(v.string()), null), logo: v.fallback(v.string(), ''), logoDarkMode: v.fallback(v.nullable(v.string()), null), - brandColor: v.fallback(v.string(), ''), + brandColor: v.fallback(v.string(), '#d80482'), accentColor: v.fallback(v.string(), ''), colors: v.any(), copyright: v.fallback(v.string(), `♥${new Date().getFullYear()}. Copying is an act of love. Please copy and share.`), diff --git a/packages/pl-fe/src/utils/tailwind.test.ts b/packages/pl-fe/src/utils/tailwind.test.ts index 08939be8f..182ff54dc 100644 --- a/packages/pl-fe/src/utils/tailwind.test.ts +++ b/packages/pl-fe/src/utils/tailwind.test.ts @@ -1,6 +1,6 @@ import { Map as ImmutableMap } from 'immutable'; -import { toTailwind, fromLegacyColors, expandPalette } from './tailwind'; +import { toTailwind, fromBasicColors, expandPalette } from './tailwind'; describe('toTailwind()', () => { it('handles empty pl-fe config', () => { @@ -68,7 +68,7 @@ describe('toTailwind()', () => { }); }); -describe('fromLegacyColors()', () => { +describe('fromBasicColors()', () => { it('converts only brandColor', () => { const plFeConfig = ImmutableMap({ brandColor: '#0482d8' }); @@ -124,7 +124,7 @@ describe('fromLegacyColors()', () => { }, }; - const result = fromLegacyColors(plFeConfig); + const result = fromBasicColors(plFeConfig); expect(result).toEqual(expected); }); @@ -185,7 +185,7 @@ describe('fromLegacyColors()', () => { }, }; - const result = fromLegacyColors(plFeConfig); + const result = fromBasicColors(plFeConfig); expect(result).toEqual(expected); }); }); diff --git a/packages/pl-fe/src/utils/tailwind.ts b/packages/pl-fe/src/utils/tailwind.ts index 6194705c6..72387334a 100644 --- a/packages/pl-fe/src/utils/tailwind.ts +++ b/packages/pl-fe/src/utils/tailwind.ts @@ -29,7 +29,7 @@ const maybeGenerateAccentColor = (brandColor: string): string | null => isHex(brandColor) ? generateAccent(brandColor) : null; /** Build a color object from legacy colors */ -const fromLegacyColors = ({ brandColor, accentColor }: { +const fromBasicColors = ({ brandColor, accentColor }: { brandColor: string; accentColor: string | null; }): TailwindColorPalette => { @@ -50,16 +50,16 @@ const toTailwind = (config: { colors: Record>; }): Record | string> => { const colors: PlFeColors = config.colors; - const legacyColors = fromLegacyColors(config); + const basicColors = fromBasicColors(config); return { ...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 { expandPalette, - fromLegacyColors, + fromBasicColors, toTailwind, };