优化色卡界面加载色卡颜色种类的处理过程。

This commit is contained in:
徐涛 2025-02-10 22:00:00 +08:00
parent ccedaa62a6
commit 7f6c217d7e

View File

@ -6,6 +6,7 @@ import { HSegmentedControl } from '../components/HSegmentedControl';
import { ScrollArea } from '../components/ScrollArea';
import { ColorDescription } from '../models';
import { ColorCard } from '../page-components/cards-detail/ColorCard';
import { mapToObject } from '../utls';
import styles from './CardsDetail.module.css';
type ColorModes = 'hex' | 'rgb' | 'hsl' | 'lab' | 'oklch';
@ -20,7 +21,11 @@ export function CardsDetail({ mainTag }: CardsDetailProps) {
return [];
}
try {
const embededCategories = colorFn.color_categories() as { label: string; value: string }[];
const embededCategories = colorFn.color_categories().map(mapToObject) as {
label: string;
value: string;
}[];
console.debug('[Fetch color categories]', embededCategories);
return embededCategories.filter((cate) => !isEqual(cate.value, 'unknown'));
} catch (e) {
console.error('[Fetch color categories]', e);