feat(samples): add sample-size reporter for auto-fitting docs iframes#3996
Open
desig9stein wants to merge 6 commits into
Open
feat(samples): add sample-size reporter for auto-fitting docs iframes#3996desig9stein wants to merge 6 commits into
desig9stein wants to merge 6 commits into
Conversation
Demos on the docs site render inside cross-origin iframes. By default
styles.scss pins html/body to height:100% + overflow:hidden, so an
iframe can only ever echo its own height back — it can't grow to fit its
content. This adds the demo-side half of a small postMessage handshake
with the docs host (astro-components' sample-widget) so samples that opt
into fitContent size themselves to their actual content.
How it works:
- the host posts { type: 'igd-sample-fit', width? } into the iframe on
load; until that arrives the reporter stays completely dormant, so
fixed-height demos and their percentage layouts are untouched
- on enable, it injects a one-time stylesheet that releases the viewport
pin (height:auto, overflow:visible) and reports content size back with
{ type: 'igd-sample-height', height, width? } immediately and on every
resize (via ResizeObserver)
- width is measured from the right-most element edge rather than the body
box, mirroring the host's same-origin measurement, and is only computed
when the host asks for it
Notes:
- no-ops outside an iframe (window.parent === window) and when there is
no window (SSR/prerender)
- replies target the host's captured origin instead of broadcasting to
'*', and only ever emit layout dimensions
- shared across all three Angular apps (src, app-crm, app-lob) via the
"@shared/sample-size-reporter" tsconfig path alias so there is a single
source of truth
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.
Related to: IgniteUI/igniteui-astro-components#108
Demos on the docs site render inside cross-origin iframes. By default
styles.scss pins html/body to height:100% + overflow:hidden, so an
iframe can only ever echo its own height back — it can't grow to fit its
content. This adds the demo-side half of a small postMessage handshake
with the docs host (astro-components' sample-widget) so samples that opt
into fitContent size themselves to their actual content.
How it works:
load; until that arrives the reporter stays completely dormant, so
fixed-height demos and their percentage layouts are untouched
pin (height:auto, overflow:visible) and reports content size back with
{ type: 'igd-sample-height', height, width? } immediately and on every
resize (via ResizeObserver)
box, mirroring the host's same-origin measurement, and is only computed
when the host asks for it
Notes:
no window (SSR/prerender)
'*', and only ever emit layout dimensions
"@shared/sample-size-reporter" tsconfig path alias so there is a single
source of truth