mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-12-03 16:59:42 +00:00
* 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>
25 lines
1.1 KiB
JavaScript
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.
|
|
}
|
|
})();
|