theme: do not throw error if deprecated color is found

This commit is contained in:
Abdullah Atta
2023-09-05 14:52:01 +05:00
committed by Abdullah Atta
parent d1c724563f
commit 1f5a5afb10
2 changed files with 7 additions and 1 deletions

View File

@@ -319,3 +319,5 @@ export const Variants: readonly (keyof Variants)[] = [
"error",
"success"
];
export const DEPRECATED_COLORS = ["shade", "textSelection"];

View File

@@ -21,6 +21,7 @@ import {
ALPHA_COLORS,
COLORS,
Colors,
DEPRECATED_COLORS,
ThemeDefinition,
Variants
} from "./types";
@@ -72,7 +73,10 @@ export function validateTheme(json: Partial<ThemeDefinition>): {
for (const key in flattenedTheme) {
if (!key.startsWith("scopes")) continue;
const keyPart = key.split(".").pop() as keyof Colors | undefined;
if (!keyPart || !COLORS.includes(keyPart))
if (
!keyPart ||
(!COLORS.includes(keyPart) && !DEPRECATED_COLORS.includes(keyPart))
)
return {
error: `Invalid theme. Found unknown key: ${key}.`
};