Skip to content

feat(results): export results as image - #573

Draft
Gudsfile wants to merge 1 commit into
mainfrom
feat/189-export-results-image
Draft

feat(results): export results as image#573
Gudsfile wants to merge 1 commit into
mainfrom
feat/189-export-results-image

Conversation

@Gudsfile

Copy link
Copy Markdown
Owner

1️⃣ First

  • I have read the CONTRIBUTION.md.
  • OPTIONAL I agree to be added as a contributor in the README.md by the all-contributors bot.

🔇 Problem

Closes #189.

There was no way to save or share the results screen. Users who want to show off or keep a snapshot of their listening stats had to resort to manual screenshots, which are inconsistent across devices and lose quality.

🎹 Proposal

Add an "Export as image" action to the results screen. The button captures the currently displayed results view and downloads it as a shareable PNG card.

Capture is handled by html-to-image (toPng), the maintained, generic option agreed on in the issue discussion. It correctly renders fonts and the D3/Observable Plot SVG charts, and it leaves room to grow toward richer custom share images later.

Details:

  • The exported card adopts the current light or dark page background, so it stays legible in either theme.
  • Rendering happens at 2× pixel ratio for a crisp result.
  • The download uses a sensible timestamped filename (tracksy-YYYY-MM-DD.png).
  • The button reflects progress (exporting) and fails gracefully with a visible error state if capture cannot complete.
  • The button follows the existing UI conventions (Tailwind, dark: variants, shared button styling).

Capture logic lives in a small, testable exportElementAsImage utility, kept separate from the ExportButton UI.

🎶 Comments

Scope is intentionally kept to a clean first version: a single export of the active results container. The button lives in the results view, so whichever tab is on screen (Simple, Lab, Chat, Query) is what gets exported.

🎤 Test

Automated:

  • moon run app:format, moon run app:lint, moon run app:typecheck, moon run app:test all pass.
  • New unit tests cover the exportElementAsImage utility (capture + download, filename format, error propagation) and the ExportButton component (render, click-to-capture, failure state, missing target). html-to-image is mocked via vi.spyOn.

Manual:

  1. moon run app:dev.
  2. Load data (or use the demo button) until the results screen appears.
  3. Click "📸 Export as image" — a PNG of the results downloads.
  4. Toggle the theme and export again — verify the background matches the active theme.

@Gudsfile Gudsfile added enhancement New feature or request [ app ] Concerns the front-end labels Jul 25, 2026
github-actions Bot pushed a commit that referenced this pull request Jul 25, 2026
@github-actions

github-actions Bot commented Jul 25, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://Gudsfile.github.io/tracksy/pr-preview/pr-573/

Built to branch gh-pages at 2026-07-26 20:15 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Add an 'Export as image' action to the results screen so users can save and
share a snapshot of their listening stats. The button captures the active
results view with html-to-image (toPng) and downloads a timestamped PNG,
picking up the current light/dark background for a legible card.
@Gudsfile
Gudsfile force-pushed the feat/189-export-results-image branch from a202461 to e4f6fff Compare July 26, 2026 20:14
github-actions Bot pushed a commit that referenced this pull request Jul 26, 2026
@Gudsfile Gudsfile added the ➡️ to maturate To be discussed or developed before it's ready label Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[ app ] Concerns the front-end enhancement New feature or request ➡️ to maturate To be discussed or developed before it's ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Export results as image

1 participant