Add theme settings, and remove the old theme system
This commit is contained in:
parent
567ac1a26d
commit
9f4a3197de
22 changed files with 2301 additions and 463 deletions
|
|
@ -15,15 +15,8 @@ import {
|
|||
state,
|
||||
type WikiScreenParams,
|
||||
} from "./state.js";
|
||||
import { applyVisualPreferences } from "./theme.js";
|
||||
import {
|
||||
getColorMode,
|
||||
isReducedEffects,
|
||||
toggleColorMode,
|
||||
toggleReducedEffects,
|
||||
} from "./theme.js";
|
||||
import {
|
||||
clear,
|
||||
h,
|
||||
initNotificationDrawer,
|
||||
initTooltipController,
|
||||
toast,
|
||||
|
|
@ -57,46 +50,6 @@ registerScreenRenderers({
|
|||
wiki: (el, p) => renderWiki(el, p as WikiScreenParams),
|
||||
});
|
||||
|
||||
function renderComfortToolbar(): void {
|
||||
const root = document.getElementById("comfort-controls-root");
|
||||
if (!root) return;
|
||||
clear(root);
|
||||
const mode = getColorMode();
|
||||
const reduced = isReducedEffects();
|
||||
root.appendChild(
|
||||
h(
|
||||
"div",
|
||||
{ class: "comfort-pill-bar" },
|
||||
h(
|
||||
"button",
|
||||
{
|
||||
class: `comfort-btn ${mode === "light" ? "active" : ""}`,
|
||||
title: "Toggle Daylight Light Mode / Dark Mode",
|
||||
onClick: () => {
|
||||
toggleColorMode();
|
||||
renderComfortToolbar();
|
||||
},
|
||||
},
|
||||
mode === "light" ? "SUN LIGHT" : "DARK",
|
||||
),
|
||||
h(
|
||||
"button",
|
||||
{
|
||||
class: `comfort-btn ${reduced ? "active" : ""}`,
|
||||
title:
|
||||
"Toggle Eye-Saver (Reduced Effects: disables glows, scanlines & shake)",
|
||||
onClick: () => {
|
||||
toggleReducedEffects();
|
||||
applyThemeFromState();
|
||||
renderComfortToolbar();
|
||||
},
|
||||
},
|
||||
reduced ? "EYE-SAVER ON" : "EYE-SAVER",
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
async function waitForStylesAndLoad(): Promise<void> {
|
||||
const pendingLinks = Array.from(
|
||||
document.querySelectorAll('link[rel="stylesheet"]'),
|
||||
|
|
@ -125,8 +78,7 @@ async function waitForStylesAndLoad(): Promise<void> {
|
|||
async function boot(): Promise<void> {
|
||||
saveSettings(getSettings());
|
||||
applyThemeFromState();
|
||||
renderComfortToolbar();
|
||||
window.addEventListener("sgywftp:theme-changed", renderComfortToolbar);
|
||||
applyVisualPreferences();
|
||||
initNotificationDrawer();
|
||||
initTooltipController();
|
||||
initWalkthroughController();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue