feat: resizable sidebar (#452)

* feat: resizable sidebar

* only expand space sidebar
This commit is contained in:
Philip Okugbe
2024-11-01 10:05:03 +00:00
committed by GitHub
parent e064e58f79
commit b85b34d6b1
4 changed files with 65 additions and 6 deletions

View File

@ -2,9 +2,9 @@ import { atom } from "jotai";
export function atomWithWebStorage<Value>(key: string, initialValue: Value, storage = localStorage) {
const storedValue = localStorage.getItem(key);
const isString = typeof initialValue === "string";
const isStringOrInt = typeof initialValue === "string" || typeof initialValue === "number";
const storageValue = storedValue ? isString ? storedValue : storedValue === "true" : undefined;
const storageValue = storedValue ? isStringOrInt ? storedValue : storedValue === "true" : undefined;
const baseAtom = atom(storageValue ?? initialValue);
return atom(