Files
lucide/docs/.vitepress/theme/iconStyleHead.js
T
Eric FennisandCopilot Autofix powered by AI ccb4b193d2 fix(site): Fix reset button and rename absolute stroke width to non-scaling stroke (#4956)
* Fix reset button and rename absolute stroke width

* Adjust props

* Adjust icon preview

* Rename switch ID for non-scaling stroke

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-10-06 09:48:14 +02:00

25 lines
1.1 KiB
JavaScript

// Run before the body is painted: the generated HTML cannot know local preferences.
(() => {
try {
const root = globalThis.document.documentElement;
const size = globalThis.localStorage.getItem('icon-size');
const stroke = globalThis.localStorage.getItem('icon-stroke-width');
const color = globalThis.localStorage.getItem('icon-color');
const nonScaling = globalThis.localStorage.getItem('icon-non-scaling-stroke');
if ([size, stroke, color, nonScaling].every((value) => value === null)) return;
if (size !== null && Number.isFinite(Number(size))) {
root.style.setProperty('--customize-size', String(Math.min(256, Math.max(16, Number(size)))));
}
if (stroke !== null && Number.isFinite(Number(stroke)))
root.style.setProperty(
'--customize-strokeWidth',
String(Math.min(3, Math.max(0.5, Number(stroke)))),
);
if (color !== null && globalThis.CSS.supports('color', color))
root.style.setProperty('--customize-color', color);
root.classList.toggle('non-scaling-stroke', nonScaling === 'true');
} catch {
// Storage can be unavailable, for example in private browsing mode.
}
})();