code refactor

This commit is contained in:
MaysWind
2025-08-30 00:38:45 +08:00
parent 32cf41a7a0
commit 4d0e376568
16 changed files with 126 additions and 120 deletions
+35 -1
View File
@@ -1,4 +1,15 @@
import type { ColorValue, ColorInfo } from '@/core/color.ts';
import type {
ColorValue,
ColorStyleValue,
ColorInfo
} from '@/core/color.ts';
import {
DEFAULT_ICON_COLOR,
DEFAULT_ACCOUNT_COLOR,
DEFAULT_CATEGORY_COLOR,
DEFAULT_COLOR_STYLE_VARIABLE
} from '@/consts/color.ts';
export function getColorsInRows(allColorValues: ColorValue[], itemPerRow: number): ColorInfo[][] {
const ret: ColorInfo[][] = [];
@@ -16,3 +27,26 @@ export function getColorsInRows(allColorValues: ColorValue[], itemPerRow: number
return ret;
}
export function getDisplayColor(color?: ColorValue): ColorStyleValue {
if (color && color !== DEFAULT_ICON_COLOR) {
return `#${color}`;
} else {
return DEFAULT_COLOR_STYLE_VARIABLE;
}
}
export function getCategoryDisplayColor(color?: ColorValue): ColorStyleValue {
if (color && color !== DEFAULT_CATEGORY_COLOR) {
return `#${color}`;
} else {
return DEFAULT_COLOR_STYLE_VARIABLE;
}
}
export function getAccountDisplayColor(color?: ColorValue): ColorStyleValue {
if (color && color !== DEFAULT_ACCOUNT_COLOR) {
return `#${color}`;
} else {
return DEFAULT_COLOR_STYLE_VARIABLE;
}
}