Skip to content

Commit 6709dd0

Browse files
committed
web: swap GL theme stylesheet instead of inverting dark-theme icons
Load both goldenlayout-dark-theme.css and goldenlayout-light-theme.css, toggling the disabled attribute on theme switch. This lets the light theme use its native black PNGs for window controls instead of applying filter: invert(1) to the dark theme's white PNGs. The tab overflow dropdown list is still custom-styled because neither GL theme provides any styling for .lm_tabdropdown_list. Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
1 parent b652baf commit 6709dd0

5 files changed

Lines changed: 60 additions & 3 deletions

File tree

src/web/src/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
crossorigin=""></script>
1414

1515
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/golden-layout@2.6.0/dist/css/goldenlayout-base.css"/>
16-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/golden-layout@2.6.0/dist/css/themes/goldenlayout-dark-theme.css"/>
16+
<link rel="stylesheet" id="gl-theme-dark" href="https://cdn.jsdelivr.net/npm/golden-layout@2.6.0/dist/css/themes/goldenlayout-dark-theme.css"/>
17+
<link rel="stylesheet" id="gl-theme-light" href="https://cdn.jsdelivr.net/npm/golden-layout@2.6.0/dist/css/themes/goldenlayout-light-theme.css" disabled/>
1718

1819
<script src="https://nturley.github.io/netlistsvg/elk.bundled.js"></script>
1920
<script src="https://nturley.github.io/netlistsvg/built/netlistsvg.bundle.js"></script>

src/web/src/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { RulerManager } from './ruler.js';
1616
import { SchematicWidget } from './schematic-widget.js';
1717
import { DrcWidget } from './drc-widget.js';
1818
import { TclCompleter } from './tcl-completer.js';
19-
import { setCookie } from './theme.js';
19+
import { setCookie, applyGLTheme } from './theme.js';
2020
import { updateDocumentTitle } from './title.js';
2121

2222
// ─── Status Indicator ───────────────────────────────────────────────────────
@@ -657,6 +657,7 @@ app.focusComponent = focusComponent;
657657
app.toggleTheme = function() {
658658
const next = document.documentElement.dataset.theme === 'dark' ? 'light' : 'dark';
659659
document.documentElement.dataset.theme = next;
660+
applyGLTheme(next);
660661
setCookie('or_theme', next);
661662
// Also write to localStorage for standalone file:// reports.
662663
if (typeof localStorage !== 'undefined') {

src/web/src/style.css

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,50 @@ html, body {
393393
background: var(--border-subtle);
394394
}
395395

396+
/* Tab overflow dropdown — neither GL theme styles the dropdown list, so
397+
* it's transparent and effectively unusable. Style it so overflowed tabs
398+
* are visible and clickable. */
399+
.lm_header .lm_tabdropdown_list {
400+
background: var(--bg-context);
401+
border: 1px solid var(--border-strong);
402+
box-shadow: 0 4px 12px var(--shadow);
403+
min-width: 160px;
404+
max-width: 320px;
405+
max-height: 60vh;
406+
overflow-y: auto !important;
407+
overflow-x: hidden;
408+
padding: 2px 0;
409+
border-radius: 0 0 4px 4px;
410+
}
411+
.lm_header .lm_tabdropdown_list .lm_tab {
412+
display: flex;
413+
align-items: center;
414+
width: auto;
415+
height: auto;
416+
padding: 4px 12px;
417+
margin: 0;
418+
background: transparent;
419+
color: var(--fg-primary);
420+
float: none;
421+
}
422+
.lm_header .lm_tabdropdown_list .lm_tab:hover {
423+
background: var(--bg-hover);
424+
color: var(--fg-bright);
425+
}
426+
.lm_header .lm_tabdropdown_list .lm_tab.lm_active {
427+
background: var(--bg-selected);
428+
color: var(--fg-white);
429+
}
430+
.lm_header .lm_tabdropdown_list .lm_tab .lm_title {
431+
width: auto;
432+
flex: 1;
433+
color: inherit;
434+
min-width: 0;
435+
white-space: nowrap;
436+
overflow: hidden;
437+
text-overflow: ellipsis;
438+
}
439+
396440
/* Leaflet map cursor */
397441
.leaflet-container {
398442
cursor: default !important;

src/web/src/theme.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,23 @@ export function setCookie(name, value) {
1414
document.cookie = name + '=' + value + '; path=/; max-age=31536000; SameSite=Lax';
1515
}
1616

17+
// Enable the Golden Layout theme stylesheet matching the active theme.
18+
export function applyGLTheme(theme) {
19+
const dark = document.getElementById('gl-theme-dark');
20+
const light = document.getElementById('gl-theme-light');
21+
if (!dark || !light) return;
22+
dark.disabled = (theme !== 'dark');
23+
light.disabled = (theme !== 'light');
24+
}
25+
1726
if (typeof document !== 'undefined') {
1827
// Try cookie first (shared across ports for the live server),
1928
// then localStorage (works for standalone file:// reports).
2029
const savedTheme = getCookie('or_theme')
2130
|| (typeof localStorage !== 'undefined' && localStorage.getItem('or_theme'))
2231
|| (matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark');
2332
document.documentElement.dataset.theme = savedTheme;
33+
applyGLTheme(savedTheme);
2434
}
2535

2636
// Read current CSS custom property values for canvas-based widgets.

src/web/src/web.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,8 @@ void WebServer::saveReport(const std::string& filename,
10231023
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"/>
10241024
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
10251025
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/golden-layout@2.6.0/dist/css/goldenlayout-base.css"/>
1026-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/golden-layout@2.6.0/dist/css/themes/goldenlayout-dark-theme.css"/>
1026+
<link rel="stylesheet" id="gl-theme-dark" href="https://cdn.jsdelivr.net/npm/golden-layout@2.6.0/dist/css/themes/goldenlayout-dark-theme.css"/>
1027+
<link rel="stylesheet" id="gl-theme-light" href="https://cdn.jsdelivr.net/npm/golden-layout@2.6.0/dist/css/themes/goldenlayout-light-theme.css" disabled/>
10271028
<style>
10281029
)" << kReportCSS
10291030
<< R"(

0 commit comments

Comments
 (0)