Skip to content

feat(live-loan): render compact bundle card as transparent PNG - #7204

Open
roger-in-kiva wants to merge 1 commit into
mainfrom
MP-3005_compact_card_png
Open

feat(live-loan): render compact bundle card as transparent PNG#7204
roger-in-kiva wants to merge 1 commit into
mainfrom
MP-3005_compact_card_png

Conversation

@roger-in-kiva

Copy link
Copy Markdown
Collaborator

What

The compact-bundle live-loan card now renders as a transparent PNG instead of a JPEG baked onto a white margin.

Why

The card's drop shadow was baked onto a white background, so it only read on white email templates. Dark-mode templates need the margin transparent so the card + shadow composite onto the email's own background.

How

  • drawCompact: keep the canvas alpha channel, clearRect the canvas to transparent (instead of a white fillRect), and export toBuffer('image/png'). The white card body and drop shadow are unchanged; only the surrounding margin is now transparent.
  • Content type is resolved per style via a new contentTypeForStyle(style) helper, used by the router for both fresh draws and cache hits (the cache stores only the buffer, so the header is derived from the style). Only compact-bundle is PNG; all other styles stay JPEG.
  • Sizing: verified against Figma node 19534-4929 — every dimension already matches; no changes needed. Card height stays fixed at the 4-line worst case (the Figma frame is just its 3-line sample).

Testing

  • Compact render asserts PNG signature bytes + a fully transparent margin corner.
  • contentTypeForStyle mapping unit test; router content-type assertions flipped to image/png for the three compact routes, JPEG retained for the others.
  • Full unit suite green (one pre-existing, unrelated flake); lint clean.

Known follow-up (not in this PR)

On a dark background the existing rgba(0,0,0,0.08) black shadow is very faint (a black shadow has little contrast against dark). This PR delivers the transparency the dark template needs; tuning the shadow treatment for dark (stronger shadow / light glow / per-template) is a separate design decision still open.

The compact-bundle card was a JPEG baked onto a white margin, so its drop
shadow only worked on a white email background. Dark-mode templates need a
transparent margin instead.

Render the compact card with an alpha channel: clear the canvas to transparent
(no white fill) and export PNG, so the margin is see-through and the card +
shadow composite onto whatever background the email uses. Content type is
resolved per style via contentTypeForStyle so the response header is correct on
both fresh draws and cache hits (the cache stores only the buffer). Other card
styles are unchanged and still JPEG.

Card sizing was verified against the design and already matches; no dimension
changes were needed.
@roger-in-kiva roger-in-kiva added the b2c Sends B2C team a message in Slack on PR creation label Aug 28, 2026
@roger-in-kiva
roger-in-kiva requested review from a team and dyersituations August 28, 2026 18:51
@cristhianDt

Copy link
Copy Markdown
Contributor

(doubt) this feat is for the dark mode in some devices?

@roger-in-kiva

Copy link
Copy Markdown
Collaborator Author

(doubt) this feat is for the dark mode in some devices?

that's correct!

@cristhianDt

Copy link
Copy Markdown
Contributor

@roger-in-kiva nice! could you please add some screenshots for references/evidences ?, then I will approve it 🎉

@roger-in-kiva

Copy link
Copy Markdown
Collaborator Author

@roger-in-kiva nice! could you please add some screenshots for references/evidences ?, then I will approve it 🎉

2

@cristhianDt cristhianDt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice feature ☺️ !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

b2c Sends B2C team a message in Slack on PR creation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants