Skip to content

Add PlayBadges recreation examples with snapshot tests and flexGrow/flexShrink for containers#5

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/test-playbadges-with-htvg
Draft

Add PlayBadges recreation examples with snapshot tests and flexGrow/flexShrink for containers#5
Copilot wants to merge 2 commits into
mainfrom
copilot/test-playbadges-with-htvg

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 14, 2026

Validates that htvg can recreate PlayBadges (originally satori-based) using JSON element trees. Adds snapshot tests and documents missing features.

PlayBadges Recreation with HTVG

flexGrow/flexShrink on Box and Flex containers

Previously only TextStyle and ImageStyle had flex child properties. The badge layout requires flexGrow: 1 on a Flex container (content area fills space beside the icon), so this was a blocking gap.

  • element.rs: Added flex_grow/flex_shrink to BoxStyle and FlexStyle
  • layout.rs: Wire values into Taffy style conversion
  • types.ts: Mirror in TypeScript definitions

PlayBadges examples

Three badge variants in examples/:

  • playbadge-dark.json — dark theme, 4.4★ rating
  • playbadge-light.json — light theme
  • playbadge-dark-norating.json — N/A rating variant

Snapshot tests

8 tests via insta in crates/htvg-core/tests/playbadges_snapshot.rs:

  • Badge compilation + SVG snapshots (dark, light, no-rating)
  • Structural checks (rounded corners, image clip-path, border stroke)
  • flexGrow layout correctness
  • OG image layout pattern (based on pavi2410/website og-image.tsx)

Missing features for full parity

  1. boxShadow — PlayBadges uses shadow-lg on the app icon
  2. Inline/rich text — mixed styles within a single line (e.g. "4.4" white + "★" yellow + "(1.2K)" gray)
  3. Icon fonts — Material Symbols Outlined for the download icon glyph
  4. Font loading from URLs at compile time — accurate text measurement requires fetching remote font data during layout
  5. Text overflow/ellipsis — long app names can overflow badge bounds

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…Shrink support for Box/Flex containers

Co-authored-by: pavi2410 <28837746+pavi2410@users.noreply.github.com>
Copilot AI changed the title [WIP] Add tests to recreate PlayBadges using htvg Add PlayBadges recreation examples with snapshot tests and flexGrow/flexShrink for containers Mar 14, 2026
Copilot AI requested a review from pavi2410 March 14, 2026 19:55
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