|
134 | 134 | style.textContent = lines.join("\n"); |
135 | 135 | } |
136 | 136 |
|
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() { |
147 | 138 | const cfg = loadConfig(); |
148 | | - if (!cfg) { |
149 | | - applyDefaultsFromTheme(); |
150 | | - return; |
151 | | - } |
| 139 | + if (!cfg) return; |
152 | 140 | applyColors(cfg.primary, cfg.accent); |
153 | 141 | } |
154 | 142 |
|
|
352 | 340 | resetBtn.addEventListener("click", () => { |
353 | 341 | localStorage.removeItem(STORAGE_KEY); |
354 | 342 | clearStyleTag(); |
355 | | - applyFromStorageOrThemeDefaults(); |
356 | 343 | 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; |
361 | 349 | }); |
362 | 350 |
|
363 | 351 | return { overlay, open, close: closePanel }; |
364 | 352 | } |
365 | 353 |
|
366 | 354 | function mount() { |
367 | | - applyFromStorageOrThemeDefaults(); |
| 355 | + applyFromStorage(); |
368 | 356 |
|
369 | 357 | if (document.querySelector(".theme-palette-overlay")) return; |
370 | 358 | const { overlay, open } = createDialog(); |
|
0 commit comments