Skip to content

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

Open
dvcolomban wants to merge 1 commit into
devframes:mainfrom
dvcolomban:codex/embedded-viewer-background
Open

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

Conversation

@dvcolomban

Copy link
Copy Markdown
Contributor

Background (Why)

The standalone viewer can also be framed by another developer tool, where its page background needs to blend with the containing UI. Today consumers must choose one background for both direct and framed visits, or rewrite the generated HTML to distinguish them.

Changes (What)

Adds branding.embeddedBackground with the same CSS string or { light, dark } shape as background. A framed standalone viewer selects it using window.self !== window.top; direct visits retain background, and framed visits fall back to background when no override is configured. CSS values keep the existing CSS.supports validation before they reach the document.

Verification (Testing)

  • Added standalone/embedded light/dark resolution coverage and fallback coverage.
  • Added supported, invalid, and absent CSS background validation coverage.
  • Passed lint, knip, typecheck, build, the public API snapshot guard, and the 15 focused Hub UI tests.
  • The full suite passed 1,335 tests; the unrelated @devframes/plugin-assets filesystem watcher test timed out locally, including when rerun alone.

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.


- **`viewer`** — set to `false` to disable the standalone viewer.
- **`branding`** — rebrand the UI (logo, name, primary color). `background` accepts any CSS `background` value (color, gradient, image, or `transparent`) or `{ light, dark }` variants; omit it to keep the design default.
- **`branding`** — rebrand the UI (logo, name, primary color). `background` accepts any CSS `background` value (color, gradient, image, or `transparent`) or `{ light, dark }` variants. `embeddedBackground` overrides it when the standalone viewer runs inside an iframe. Omit either value to inherit its fallback.
documentElement.classList.add('viewer-background-custom')
documentElement.style.setProperty('--devframes-viewer-background', background)
}
const brandingBackground = useBrandingBackground(window.self !== window.top)
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 on lines +12 to +19
if (background === undefined || !supports('background', background)) {
documentElement.classList.remove('viewer-background-custom')
documentElement.style.removeProperty('--devframes-viewer-background')
return
}

documentElement.classList.add('viewer-background-custom')
documentElement.style.setProperty('--devframes-viewer-background', background)
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.

2 participants