From bba9b82ce95748b98bb1d6536846a9c9a8a47c94 Mon Sep 17 00:00:00 2001 From: DrSmoothl <1787882683@qq.com> Date: Sat, 20 Jun 2026 23:30:08 +0800 Subject: [PATCH] feat(webui): hover-expand sidebar rail + borderless nested-canvas chrome MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reshape the desktop shell to feel less "boxed-in", keeping the original visual design — boundaries now read via depth/tone, not hard borders. - Sidebar rests as a 64px icon rail and auto-expands on hover (or keyboard focus-visible), pushing the content rather than overlaying it. Removes the explicit collapse button; resting state is the rail (`effectiveCollapsed = !editing`), so it always auto-collapses on mouse-leave. - Drop hard region borders: sidebar border-r and topbar border-b/divider are gone; the rail blends into a sidebar-toned chrome. - Sidebar internal cleanup: brand border, the footer Separator, the update card / edit-item / 完成 button borders removed; active nav indicator is now a soft pill + sliding 2px primary left bar (layoutId). - Content is a nested canvas with a rounded top-left corner at the sidebar/topbar junction, lifted via a soft shadow; the corner slides with the rail since the canvas is its flex sibling. Note: the 「侧栏默认折叠」 appearance toggle (settings-page) is now inert for the main nav sidebar — to be repurposed as "pin open" or removed in a follow-up. --- .../src/components/layout/main-layout.tsx | 67 ++++++++++++------- .../webui/src/components/layout/sidebar.tsx | 27 +++++--- .../webui/src/components/layout/top-bar.tsx | 30 ++------- 3 files changed, 63 insertions(+), 61 deletions(-) diff --git a/packages/webui/src/components/layout/main-layout.tsx b/packages/webui/src/components/layout/main-layout.tsx index 30dfe59e..42e5cceb 100644 --- a/packages/webui/src/components/layout/main-layout.tsx +++ b/packages/webui/src/components/layout/main-layout.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState, type ReactNode } from 'react'; +import { useState, type ReactNode } from 'react'; import { motion, AnimatePresence } from 'motion/react'; import { useRouterState } from '@tanstack/react-router'; import { Minimize2 } from 'lucide-react'; @@ -21,14 +21,6 @@ interface MainLayoutProps { export function MainLayout({ status, onLogout, children }: MainLayoutProps) { const isMobile = !useMediaQuery('(min-width: 768px)'); const { appearance } = useTheme(); - const [collapsed, setCollapsed] = useState(() => { - // An explicit per-browser toggle wins; otherwise fall back to the - // operator's `sidebarDefaultCollapsed` appearance preference. - const explicit = localStorage.getItem('snowluma_sidebar_collapsed'); - if (explicit === '1') return true; - if (explicit === '0') return false; - return appearance.sidebarDefaultCollapsed; - }); const customBg = appearance.background.type !== 'none'; // Framer's reducedMotion only suppresses transforms, so the always-present // width + page-transition animations need an explicit opt-out to make the @@ -36,27 +28,44 @@ export function MainLayout({ status, onLogout, children }: MainLayoutProps) { const reduce = appearance.reduceMotion || appearance.disableMotion; const { editing } = useLayout(); const { kiosk, exit: exitKiosk } = useKiosk(); - // Force the sidebar open while editing layout so its drag-to-reorder list - // has room (it returns to the user's collapsed pref on 完成). - const effectiveCollapsed = collapsed && !editing; + // The sidebar rests as a slim icon rail and auto-expands on hover/focus (the + // peek logic below) — there's no collapse button. Layout-edit mode force- + // expands it so the drag-to-reorder list has room. + const effectiveCollapsed = !editing; + // Hover/focus peek: while collapsed, hovering (or keyboard-focusing) the rail + // temporarily expands it. The rail lives in the flex flow, so the page + // content is pushed right rather than overlaid. The pinned `collapsed` pref + // (and the TopBar toggle that reflects it) is untouched — this is transient. + const [hovered, setHovered] = useState(false); + const [focused, setFocused] = useState(false); + const peeking = hovered || focused; + const showCollapsed = effectiveCollapsed && !peeking; const [mobileOpen, setMobileOpen] = useState(false); const pathname = useRouterState({ select: (s) => s.location.pathname }); - useEffect(() => { - localStorage.setItem('snowluma_sidebar_collapsed', collapsed ? '1' : '0'); - }, [collapsed]); - return ( -