From 12f8d8542cade05fb18f10eaab63cb9ad8b4304f Mon Sep 17 00:00:00 2001 From: hypercross Date: Sun, 13 Sep 2026 14:09:18 +0800 Subject: [PATCH] feat(ui): make desktop sidebar collapsible Add a header toggle and a panel close button so the desktop file sidebar collapses with a width transition, mirroring the journal panel. - split onClose (close button) from onNavigate (file selection) so clicking a file no longer collapses the sidebar on desktop - give the aside h-full so the file tree and outline keep bounded scroll regions inside the new wrapper - swap the aside shadow for a gray right border to match the journal --- src/App.tsx | 39 +++++++++++++++++++++++++++++++------- src/components/Sidebar.tsx | 27 +++++++++++++------------- 2 files changed, 45 insertions(+), 21 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index c506610..ff4a532 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -11,6 +11,8 @@ import { TbOutlineMenu2, TbOutlineClipboardList, TbOutlineHelpCircle, + TbOutlineLayoutSidebarLeftCollapse, + TbOutlineLayoutSidebarLeftExpand, } from "solid-icons/tb"; import { useJournalStream } from "./components/stores/journalStream"; @@ -51,6 +53,7 @@ const App: Component = () => { const location = useLocation(); const stream = useJournalStream(); const [isSidebarOpen, setIsSidebarOpen] = createSignal(false); + const [isDesktopSidebarOpen, setIsDesktopSidebarOpen] = createSignal(true); const [isDocOpen, setIsDocOpen] = createSignal(false); const [isDataSourceOpen, setIsDataSourceOpen] = createSignal(false); const [isJournalOpen, setIsJournalOpen] = createSignal(false); @@ -98,7 +101,7 @@ const App: Component = () => { {/* Header */}
- {/* 仅在移动端显示菜单按钮 */} + {/* 移动端:打开抽屉式侧边栏 */} + {/* 桌面端:折叠/展开固定侧边栏 */} +

Tabletop Toolkit

- - - +
@@ -84,7 +82,7 @@ const SidebarContent: Component = (props) => { currentPath={props.currentPath} pathHeadings={props.pathHeadings} depth={0} - onClose={props.onClose} + onClose={() => props.onNavigate?.()} isHidden={isFileHidden} /> ))} @@ -151,6 +149,7 @@ export const MobileSidebar: Component = (props) => { pathHeadings={pathHeadings()} currentPath={location.pathname} onClose={props.onClose} + onNavigate={props.onClose} onDataSourceOpen={props.onDataSourceOpen} /> @@ -164,6 +163,7 @@ export const MobileSidebar: Component = (props) => { export const DesktopSidebar: Component<{ fileTree?: FileNode[]; pathHeadings?: Record; + onClose: () => void; onDataSourceOpen?: () => void; }> = (props) => { const location = useLocation(); @@ -183,13 +183,12 @@ export const DesktopSidebar: Component<{ }); return ( -