Skip to content

Commit fd402e8

Browse files
committed
fix(hub-ui): preserve transparent iframe canvas
1 parent 2664708 commit fd402e8

3 files changed

Lines changed: 21 additions & 14 deletions

File tree

packages/hub-ui/src/client/standalone/index.html

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,23 @@
66
<title>Devframes</title>
77
<meta name="description" content="Devframes hub" />
88
<style>
9+
:root {
10+
color-scheme: light;
11+
--devframes-viewer-background: #fff;
12+
}
13+
html.dark {
14+
color-scheme: dark;
15+
--devframes-viewer-background: #111;
16+
}
17+
html.viewer-background-transparent {
18+
color-scheme: normal;
19+
--devframes-viewer-background: transparent;
20+
}
921
html,
1022
body {
1123
margin: 0;
1224
height: 100%;
13-
background: #fff;
14-
}
15-
html.dark,
16-
html.dark body {
17-
background: #111;
18-
}
19-
html.viewer-background-transparent,
20-
html.viewer-background-transparent body {
21-
background: transparent;
25+
background: var(--devframes-viewer-background);
2226
}
2327
#app {
2428
height: 100%;

packages/hub-ui/src/client/standalone/main.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import { DEFAULT_DOCK_SESSION_STORE } from '../state/docks'
1313
// custom element's shadow root.
1414

1515
// The viewer page runs in the light DOM, so mirror the color mode onto the
16-
// document element — its background and native controls follow the
17-
// Auto/Light/Dark choice.
16+
// document element — its background follows the Auto/Light/Dark choice. The
17+
// component tree carries `color-scheme` for its native controls; keeping that
18+
// off the document lets the transparent viewer expose the iframe's parent.
1819
watchEffect(() => {
1920
const el = document.documentElement
2021
el.classList.toggle('dark', isDark.value)
2122
el.classList.toggle('light', !isDark.value)
22-
el.style.colorScheme = isDark.value ? 'dark' : 'light'
2323
})
2424

2525
async function main(): Promise<void> {

packages/hub-ui/src/index.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ function createContext(): DevframeHubContext {
99
}
1010

1111
describe('createUi branding background', () => {
12-
it('keeps the viewer stylesheet static', () => {
13-
expect.assertions(2)
12+
it('defines the viewer background through a static token', () => {
13+
expect.assertions(5)
1414

1515
const html = readFileSync(join(import.meta.dirname, '..', 'dist', 'client', 'standalone', 'index.html'), 'utf8')
1616

1717
expect(html).not.toContain('__hub-ui.css')
1818
expect(html).toContain('html.viewer-background-transparent')
19+
expect(html).toContain('--devframes-viewer-background: transparent')
20+
expect(html).toContain('background: var(--devframes-viewer-background)')
21+
expect(html).toMatch(/html\.viewer-background-transparent\s*\{[^}]*color-scheme:\s*normal/)
1922
})
2023

2124
it('preserves the default viewer background', () => {

0 commit comments

Comments
 (0)