From db9a4a46b79d7aa87107b813a9fcee6fd73162f6 Mon Sep 17 00:00:00 2001 From: Roger Deng <13251150+rogerdigital@users.noreply.github.com> Date: Tue, 14 Apr 2026 12:21:36 +0800 Subject: [PATCH 1/4] feat(layout): add sidebar collapse toggle with localStorage persistence --- .../components/layout/ConsoleChrome.css.ts | 36 +++++++++++ .../src/components/layout/ConsoleChrome.tsx | 62 ++++++++++++++----- 2 files changed, 84 insertions(+), 14 deletions(-) diff --git a/apps/web/src/components/layout/ConsoleChrome.css.ts b/apps/web/src/components/layout/ConsoleChrome.css.ts index 3237622..8596dd6 100644 --- a/apps/web/src/components/layout/ConsoleChrome.css.ts +++ b/apps/web/src/components/layout/ConsoleChrome.css.ts @@ -11,6 +11,11 @@ export const appShell = style({ minHeight: '100vh', gap: 0, padding: 0, + transition: 'grid-template-columns 0.25s ease', +}); + +export const appShellCollapsed = style({ + gridTemplateColumns: '60px 1fr', }); globalStyle(`${appShell}::before`, { @@ -86,6 +91,37 @@ globalStyle(`${sidebar}::before`, { pointerEvents: 'none', }); +export const sidebarCollapsed = style({ + width: '60px', + padding: '24px 10px', + alignItems: 'center', +}); + +export const sidebarToggle = style({ + position: 'absolute', + top: '24px', + right: '-13px', + zIndex: 10, + width: '26px', + height: '26px', + borderRadius: '50%', + border: '1px solid var(--line-strong)', + background: 'var(--panel-2)', + color: 'var(--muted)', + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + cursor: 'pointer', + fontSize: '12px', + transition: 'border-color 160ms ease, color 160ms ease, background 160ms ease', + flexShrink: 0, + ':hover': { + borderColor: 'var(--accent-live)', + color: 'var(--accent-live)', + background: 'rgba(0, 212, 255, 0.08)', + }, +}); + export const brand = style({ display: 'flex', gap: '12px', diff --git a/apps/web/src/components/layout/ConsoleChrome.tsx b/apps/web/src/components/layout/ConsoleChrome.tsx index 8d859b4..04be061 100644 --- a/apps/web/src/components/layout/ConsoleChrome.tsx +++ b/apps/web/src/components/layout/ConsoleChrome.tsx @@ -17,6 +17,7 @@ import { import { useTradingSystem } from '../../store/trading-system/TradingSystemProvider.tsx'; import { appShell, + appShellCollapsed, brand, brandMark, brandName, @@ -30,7 +31,9 @@ import { navStack, sidebar, sidebarBlock, + sidebarCollapsed, sidebarLabel, + sidebarToggle, toolbarActions, toolbarCopy, toolbarKicker, @@ -275,30 +278,50 @@ export function TopMeta({ items }: { items: TopMetaItem[] }) { ); } -function Sidebar() { +function Sidebar({ collapsed, onToggle }: { collapsed: boolean; onToggle: () => void }) { const { locale } = useLocale(); const routes = listSidebarRoutes(); return ( -