Update theme.ts

This commit is contained in:
かっこかり 2026-05-20 22:35:04 +09:00 committed by GitHub
commit 98d362df23
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -29,7 +29,7 @@ export type Theme = {
export type CompiledTheme = Record<string, string>;
const MAX_THEME_REFERENCE_DEPTH = 4;
const MAX_THEME_REFERENCE_DEPTH = 8;
export const themeProps = Object.keys(lightTheme.props).filter(key => !key.startsWith('X'));
@ -76,15 +76,15 @@ function getThemeReferenceColor(theme: Theme, key: string, stack: string[], dept
}
function getColor(theme: Theme, val: string, stack: string[] = [], depth = 0): tinycolor.Instance {
if (depth >= MAX_THEME_REFERENCE_DEPTH) {
throw new Error('Theme reference limit exceeded');
}
if (val[0] === '@') { // ref (prop)
return getThemeReferenceColor(theme, val.substring(1), stack, depth);
} else if (val[0] === '$') { // ref (const)
return getThemeReferenceColor(theme, val, stack, depth);
} else if (val[0] === ':') { // func
if (depth >= MAX_THEME_REFERENCE_DEPTH) {
throw new Error('Theme reference limit exceeded');
}
const parts = val.split('<');
const funcTxt = parts.shift();
const argTxt = parts.shift();