mirror of
https://github.com/baptisteArno/typebot.io.git
synced 2026-06-19 21:04:33 +08:00
🚸 Save sidebar locked state in local storage (#1956)
Closes #1933 --------- Co-authored-by: Baptiste Arnaud <contact@baptiste-arnaud.fr> Co-authored-by: Baptiste Arnaud <baptiste.arnaud95@gmail.com>
This commit is contained in:
parent
5ceaa961a1
commit
d4d922dbf0
@ -25,7 +25,7 @@ import { isDefined } from "@typebot.io/lib/utils";
|
||||
import type React from "react";
|
||||
import { useState } from "react";
|
||||
import { useDebouncedCallback } from "use-debounce";
|
||||
import { headerHeight } from "../constants";
|
||||
import { headerHeight, leftSidebarLockedStorageKey } from "../constants";
|
||||
import { BlockCard } from "./BlockCard";
|
||||
import { BlockCardOverlay } from "./BlockCardOverlay";
|
||||
import {
|
||||
@ -49,8 +49,12 @@ export const BlocksSideBar = () => {
|
||||
x: 0,
|
||||
y: 0,
|
||||
});
|
||||
const [isLocked, setIsLocked] = useState(true);
|
||||
const [isExtended, setIsExtended] = useState(true);
|
||||
const [isLocked, setIsLocked] = useState(
|
||||
localStorage.getItem(leftSidebarLockedStorageKey) === "true",
|
||||
);
|
||||
const [isExtended, setIsExtended] = useState(
|
||||
localStorage.getItem(leftSidebarLockedStorageKey) === "true",
|
||||
);
|
||||
const [searchInput, setSearchInput] = useState("");
|
||||
|
||||
const closeSideBar = useDebouncedCallback(() => setIsExtended(false), 200);
|
||||
@ -86,7 +90,14 @@ export const BlocksSideBar = () => {
|
||||
};
|
||||
useEventListener("mouseup", handleMouseUp);
|
||||
|
||||
const handleLockClick = () => setIsLocked(!isLocked);
|
||||
const handleLockClick = () => {
|
||||
try {
|
||||
localStorage.setItem(leftSidebarLockedStorageKey, String(!isLocked));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
setIsLocked(!isLocked);
|
||||
};
|
||||
|
||||
const handleDockBarEnter = () => {
|
||||
closeSideBar.flush();
|
||||
|
||||
@ -1 +1,3 @@
|
||||
export const headerHeight = 56;
|
||||
|
||||
export const leftSidebarLockedStorageKey = "isLeftSidebarLocked";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user