Skip to content

Commit 2bcce0e

Browse files
author
committed
Deployed 9d5041e with MkDocs version: 1.6.1
1 parent a0c9d27 commit 2bcce0e

1 file changed

Lines changed: 8 additions & 20 deletions

File tree

assets/javascripts/theme-palette.js

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -134,21 +134,9 @@
134134
style.textContent = lines.join("\n");
135135
}
136136

137-
function applyDefaultsFromTheme() {
138-
const primary = getCssVar("--md-primary-fg-color");
139-
const primaryHex = rgbStringToHex(primary) || (isHexColor(primary) ? primary.toUpperCase() : null);
140-
if (!primaryHex) return;
141-
142-
const accentHex = lightenHex(primaryHex, 0.35) || primaryHex;
143-
applyColors(primaryHex, accentHex);
144-
}
145-
146-
function applyFromStorageOrThemeDefaults() {
137+
function applyFromStorage() {
147138
const cfg = loadConfig();
148-
if (!cfg) {
149-
applyDefaultsFromTheme();
150-
return;
151-
}
139+
if (!cfg) return;
152140
applyColors(cfg.primary, cfg.accent);
153141
}
154142

@@ -352,19 +340,19 @@
352340
resetBtn.addEventListener("click", () => {
353341
localStorage.removeItem(STORAGE_KEY);
354342
clearStyleTag();
355-
applyFromStorageOrThemeDefaults();
356343
const p = getCssVar("--md-primary-fg-color");
357-
const pHex = rgbStringToHex(p) || (isHexColor(p) ? p : null) || "#6750A4";
358-
const aHex = lightenHex(pHex, 0.35) || "#EFB8C8";
359-
primaryInput.value = pHex;
360-
accentInput.value = aHex;
344+
const a = getCssVar("--md-accent-fg-color");
345+
const pHex = rgbStringToHex(p) || (isHexColor(p) ? p : null);
346+
const aHex = rgbStringToHex(a) || (isHexColor(a) ? a : null);
347+
if (pHex) primaryInput.value = pHex;
348+
if (aHex) accentInput.value = aHex;
361349
});
362350

363351
return { overlay, open, close: closePanel };
364352
}
365353

366354
function mount() {
367-
applyFromStorageOrThemeDefaults();
355+
applyFromStorage();
368356

369357
if (document.querySelector(".theme-palette-overlay")) return;
370358
const { overlay, open } = createDialog();

0 commit comments

Comments
 (0)