feat(hub-ui): support embedded viewer backgrounds - #320
Open
dvcolomban wants to merge 1 commit into
Open
Conversation
|
@dvcolomban is attempting to deploy a commit to the NuxtLabs Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
There was a problem hiding this comment.
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.embeddedBackgroundalongsidebranding.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) |
dvcolomban
force-pushed
the
codex/embedded-viewer-background
branch
from
August 31, 2026 12:48
82658b2 to
dca6735
Compare
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) |
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.
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.embeddedBackgroundwith the same CSS string or{ light, dark }shape asbackground. A framed standalone viewer selects it usingwindow.self !== window.top; direct visits retainbackground, and framed visits fall back tobackgroundwhen no override is configured. CSS values keep the existingCSS.supportsvalidation before they reach the document.Verification (Testing)
@devframes/plugin-assetsfilesystem watcher test timed out locally, including when rerun alone.