Skip to content

refactor: resolve dock icons via a runtime Iconify SVG fetch - #137

Merged
antfu merged 3 commits into
mainfrom
chore/shared-dock-icon-map
Jul 27, 2026
Merged

refactor: resolve dock icons via a runtime Iconify SVG fetch#137
antfu merged 3 commits into
mainfrom
chore/shared-dock-icon-map

Conversation

@antfubot

@antfubot antfubot commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

The vite and next hub playground icons.ts each hand-maintained an identical copy of a dock-icon -> UnoCSS class map, needing a manual edit for every new icon. Replace it with a framework-neutral port of @antfu/design's DisplayIconifyRemoteIcon: any Iconify collection:icon id now resolves to its live, sanitized SVG fetched from api.iconify.design, with no @iconify-json/* collection to install and no table to keep in sync.

  • design/dock-icon.ts (new): dockIconSvg() parses the dock's icon id and calls @antfu/design/utils/iconify's own getIconifySvg fetcher/cache/sanitizer directly — reusing @antfu/design's implementation rather than reimplementing it. Only the id-parsing/light-dark selection is devframe-specific, mirroring the upstream component's own prop parsing.
  • design/design.ts: dropped the static ICON_CLASS map + iconClass().
  • examples/minimal-vite-devframe-hub: icons.ts re-exports dockIconSvg; main.ts renders the fallback initial synchronously, then patches in the resolved SVG once the fetch settles (small session cache to avoid re-fetching on re-render).
  • examples/minimal-next-devframe-hub: icons.ts re-exports dockIconSvg; page.tsx's DockIcon uses a small useDockIconSvg effect hook to the same effect.
  • Both examples' package.json gain dompurify (already an @antfu/design peer dep, needed transitively by utils/iconify), via the existing frontend catalog entry.

Created with the help of an agent.

The vite and next hub playgrounds each hand-maintained an identical
copy of the dock-icon -> UnoCSS class map. Move it into the shared
design/design.ts class-helper module (already the one source of truth
for devframe -> @antfu/design class chains) and have both examples'
icons.ts re-export it, matching the existing local design.ts re-export
pattern used by every other plugin/example.
@netlify

netlify Bot commented Jul 27, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit c61f9bc
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a670b0f9d8dc40008c2bf62
😎 Deploy Preview https://deploy-preview-137--devfra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Port @antfu/design's DisplayIconifyRemoteIcon (utils/iconify.ts's
getIconifySvg) instead of a hand-maintained ph:icon -> UnoCSS-class
table: design/dock-icon.ts resolves a dock icon id to its sanitized
SVG, fetched live from api.iconify.design, so any Iconify id renders
with no @iconify-json/* collection to install and no table to keep in
sync. The vite hub patches the resolved SVG into the dock button once
it settles; the Next hub does the same via a small effect hook.
@antfubot antfubot changed the title refactor: centralize dock-icon class map in shared design helpers refactor: resolve dock icons via a runtime Iconify SVG fetch Jul 27, 2026
Next/Turbopack has no loader for the bare .ts source @antfu/design
ships (utils/iconify.ts, now imported by design/dock-icon.ts) and
fails the production build with "Unknown module type". Add it to
transpilePackages so Next runs the package through its own transform,
matching how Vite already handles it.
@antfu
antfu merged commit f39cae8 into main Jul 27, 2026
12 checks passed
@antfu
antfu deleted the chore/shared-dock-icon-map branch July 27, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants