Draw something for an icon or colour name nothing maps to

An unknown name indexed the map, got undefined and drew nothing — the same
as no icon at all, so a typo was invisible. It resolves to a placeholder
glyph and the default tint now, and warns once per bad name: both lookups
sit in a render, so a bound widget would otherwise warn per value.

An empty name still draws nothing, which is what "no icon" means.
This commit is contained in:
2026-08-30 16:29:46 +02:00
parent 57a0faafbd
commit 59e942ca1c
3 changed files with 55 additions and 7 deletions
@@ -1,6 +1,6 @@
import { cn } from "@/lib/utils"
import { useBoundValue } from "./dataContext"
import { ICON_COLORS, ICONS } from "./icons"
import { resolveIcon, resolveIconColor } from "./icons"
import { config } from "./ui/core/config"
import type { WidgetProps } from "./widgets"
@@ -41,7 +41,7 @@ export function ForecastWidget({ widget }: WidgetProps) {
return (
<div className="flex min-h-0 items-stretch justify-between gap-2">
{items.map((item, index) => {
const Glyph = ICONS[item.icon ?? ""] ?? null
const Glyph = resolveIcon(item.icon ?? "")
return (
<div
// Two steps can carry the same label and reading; position is the
@@ -66,7 +66,7 @@ export function ForecastWidget({ widget }: WidgetProps) {
<Glyph
className={cn(
"dui-glyph-sm shrink-0",
ICON_COLORS[item.color ?? ""] ?? ICON_COLORS.default,
resolveIconColor(item.color ?? ""),
)}
/>
) : null}