feat(centralui): dark-mode toggle + localStorage persistence + SSR pre-hydration (T34b)

This commit is contained in:
Joseph Doherty
2026-06-18 20:09:00 -04:00
parent 0449c473c1
commit fef4d4cf83
5 changed files with 189 additions and 0 deletions
@@ -10,6 +10,19 @@
<ThemeHead />
<link href="/ZB.MOM.WW.ScadaBridge.Host.styles.css" rel="stylesheet" />
<link href="_content/ZB.MOM.WW.ScadaBridge.CentralUI/css/site.css" rel="stylesheet" />
<script>
// T34b: apply the persisted theme to <html> BEFORE first paint so a
// dark-mode user never sees a light flash. Mirrors window.sbTheme.get/apply
// (theme.js) — same key, same rule — but inlined so it runs without waiting
// on the deferred script include. localStorage access is guarded for
// private-browsing modes that throw on read.
(function () {
try {
var m = localStorage.getItem('sb-theme') === 'dark' ? 'dark' : 'light';
document.documentElement.setAttribute('data-bs-theme', m);
} catch (e) { }
})();
</script>
<HeadOutlet @rendermode="InteractiveServer" />
</head>
<body>
@@ -78,6 +91,7 @@
</script>
<script src="/js/treeview-storage.js"></script>
<ThemeScripts />
<script src="_content/ZB.MOM.WW.ScadaBridge.CentralUI/js/theme.js"></script>
<script src="_content/ZB.MOM.WW.ScadaBridge.CentralUI/js/monaco-init.js"></script>
<script src="_content/ZB.MOM.WW.ScadaBridge.CentralUI/js/audit-grid.js"></script>
<script src="_content/ZB.MOM.WW.ScadaBridge.CentralUI/js/transport.js"></script>