Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: add persistent cookie sidebar
Marc Seitzdad16bbaf652
diff --git a/components/ui/sidebar.tsx b/components/ui/sidebar.tsxindex 5834dca9..a72ea6cc 100644--- a/components/ui/sidebar.tsx+++ b/components/ui/sidebar.tsx@@ -70,9 +70,22 @@ const SidebarProvider = React.forwardRef<const isMobile = useIsMobile();const [openMobile, setOpenMobile] = React.useState(false);+ // Read initial state from cookie+ const initialState = React.useMemo(() => {+ if (typeof window === "undefined") return defaultOpen;+ const cookie = document.cookie+ .split("; ")+ .find((row) => row.startsWith(SIDEBAR_COOKIE_NAME));+ if (cookie) {+ const value = cookie.split("=")[1];+ return value === "true";+ }+ return defaultOpen;+ }, [defaultOpen]);+// This is the internal state of the sidebar.// We use openProp and setOpenProp for control from outside the component.- const [_open, _setOpen] = React.useState(defaultOpen);+ const [_open, _setOpen] = React.useState(initialState);const open = openProp ?? _open;const setOpen = React.useCallback((value: boolean | ((value: boolean) => boolean)) => {