From 1135f3b7a8d2a44a479edd863e34ee9aefe69436 Mon Sep 17 00:00:00 2001 From: Felix Zett Date: Sun, 14 Sep 2025 19:59:52 +0200 Subject: [PATCH] feat: dynamic tag colors in ItemRow component --- frontend/src/components/ItemRow.tsx | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/ItemRow.tsx b/frontend/src/components/ItemRow.tsx index cf992df..33f6516 100644 --- a/frontend/src/components/ItemRow.tsx +++ b/frontend/src/components/ItemRow.tsx @@ -10,6 +10,19 @@ interface ItemRowProps { onDeleteItem: (itemId: string) => void; } +const TAG_COLORS = [ + "bg-blue-200 text-blue-900", + "bg-green-200 text-green-900", + "bg-yellow-200 text-yellow-900", + "bg-pink-200 text-pink-900", + "bg-purple-200 text-purple-900", + "bg-orange-200 text-orange-900", + "bg-teal-200 text-teal-900", + "bg-red-200 text-red-900", + "bg-indigo-200 text-indigo-900", + "bg-lime-200 text-lime-900", +]; + export default function ItemRow({ item, allTags, @@ -93,7 +106,7 @@ export default function ItemRow({ {item.tags.map((tag) => ( #{tag.name} {hover && ( @@ -172,3 +185,12 @@ export default function ItemRow({ ); } + +function getTagColor(tagId: string) { + // Simple hash: sum char codes + let hash = 0; + for (let i = 0; i < tagId.length; i++) { + hash = (hash + tagId.charCodeAt(i)) % TAG_COLORS.length; + } + return TAG_COLORS[hash]; +}