Skip to content

Add SVG download to demo and embed images in SVG downloads - #650

Merged
LGLabGreg merged 3 commits into
mainfrom
claude/project-thread-grgbii
Oct 11, 2026
Merged

LGLabGreg merged 3 commits into
mainfrom
claude/project-thread-grgbii

Conversation

@LGLabGreg

@LGLabGreg LGLabGreg commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Requested by Greg · project thread

Before: the demo page only offered "Download PNG". In the library, a downloaded SVG linked to its image by URL, so the logo was missing when the file was opened offline or printed. The demo logo was also a 60px PNG, so it looked blurry when the SVG was scaled up.

After: "Download PNG" is a split button, and its dropdown offers PNG and SVG. SVG downloads embed linked images as data URLs, so they work offline. The demo uses a new logo.svg, so its logo stays sharp at any size.

How:

  • Library (download.ts): downloadSVG now fetches each <image> href on the cloned SVG and inlines it as a data URL. It keeps the original href when the fetch fails or returns an HTTP error, for example because of CORS. Requests send credentials when the image uses crossOrigin: 'use-credentials'. This includes unit tests and a patch changeset.
  • Docs: this adds @radix-ui/react-dropdown-menu, a shadcn-style ui/dropdown-menu.tsx, and public/images/logo.svg, built from the header logo. The demo now points at https://reactqrcode.com/images/logo.svg, so the Vercel preview shows a broken logo until this merges.

Tested in Chromium against a local docs build:

  • Same-origin SVG and PNG logos, relative URLs, and cross-origin with CORS are inlined.
  • A cross-origin URL without CORS, an unreachable URL and a 404 keep the original href.
  • Downloading with no image works.
  • The PNG download still works.
  • The downloaded SVG renders its logo when opened with the network blocked.

Turn the demo's Download PNG button into a split button with a
dropdown offering PNG and SVG.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UUJ8UiTaVBBcDZj7nK9WSi
@vercel

vercel Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
reactqrcode-com Ready Ready Preview Oct 11, 2026 12:00pm UTC

Request Review

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UUJ8UiTaVBBcDZj7nK9WSi
Downloaded SVGs linked to the image URL, so the image was missing when
the file was opened offline or printed. Fetch each linked image and
inline it as a data URL, keeping the original href if the fetch fails.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UUJ8UiTaVBBcDZj7nK9WSi
@LGLabGreg LGLabGreg changed the title Add SVG download option to demo page Add SVG download to demo and embed images in SVG downloads Oct 11, 2026
@LGLabGreg
LGLabGreg marked this pull request as ready for review October 11, 2026 12:05
@LGLabGreg
LGLabGreg merged commit 4bbd1bf into main Oct 11, 2026
3 checks passed
@LGLabGreg
LGLabGreg deleted the claude/project-thread-grgbii branch October 11, 2026 12:05

This branch was successfully deployed

1 active deployment
Preview — 7500df50 Deployed Oct 11, 2026 by vercel[bot]
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