Skip to content

Report content height for iframe auto-sizing across all widgets#49

Merged
jbeshir merged 1 commit into
mainfrom
auto-height
Jun 22, 2026
Merged

Report content height for iframe auto-sizing across all widgets#49
jbeshir merged 1 commit into
mainfrom
auto-height

Conversation

@jbeshir

@jbeshir jbeshir commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Completes the embedding work: every widget now tells its host how tall it wants to be, so a host can auto-size the iframe instead of guessing a fixed height.

What changed

  • function-plotter and image-comparison-table now post { type: "resize", height } to window.parent via a ResizeObserver — the same thing pennsic-planner and japanese-verb-tower already did. These were the two that lacked it.
  • Standardised the message type on resize. verb-tower previously emitted widget-size; now all four speak the same protocol, so a host needs a single listener and matches the right iframe with event.source.
  • Documented the host-side listener in the function-plotter and image-comparison READMEs (pennsic's was already documented).

image-comparison-table + fit-scale

This widget scales its grid to fit a fixed viewport. It now reports its natural (untransformed) content height (scrollHeight is unaffected by the fit-scale transform), so:

  • a host that listens grows the iframe to fit → no scaling needed;
  • a host that pins a fixed height → the existing fit-to-viewport scaling kicks in as the fallback.

Reporting natural height (guarded against no-op posts + debounced) keeps the two mechanisms from fighting: the height is transform-invariant, so there's no resize feedback loop.

Verification

scripts/validate-widgets.mjs passes locally (4/4); the resize effect is a faithful copy of the already-deployed pennsic/verb-tower pattern. The PR's check-widgets CI builds every changed widget (npm run build), which is the real type/build gate.

🤖 Generated with Claude Code

function-plotter and image-comparison-table now post { type: 'resize', height } to window.parent via a ResizeObserver, matching what pennsic-planner and japanese-verb-tower already do, so a host can auto-size the iframe to the widget's content. image-comparison-table reports its natural (untransformed) content height — scrollHeight is unaffected by the fit-scale transform — so its existing fit-to-viewport scaling remains the fallback for hosts that pin a fixed height instead.

Standardise the message type on 'resize' (verb-tower previously emitted 'widget-size') so a host needs a single listener for every widget; match the right iframe with event.source. Documented the host-side listener in the function-plotter and image-comparison READMEs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jbeshir jbeshir merged commit fa7130f into main Jun 22, 2026
6 checks passed
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.

1 participant