Skip to content

feat(hub-ui): support embedded viewer backgrounds - #320

Merged
antfu merged 1 commit into
devframes:mainfrom
dvcolomban:codex/embedded-viewer-background
Sep 1, 2026
Merged

feat(hub-ui): support embedded viewer backgrounds#320
antfu merged 1 commit into
devframes:mainfrom
dvcolomban:codex/embedded-viewer-background

Conversation

@dvcolomban

@dvcolomban dvcolomban commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Background (Why)

The standalone viewer can also be embedded as an iframe by downstream developer tools. Those consumers need a transparent framed surface while retaining an authored background for direct visits, without rewriting generated HTML or treating the Hub client type as iframe state.

Changes (What)

  • Keeps the existing flat branding.background string and { light, dark } forms unchanged; they still apply everywhere.
  • Adds an optional contextual form: { standalone, iframe? }, where each value accepts the same flat color-scheme shape.
  • Selects the iframe value locally in the standalone viewer with window.self !== window.top; a missing iframe value falls back to standalone.
  • Keeps branding JSON-serializable and leaves DockClientType unchanged.
  • Preserves CSS validation and applies the viewer's light/dark color-scheme without the unused custom-background class.
  • Updates the public declarations, API snapshot, documentation, and focused tests.

Verification (Testing)

  • Hub UI tests: 43 passed across six files.
  • Focused background resolution and CSS validation: 11 passed.
  • Typecheck, ESLint, Knip, Hub UI build, built-viewer tests, and targeted public API snapshot passed.
  • Browser-verified standalone white / #282828 backgrounds and transparent cross-origin iframe backgrounds in both light and dark modes, including dark foreground and color-scheme.
Copilot AI lite review requested due to automatic review settings August 31, 2026 09:50
@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown

@dvcolomban is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds configurable background styling for the hub UI standalone viewer when it’s framed (embedded) by another tool, while preserving existing standalone behavior and CSS validation.

Changes:

  • Introduces branding.embeddedBackground alongside branding.background (supports string or { light, dark }).
  • Updates standalone viewer runtime to select embedded vs standalone background based on frame context.
  • Adds unit tests for embedded/standalone resolution and for CSS background validation application.

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
tests/snapshots/tsnapi/@devframes/hub-ui/index.snapshot.d.ts Updates public API snapshot to include embeddedBackground.
packages/hub-ui/src/types.ts Adds DevframeBranding.embeddedBackground to published types.
packages/hub-ui/src/index.test.ts Ensures createUi() publishes embeddedBackground through static config.
packages/hub-ui/src/client/state/branding.ts Extends resolved branding and updates useBrandingBackground() to support embedded selection/fallback.
packages/hub-ui/src/client/state/branding.test.ts Adds coverage for embedded/standalone resolution and fallback behavior.
packages/hub-ui/src/client/standalone/viewer-background.ts Extracts background application + CSS.supports validation into a helper.
packages/hub-ui/src/client/standalone/viewer-background.test.ts Adds tests for supported/invalid/absent background application.
packages/hub-ui/src/client/standalone/main.ts Uses embedded-aware branding background and the extracted helper.
docs/content/1.guide/18.hub-initiate.md Documents embeddedBackground behavior in hub UI configuration guide.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docs/content/1.guide/18.hub-initiate.md Outdated
Comment thread packages/hub-ui/src/client/standalone/main.ts Outdated
Copilot AI review requested due to automatic review settings August 31, 2026 12:48
@dvcolomban
dvcolomban force-pushed the codex/embedded-viewer-background branch from 82658b2 to dca6735 Compare August 31, 2026 12:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.

Comment thread packages/hub-ui/src/client/standalone/viewer-background.ts
@dvcolomban
dvcolomban marked this pull request as draft August 31, 2026 21:28
@dvcolomban
dvcolomban force-pushed the codex/embedded-viewer-background branch from dca6735 to c246b56 Compare August 31, 2026 22:21
@dvcolomban
dvcolomban marked this pull request as ready for review August 31, 2026 23:31
Copilot AI review requested due to automatic review settings August 31, 2026 23:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.

Comment thread packages/hub-ui/src/client/state/branding.ts Outdated
Copilot AI review requested due to automatic review settings August 31, 2026 23:39
@dvcolomban
dvcolomban force-pushed the codex/embedded-viewer-background branch from c246b56 to 79da0fe Compare August 31, 2026 23:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated no new comments.

@antfu
antfu merged commit 1cefacd into devframes:main Sep 1, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants