fix bug 16 and 17
Build & Push / Pipeline Tests (push) Successful in 1m53s
Test / Type Check (all packages) (push) Successful in 56s
Build & Push / Build & Push Docker Image (push) Failing after 4m53s
Test / API Unit Tests (push) Successful in 1m15s
Test / Homepage Unit Tests (push) Successful in 46s
Test / Carplace Unit Tests (push) Successful in 41s
Test / Admin Unit Tests (push) Successful in 40s
Test / Dashboard Unit Tests (push) Successful in 42s
Test / API Integration Tests (push) Successful in 1m6s

This commit is contained in:
root
2026-08-04 00:52:58 -04:00
parent 626da23c2e
commit 149806a773
72 changed files with 834 additions and 174 deletions
@@ -1,10 +1,15 @@
export const themeBootstrapScript = `(function () {
var allowed = { light: true, dark: true, system: true };
var allowedResolved = { light: true, dark: true };
var cookieMatch = document.cookie.match(/(?:^|; )hpc-theme=([^;]+)/);
var cookieValue = cookieMatch ? decodeURIComponent(cookieMatch[1]) : null;
var sharedCookieMatch = document.cookie.match(/(?:^|; )rentaldrivego-theme=([^;]+)/);
var sharedCookieValue = sharedCookieMatch ? decodeURIComponent(sharedCookieMatch[1]) : null;
var stored = null;
var sharedStored = null;
try { stored = localStorage.getItem("hpc.theme.preference"); } catch (_) {}
var preference = allowed[cookieValue] ? cookieValue : (allowed[stored] ? stored : "dark");
try { sharedStored = localStorage.getItem("rentaldrivego-theme"); } catch (_) {}
var preference = allowed[cookieValue] ? cookieValue : (allowed[stored] ? stored : (allowedResolved[sharedCookieValue] ? sharedCookieValue : (allowedResolved[sharedStored] ? sharedStored : "dark")));
var dark = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
var resolved = preference === "system" ? (dark ? "dark" : "light") : preference;
var root = document.documentElement;
+9 -7
View File
@@ -1,6 +1,8 @@
import {
isThemePreference,
resolveTheme,
sharedThemeCookie,
sharedThemeStorageKey,
themeCookie,
themeCookieMaxAgeSeconds,
themeStorageKey,
@@ -18,20 +20,20 @@ export function applyTheme(preference: ThemePreference): void {
}
export function persistTheme(preference: ThemePreference): void {
const systemDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const resolved = resolveTheme(preference, systemDark);
try {
window.localStorage.setItem(themeStorageKey, preference);
window.localStorage.setItem(sharedThemeStorageKey, resolved);
} catch {
// Storage can be unavailable; the first-party cookie remains canonical.
}
const secure = window.location.protocol === 'https:' ? '; Secure' : '';
document.cookie =
[
`${themeCookie}=${encodeURIComponent(preference)}`,
'Path=/',
`Max-Age=${themeCookieMaxAgeSeconds}`,
'SameSite=Lax',
].join('; ') + secure;
const cookieAttributes = ['Path=/', `Max-Age=${themeCookieMaxAgeSeconds}`, 'SameSite=Lax'].join('; ') + secure;
document.cookie = `${themeCookie}=${encodeURIComponent(preference)}; ${cookieAttributes}`;
document.cookie = `${sharedThemeCookie}=${encodeURIComponent(resolved)}; ${cookieAttributes}`;
applyTheme(preference);
window.dispatchEvent(
new CustomEvent<ThemePreference>(themePreferenceEvent, { detail: preference }),
+2
View File
@@ -1,5 +1,7 @@
export const themeCookie = 'hpc-theme';
export const themeStorageKey = 'hpc.theme.preference';
export const sharedThemeCookie = 'rentaldrivego-theme';
export const sharedThemeStorageKey = 'rentaldrivego-theme';
export const themePreferences = ['light', 'dark', 'system'] as const;
export type ThemePreference = (typeof themePreferences)[number];
export type ResolvedTheme = 'light' | 'dark';