Inline category icons as SVG markup with theme/hover-aware colors - #201
Merged
Conversation
6 tasks
sdunster
marked this pull request as ready for review
September 4, 2026 20:48
The 66 category icons were served as opaque <img src="/image/categories/*.svg">
files with colors baked into hex values in the file - fine for the kiosk's
current look, but impossible to theme (dark mode) or react to hover/active
state, since an <img>-loaded SVG can't be reached by CSS.
- Move the icons from web/public/image/categories/ to web/src/assets/categories/,
inlined into the DOM at build time via import.meta.glob(..., {eager: true})
(no runtime fetch, no extra request per icon) and a new CategoryIcon
component, used in place of the old categoryIconSrc()-built <img> tags.
- Each icon keeps its original navy/orange as a literal presentation
attribute, so the file still opens correctly in a design tool with no
stylesheet present, and layers a class on top that a real stylesheet rule
always outranks:
- icon-stroke / icon-fill ride ordinary currentColor inheritance - a
text-navy / group-hover:text-... class on the icon's wrapper drives
them, the same mechanism HomeIcons.tsx already uses.
- icon-accent / icon-accent-stroke read a new --icon-accent custom
property (falling back to the existing --color-accent token), so the
orange accent can be overridden independently of the navy - by theme,
hover, or active state - without fighting over the single currentColor
channel.
- Defined via Tailwind's @Utility mechanism, not a plain @layer base
class: eslint-plugin-better-tailwindcss's no-unknown-classes rule only
recognizes classes visible in Tailwind's own utility set, and these
are referenced as literal JSX classes by a follow-up PR applying the
same treatment to the homepage icons.
- Update the /demo/category preview page (added to main after this branch's
first commit) to render icons via CategoryIcon instead of <img>, and
correct its comment claiming the icon's stroke color doesn't adapt to
dark mode - it now does.
- Unlike <img>, inlined SVG is real DOM content: raw whitespace between
tags in the source files, and any in-icon <text> (e.g. Flood Operator
L1/2/3's badge digit), show up in textContent. Strip inter-tag
whitespace once in the loader, mark the icon aria-hidden +
data-icon="category", and scope ScanScreenCategories.test.tsx's label
assertions past it.
- Verified the color/hover/dark-mode mechanism, and icon sizing under the
existing max-h-12/max-w-12 wrapper classes, against the actual compiled
app CSS in a headless browser before wiring it into the kiosk screens.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A3vVVqpFCjgdVXQvRz1hh8
sdunster
force-pushed
the
claude/svg-icon-approaches-ylqw45
branch
from
September 4, 2026 21:04
20b231e to
ee8c6fc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The 66 category icons were served as opaque
'<img src="/image/categories/*.svg">'files with colors baked into hex values in the file - fine for the kiosk's current look, but impossible to theme (dark mode) or react to hover/active state, since an<img>-loaded SVG can't be reached by CSS.web/public/image/categories/toweb/src/assets/categories/, inlined into the DOM at build time viaimport.meta.glob(..., {eager: true})(no runtime fetch, no extra request per icon) and a newCategoryIconcomponent.icon-stroke/icon-fillride ordinarycurrentColorinheritance - atext-navy/group-hover:text-...class on the icon's wrapper drives them, the same mechanismHomeIcons.tsxalready uses.icon-accent/icon-accent-strokeread a new--icon-accentcustom property (falling back to the existing--color-accenttoken), so the orange accent can be overridden independently of the navy - by theme, hover, or active state - without fighting over the singlecurrentColorchannel.Knock-on fix
Unlike
<img>, inlined SVG is real DOM content: raw whitespace between tags in the source files, and any in-icon<text>(e.g. Flood Operator L1/2/3's badge digit), now show up intextContent. Fixed by stripping inter-tag whitespace once in the loader, marking the iconaria-hidden+data-icon="category", and scopingScanScreenCategories.test.tsx's label assertions past the icon.Follow-up
A matching PR applies the same treatment to the two homepage icons (
home/HomeIcons.tsx) for consistency.Test plan
npx tsc -b- cleannpm run lint- cleannpx prettier --checkon touched files - cleannpm run test:unit- 146/146 passing (after fixing theScanScreenCategories.test.tsxlabel assertion)npm run build- succeeds; confirmed the newicon-stroke/icon-fill/icon-accent/icon-accent-strokerules compile into the output CSS🤖 Generated with Claude Code
https://claude.ai/code/session_01A3vVVqpFCjgdVXQvRz1hh8
Generated by Claude Code