Feature: configurable <body> background in Render.render_email (#19)#21
Draft
makerprism-bot wants to merge 1 commit into
Draft
Feature: configurable <body> background in Render.render_email (#19)#21makerprism-bot wants to merge 1 commit into
makerprism-bot wants to merge 1 commit into
Conversation
Add optional body_background parameter to Render.render_email to allow customizing the <body> element's background color. This enables the common transactional email pattern of tinted page backgrounds with lighter content cards inside. - Add ?body_background:Color.t parameter (defaults to solid white) - Generate proper background styles using Color.to_style - For gradients, add bgcolor attribute with fallback color for Outlook - Backward compatible: defaults to existing behavior Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sabine
requested changes
Apr 19, 2026
Contributor
sabine
left a comment
There was a problem hiding this comment.
Review: Request Changes
Thanks for the body_background feature! This is a useful addition. However, there's a critical bug with nested gradient handling that needs to be fixed.
Critical Issue: Nested Gradient Fallback
Current code:
| Color.Gradient {fallback = Gradient _; _} ->
(* Should be impossible through API, but handle gracefully *)
" bgcolor=\"#ffffff\""Problem: This pattern is possible when users nest gradients:
let nested = Color.gradient
~colors:["#667eea"; "#764ba2"]
~fallback:(Color.gradient (* <-- Nested gradient *)
~colors:["#a18cd1"; "#fbc2eb"]
~fallback:(Color.solid "#667eea"))The code returns #ffffff instead of extracting the solid fallback from the nested gradient.
Fix:
(* Extract solid fallback from potentially nested gradients *)
let rec extract_solid_fallback = function
| Color.Solid hex -> hex
| Color.Gradient {fallback; _} -> extract_solid_fallback fallback
in
let bgcolor_attr = match body_background with
| Color.Solid hex -> Printf.sprintf " bgcolor=\"%s\"" hex
| Color.Gradient _ ->
let fb_hex = extract_solid_fallback body_background in
Printf.sprintf " bgcolor=\"%s\"" fb_hexAdditional Requests
-
Add caniemail citation for body background support
- https://www.caniemail.com/features/css-background/ (body background support)
- https://www.caniemail.com/features/html-body/ (body element attributes)
-
Add test coverage for:
- Solid body background
- Gradient body background with fallback
- Nested gradient fallback extraction (critical)
- Verify bgcolor attribute is correctly extracted
-
Documentation: Update module doc to mention body_background parameter in examples
Summary
The feature is good but needs the nested gradient bug fixed before merging. Once that's addressed and tests are added, this will be ready to merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #19.
Automated implementation for issue #19 (#19).
Produced by automation run
f7dc92b1-ff3b-4036-8192-fd69d5f21cdausing Claude Code onmakerprism/typemail.Agent's summary (last lines of output):
Committed changes to branch
automation/issue-19-f7dc92b1.