mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-29 09:09:58 -07:00
changelog: updated
This commit is contained in:
@@ -198,19 +198,20 @@ onFirstIntersection(navElement, () => {
|
||||
function initResizeBar() {
|
||||
const bar = getElementById("resize-bar");
|
||||
const key = "bar-width";
|
||||
const root = document.documentElement;
|
||||
const max = () => parseFloat(style.getPropertyValue("--max-main-width")) / 100 * window.innerWidth;
|
||||
|
||||
const saved = readStored(key);
|
||||
if (saved) mainElement.style.width = `${saved}px`;
|
||||
if (saved) root.style.setProperty("--sidebar-width", `${saved}px`);
|
||||
|
||||
/** @param {number | null} width */
|
||||
function setWidth(width) {
|
||||
if (width != null) {
|
||||
const clamped = Math.min(width, max());
|
||||
mainElement.style.width = `${clamped}px`;
|
||||
root.style.setProperty("--sidebar-width", `${clamped}px`);
|
||||
writeToStorage(key, String(clamped));
|
||||
} else {
|
||||
mainElement.style.width = "";
|
||||
root.style.removeProperty("--sidebar-width");
|
||||
removeStored(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,12 @@ export function onChange(callback) {
|
||||
function setDark(value) {
|
||||
if (dark === value) return;
|
||||
dark = value;
|
||||
apply(value);
|
||||
callbacks.forEach((cb) => cb());
|
||||
const swap = () => {
|
||||
apply(value);
|
||||
callbacks.forEach((cb) => cb());
|
||||
};
|
||||
if (document.startViewTransition) document.startViewTransition(swap);
|
||||
else swap();
|
||||
}
|
||||
|
||||
/** @param {boolean} isDark */
|
||||
|
||||
Reference in New Issue
Block a user