|
6 | 6 | id: "md3", |
7 | 7 | name: "MD3 默认", |
8 | 8 | primary: "#6750A4", |
9 | | - accent: "#EFB8C8", |
| 9 | + accent: "#9C8DC4", |
10 | 10 | }, |
11 | 11 | { |
12 | 12 | id: "teal_purple", |
|
120 | 120 | style.textContent = lines.join("\n"); |
121 | 121 | } |
122 | 122 |
|
| 123 | + function applyDefaultAccentFromPrimary() { |
| 124 | + const p = getCssVar("--md-primary-fg-color"); |
| 125 | + const pHex = rgbStringToHex(p) || (isHexColor(p) ? p : null); |
| 126 | + if (!pHex) return; |
| 127 | + const aHex = lightenHex(pHex, 0.35) || pHex; |
| 128 | + applyColors(pHex, aHex); |
| 129 | + } |
| 130 | + |
123 | 131 | function createHeaderButton() { |
124 | 132 | const btn = document.createElement("button"); |
125 | 133 | btn.type = "button"; |
|
166 | 174 | const p = getCssVar("--md-primary-fg-color"); |
167 | 175 | const a = getCssVar("--md-accent-fg-color"); |
168 | 176 | const pHex = rgbStringToHex(p) || (isHexColor(p) ? p : null); |
169 | | - const aHex = rgbStringToHex(a) || (isHexColor(a) ? a : null); |
| 177 | + let aHex = rgbStringToHex(a) || (isHexColor(a) ? a : null); |
| 178 | + |
| 179 | + if (pHex && (!aHex || aHex.toUpperCase() === pHex.toUpperCase())) aHex = lightenHex(pHex, 0.35) || pHex; |
| 180 | + |
170 | 181 | if (pHex) primaryInput.value = pHex; |
171 | 182 | if (aHex) accentInput.value = aHex; |
172 | 183 | } |
|
239 | 250 | accentText.textContent = "强调色"; |
240 | 251 | const accentInput = document.createElement("input"); |
241 | 252 | accentInput.type = "color"; |
242 | | - accentInput.value = "#EFB8C8"; |
| 253 | + accentInput.value = "#9C8DC4"; |
243 | 254 | accentWrap.appendChild(accentText); |
244 | 255 | accentWrap.appendChild(accentInput); |
245 | 256 |
|
|
317 | 328 | }); |
318 | 329 |
|
319 | 330 | resetBtn.addEventListener("click", () => { |
320 | | - clearStyleTag(); |
| 331 | + applyDefaultAccentFromPrimary(); |
321 | 332 | requestAnimationFrame(() => { |
322 | 333 | syncInputsToComputed(primaryInput, accentInput); |
323 | 334 | }); |
|
327 | 338 | } |
328 | 339 |
|
329 | 340 | function mount() { |
| 341 | + applyDefaultAccentFromPrimary(); |
330 | 342 | if (document.querySelector(".theme-palette-overlay")) return; |
331 | 343 | const { overlay, open } = createDialog(); |
332 | 344 | document.body.appendChild(overlay); |
|
0 commit comments