mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-18 08:44:25 +08:00
code refactor
This commit is contained in:
+35
-1
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user