Skip to content

feat(code): iframe component - #203

Open
coryrylan wants to merge 1 commit into
mainfrom
topic-iframe
Open

feat(code): iframe component#203
coryrylan wants to merge 1 commit into
mainfrom
topic-iframe

Conversation

@coryrylan

@coryrylan coryrylan commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator
  • Added the nve-iframe component to render isolated content with dynamic height and theme synchronization.
  • Implemented iframe styling and functionality to handle resizing and theme updates.

Summary by CodeRabbit

  • New Features

    • Added the nve-iframe component for rendering isolated, sandboxed content.
    • Supports templated content, theme synchronization, dynamic height, fixed sizing, and overflow control.
    • Added public package exports for the iframe component and registration helper.
  • Documentation

    • Added iframe usage documentation and navigation.
  • Tests

    • Added unit, accessibility, performance, and server-side rendering coverage.
    • Added a dedicated SSR test command and CI integration.

@coryrylan
coryrylan requested a review from johnyanarella July 31, 2026 20:17
@coryrylan coryrylan self-assigned this Jul 31, 2026
Copilot AI review requested due to automatic review settings July 31, 2026 20:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added scope(internals) scope(code) scope(docs) dependencies Pull requests that update a dependency file labels Jul 31, 2026
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds the nve-iframe Lit component. It supports sandboxed templated content, theme synchronization, automatic resizing, public package exports, SSR testing, Storybook examples, and site documentation.

Changes

Iframe component

Layer / File(s) Summary
Iframe rendering and synchronization
projects/code/src/iframe/iframe.ts, projects/code/src/iframe/iframe.css
The component renders sandboxed srcdoc content, synchronizes themes, observes template changes, validates resize messages, and updates its dimensions.
Component behavior validation
projects/code/src/iframe/iframe.test.ts, projects/code/src/iframe/iframe.test.axe.ts, projects/code/src/iframe/iframe.test.lighthouse.ts, projects/code/src/iframe/iframe.test.ssr.ts
Tests cover rendering, sandbox attributes, theme propagation, resize handling, lifecycle cleanup, accessibility, Lighthouse scores, and SSR output.
Public registration and test wiring
projects/code/src/iframe/define.ts, projects/code/src/iframe/index.ts, projects/code/src/bundle.ts, projects/code/package.json, projects/code/vitest.ssr.ts, projects/code/DEVELOPMENT.md, projects/code/src/index.test.lighthouse.ts
The iframe API is registered and exported. Package exports and SSR test targets are added.
Examples and documentation
projects/code/src/iframe/iframe.examples.ts, projects/site/src/docs/code/iframe.md, projects/site/src/_11ty/layouts/common.js, projects/internals/eslint/src/local/example-approved-domains.js
Examples and documentation describe iframe isolation, dynamic height, fixed sizing, overflow clipping, and dynamic content updates.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ParentDocument
  participant Iframe
  participant ResizeObserver
  ParentDocument->>Iframe: Render templated srcdoc
  ParentDocument->>Iframe: Send theme message
  Iframe->>ResizeObserver: Observe body size
  ResizeObserver-->>Iframe: Report dimensions
  Iframe-->>ParentDocument: Send resize message
Loading

Possibly related PRs

Suggested labels: scope(ci)

Suggested reviewers: johnyanarella

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: adding the iframe component to the code package.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch topic-iframe

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

projects/code/package.json

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

projects/code/src/bundle.ts

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

projects/code/src/iframe/define.ts

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

  • 11 others

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@projects/code/src/iframe/iframe.css`:
- Around line 4-18: In the :host rule, insert a blank line after the
custom-property declarations and before display: block;, preserving all existing
declarations and values.

In `@projects/code/src/iframe/iframe.examples.ts`:
- Around line 17-28: Add a descriptive aria-label to every nve-iframe example so
each native browsing context has an accessible name. Update
projects/code/src/iframe/iframe.examples.ts at 17-28, 38-56, 66-68, 78-92, and
102-106, and apply the same requirement to the installation sample in
projects/site/src/docs/code/iframe.md at 16-27.

In `@projects/code/src/iframe/iframe.test.axe.ts`:
- Around line 11-19: Update the beforeEach setup for element in the Iframe
metadata test to call querySelector with the Iframe generic and explicitly
reject a null result, matching the guard pattern used in iframe.test.ts.

In `@projects/code/src/iframe/iframe.ts`:
- Around line 106-113: Update the iframe title binding in render() to use a
non-empty fallback such as “Embedded content” whenever ariaLabel is unset or
empty, while preserving the configured ariaLabel when provided.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 93881312-ebe3-426c-b886-89a6b6572cf7

📥 Commits

Reviewing files that changed from the base of the PR and between 651abf3 and dfd197f.

📒 Files selected for processing (17)
  • projects/code/DEVELOPMENT.md
  • projects/code/package.json
  • projects/code/src/bundle.ts
  • projects/code/src/iframe/define.ts
  • projects/code/src/iframe/iframe.css
  • projects/code/src/iframe/iframe.examples.ts
  • projects/code/src/iframe/iframe.test.axe.ts
  • projects/code/src/iframe/iframe.test.lighthouse.ts
  • projects/code/src/iframe/iframe.test.ssr.ts
  • projects/code/src/iframe/iframe.test.ts
  • projects/code/src/iframe/iframe.ts
  • projects/code/src/iframe/index.ts
  • projects/code/src/index.test.lighthouse.ts
  • projects/code/vitest.ssr.ts
  • projects/internals/eslint/src/local/example-approved-domains.js
  • projects/site/src/_11ty/layouts/common.js
  • projects/site/src/docs/code/iframe.md

Comment thread projects/code/src/iframe/iframe.css
Comment thread projects/code/src/iframe/iframe.examples.ts Outdated
Comment thread projects/code/src/iframe/iframe.test.axe.ts
Comment thread projects/code/src/iframe/iframe.ts
- Added the nve-iframe component to render isolated content with dynamic height and theme synchronization.
- Implemented iframe styling and functionality to handle resizing and theme updates.

Signed-off-by: Cory Rylan <crylan@nvidia.com>
Copilot AI review requested due to automatic review settings July 31, 2026 20:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (2)
projects/code/src/iframe/iframe.css (1)

4-12: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add the blank line Stylelint requires before display: block;.

The declaration-empty-line-before rule still flags line 8. Insert a blank line between the custom-property declarations and the regular declarations.

🎨 Proposed fix
 :host {
   --width: var(--_width, fit-content);
   --height: var(--_height, fit-content);
   --border: none;
+
   display: block;
   width: fit-content;
   height: fit-content;
   border: var(--border);
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@projects/code/src/iframe/iframe.css` around lines 4 - 12, In the :host rule,
insert a blank line after the custom-property declarations for --width,
--height, and --border, before the display declaration, to satisfy Stylelint's
declaration-empty-line-before rule.

Source: Linters/SAST tools

projects/code/src/iframe/iframe.ts (1)

106-113: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Provide a non-empty fallback for the iframe title.

title=${this.ariaLabel} has no fallback. When ariaLabel is unset, Lit renders title="", not a removed attribute. Official Lit documentation confirms this: "In attribute expressions, nothing removes the attribute, while undefined and null will render an empty string." An empty title on the internal iframe fails accessibility checks (as flagged by the Lighthouse fixture in a prior review, before it was updated to always pass aria-label).

Add a fallback, e.g., title=${this.ariaLabel || 'Embedded content'}.

🐛 Proposed fix
   render() {
     return html`<iframe
       internal-host
-      title=${this.ariaLabel}
+      title=${this.ariaLabel || 'Embedded content'}
       sandbox="allow-scripts"
       `@load`=${this.#syncTheme}
     ></iframe>`;
   }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@projects/code/src/iframe/iframe.ts` around lines 106 - 113, Update the iframe
title binding in render() to use a non-empty fallback when ariaLabel is unset,
such as “Embedded content,” while preserving the configured ariaLabel when
provided.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@projects/code/src/iframe/iframe.ts`:
- Around line 65-77: Update the class-level `@description` in the nve-iframe JSDoc
to use clear active voice, replacing the awkward usage phrase with wording that
identifies the component as the subject while preserving the meaning about
rendering dynamically generated or isolated content.

In `@projects/site/src/docs/code/iframe.md`:
- Around line 38-40: Add documentation sections in the iframe guide alongside
the existing Fixed Size example for the public OverflowClip and
DynamicallyUpdatedContent examples. Reference the corresponding example names
from iframe.examples.json so the overflow boundary and dynamically updated
content behaviors are exposed consistently with the existing sections.

---

Duplicate comments:
In `@projects/code/src/iframe/iframe.css`:
- Around line 4-12: In the :host rule, insert a blank line after the
custom-property declarations for --width, --height, and --border, before the
display declaration, to satisfy Stylelint's declaration-empty-line-before rule.

In `@projects/code/src/iframe/iframe.ts`:
- Around line 106-113: Update the iframe title binding in render() to use a
non-empty fallback when ariaLabel is unset, such as “Embedded content,” while
preserving the configured ariaLabel when provided.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 1ab30b26-6333-4b70-95c4-ba975f88cb5d

📥 Commits

Reviewing files that changed from the base of the PR and between dfd197f and ab3eb8f.

📒 Files selected for processing (17)
  • projects/code/DEVELOPMENT.md
  • projects/code/package.json
  • projects/code/src/bundle.ts
  • projects/code/src/iframe/define.ts
  • projects/code/src/iframe/iframe.css
  • projects/code/src/iframe/iframe.examples.ts
  • projects/code/src/iframe/iframe.test.axe.ts
  • projects/code/src/iframe/iframe.test.lighthouse.ts
  • projects/code/src/iframe/iframe.test.ssr.ts
  • projects/code/src/iframe/iframe.test.ts
  • projects/code/src/iframe/iframe.ts
  • projects/code/src/iframe/index.ts
  • projects/code/src/index.test.lighthouse.ts
  • projects/code/vitest.ssr.ts
  • projects/internals/eslint/src/local/example-approved-domains.js
  • projects/site/src/_11ty/layouts/common.js
  • projects/site/src/docs/code/iframe.md

Comment thread projects/code/src/iframe/iframe.ts
Comment thread projects/site/src/docs/code/iframe.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file scope(code) scope(docs) scope(internals)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants