Shed standalone page chrome when embedded in an iframe#47
Merged
Conversation
Each widget now adds an 'embedded' class to the document element when it detects it is running framed (window.self !== window.top), with ?embed=0 as an escape hatch to force the framed look. An .embedded block in each styles.css then makes the body background transparent, drops the outer container's max-width/padding, and removes the card's border, radius, and shadow — so the card fills the frame instead of sitting as a shadowed, centred panel on a redundant inner background. The card keeps its own opaque, theme-correct background, so text contrast holds regardless of the host page's background (the widget's light/dark still follows the viewer's OS, not the host). image-comparison-table also zeroes its .page padding/min-height so the fit-scale wrapper measures against the full frame, and keeps its rose top-accent strip as a small brand cue. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
When a widget is embedded via iframe, the iframe is the container — so the standalone presentation chrome (outer page background, centered max-width, floating-card shadow/border/radius) becomes a redundant double-frame: the host surface, then a band of the widget's own background, then a shadowed rounded card on top.
This makes each widget detect the framed case and shed that chrome so the card fills the frame.
How
Each
main.tsxadds anembeddedclass to<html>when framed:(
window.self !== window.topis safe cross-origin;?embed=0forces the framed look back if a host wants it.)An
.embeddedblock in eachstyles.cssthen:max-widthand padding (fills the frame),Why it stays readable
The card keeps its own opaque, theme-correct background, so contrast holds whatever the host page's background is — important because each widget's light/dark follows the viewer's OS, not the host page. (True host-blending transparency would need the host to drive the theme; deliberately out of scope.)
Per-widget notes
.pagepadding/min-height so thefit-scalewrapper measures against the full frame, and keeps its rose top-accent strip as a small brand cue.postMessagealready in pennsic/verb-tower pairs naturally: a chromeless card that reports its height is exactly what a host wants.Verification
Rendered standalone vs embedded (with a simulated host backdrop) in light and dark for all four — standalone keeps the framed card; embedded fills the frame flush with the card's opaque surface, transparency confirmed by the host showing through where the card doesn't cover.
scripts/validate-widgets.mjspasses (4/4).🤖 Generated with Claude Code