Skip to content

[FEATURE] Add shareable Achievements card #1155

Description

@Suprita736

Feature Summary

Add a Share Achievements option to the Achievements component so users can generate and share/download a visual card containing their earned badges.

Problem Statement

The Achievements section displays users' earned badges, but there is currently no way to share or save these accomplishments outside the application.

Dashboard.jsx already provides an established html2canvas-based sharing pattern for generating a visual AQI card. Reusing this approach would provide a consistent and low-risk way to make achievements shareable.

Proposed Solution

Add a Share Achievements button to src/components/Achievements.jsx.

The feature should:

  • Generate a visual share card containing the user's earned badges.
  • Add a hidden share-card template for rendering the achievement information.
  • Use the existing html2canvas dependency and sharing/download pattern from Dashboard.jsx.
  • Convert the generated card to an image using html2canvas(...).toBlob().
  • Allow users to download the generated image.
  • Use the browser Web Share API when available, following the existing Dashboard pattern.
  • Keep the existing achievement calculation, badge unlocking, and storage behavior unchanged.
  • Provide reasonable behavior when the user has no earned achievements.

Alternatives Considered

  • Plain text sharing: Simple, but does not provide a visually appealing representation of the user's achievements.
  • PDF export: Useful for documents, but unnecessarily heavy for a social/shareable achievement card.
  • Screenshot instructions: Requires manual user action and does not provide a consistent result.

Reusing the existing html2canvas image-generation approach provides the most consistent implementation with minimal additional complexity.

Additional Context

Dashboard.jsx already contains a complete html2canvas-based sharing implementation, including a hidden share-card template and image download/share flow.

Achievements.jsx can follow this established pattern while using the user's earned badges as the card content.

Relevant files:

  • src/components/Achievements.jsx — add the share button, hidden card, and sharing logic.
  • src/components/Dashboard.jsx — existing html2canvas sharing pattern to follow.
  • src/utils/achievementsStore.js — existing achievement/badge data source.

This is a shareability feature only.

No changes should be made to achievement calculation, badge unlocking, persistence, Dashboard behavior, or unrelated functionality.

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions