Size-reporter migrated to base vnext without sample changes - #4014
Merged
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
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a shared “sample size reporter” utility intended for iframe-embedded demos (to report content height/width to a docs host) and wires it into the various app entrypoints, along with some accompanying stylesheet cleanups.
Changes:
- Added
initSampleSizeReporter()utility and initialized it insrc/main.tsand project entrypoints. - Added a TypeScript path alias for importing the shared reporter.
- Adjusted/removed several sample and docs-layout SCSS rules.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Adds paths alias for @shared/sample-size-reporter (but currently missing baseUrl). |
| src/sample-size-reporter.ts | New shared utility to listen for a host message and post back size updates. |
| src/main.ts | Initializes the reporter before bootstrapping the Angular app. |
| src/app/layouts/avatar/avatar-styling/layout.scss | Updates avatar sample layout styles. |
| src/app/interactions/toggle/toggle-samples.scss | Formatting cleanup and removal of nested theme-specific rules for toggle section. |
| src/app/index/docs-layout.component.scss | Removes the previous ::ng-deep .custom-body styling (file becomes empty). |
| projects/app-lob/src/main.ts | Initializes the reporter before bootstrapping the app-lob project. |
| projects/app-lob/src/app/index/docs-layout.component.scss | Removes the previous ::ng-deep .custom-body styling (file becomes empty). |
| projects/app-crm/src/main.ts | Initializes the reporter before bootstrapping the app-crm project. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 9 changed files in this pull request and generated no new comments.
Suppressed comments (4)
src/app/layouts/avatar/avatar-styling/layout.scss:3
- This replaces the avatar sample’s wrapping layout and sizing rules with a different host layout, which is a functional sample change despite the PR title stating that the migration has no sample changes. Either revert this hunk or update the stated scope and validate the intentional visual change.
:host {
display: inline-flex;
gap: 32px
src/app/interactions/toggle/toggle-samples.scss:20
- Removing the dark-theme and custom-body rules changes the toggle samples’ themed foreground/background rendering, contrary to the PR’s stated “without sample changes” scope. Restore these rules unless this visual change is intentional and documented in the PR scope.
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
src/app/index/docs-layout.component.scss:1
- This removes the direct-sample layout’s
.custom-bodysurface and contrast colors whileAppComponentstill applies that body class, so themed samples can render differently. That contradicts the PR title’s “without sample changes” scope; restore the rule or document and validate the intended visual change.
projects/app-lob/src/app/index/docs-layout.component.scss:1 - This removes the LOB direct-sample layout’s
.custom-bodysurface and contrast colors while the LOBAppComponentstill applies that class. The resulting theme-rendering change conflicts with the PR title’s “without sample changes” scope; restore the rule or document and validate the visual change.
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.
No description provided.