fix(webui): hide sidebar pin controls in menu mode
Keep sidebar pinning available in desktop navigation and hide its controls when navigation uses the menu. Fixes #485
This commit is contained in:
4 files changed
+18
-10
No files matched your search
@@ -6,7 +6,7 @@ import { Sheet, SheetContent, SheetDescription, SheetTitle } from '@/components/
|
|||||||
import { ScrollArea } from '@/components/ui/scroll-area';
|
import { ScrollArea } from '@/components/ui/scroll-area';
|
||||||
import { Sidebar } from '@/components/layout/sidebar';
|
import { Sidebar } from '@/components/layout/sidebar';
|
||||||
import { TopBar } from '@/components/layout/top-bar';
|
import { TopBar } from '@/components/layout/top-bar';
|
||||||
import { useFinePointer, useMediaQuery } from '@/hooks/use-media-query';
|
import { useDesktopSidebar } from '@/hooks/use-media-query';
|
||||||
import { useTheme } from '@/contexts/ThemeContext';
|
import { useTheme } from '@/contexts/ThemeContext';
|
||||||
import { useLayout } from '@/contexts/LayoutContext';
|
import { useLayout } from '@/contexts/LayoutContext';
|
||||||
import { useKiosk } from '@/contexts/KioskContext';
|
import { useKiosk } from '@/contexts/KioskContext';
|
||||||
@@ -20,9 +20,7 @@ interface MainLayoutProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function MainLayout({ status, onLogout, notice, children }: MainLayoutProps) {
|
export function MainLayout({ status, onLogout, notice, children }: MainLayoutProps) {
|
||||||
const isWide = useMediaQuery('(min-width: 768px)');
|
const isMobile = !useDesktopSidebar();
|
||||||
const canHover = useFinePointer();
|
|
||||||
const isMobile = !isWide || !canHover;
|
|
||||||
const { appearance } = useTheme();
|
const { appearance } = useTheme();
|
||||||
const customBg = appearance.background.type !== 'none';
|
const customBg = appearance.background.type !== 'none';
|
||||||
// Framer's reducedMotion only suppresses transforms, so the always-present
|
// Framer's reducedMotion only suppresses transforms, so the always-present
|
||||||
@@ -55,7 +53,7 @@ export function MainLayout({ status, onLogout, notice, children }: MainLayoutPro
|
|||||||
initial={false}
|
initial={false}
|
||||||
animate={{ width: showCollapsed ? 64 : 248 }}
|
animate={{ width: showCollapsed ? 64 : 248 }}
|
||||||
transition={reduce ? { duration: 0 } : { duration: 0.26, ease: [0.4, 0, 0.1, 1] }}
|
transition={reduce ? { duration: 0 } : { duration: 0.26, ease: [0.4, 0, 0.1, 1] }}
|
||||||
onMouseEnter={() => { if (canHover) setHovered(true); }}
|
onMouseEnter={() => setHovered(true)}
|
||||||
onMouseLeave={() => setHovered(false)}
|
onMouseLeave={() => setHovered(false)}
|
||||||
onFocusCapture={(e) => {
|
onFocusCapture={(e) => {
|
||||||
// Only *keyboard* focus (focus-visible) peeks the rail open. A mouse
|
// Only *keyboard* focus (focus-visible) peeks the rail open. A mouse
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { APP_NAME, APP_VERSION } from '@/types';
|
|||||||
import { useAppState } from '@/contexts/AppStateContext';
|
import { useAppState } from '@/contexts/AppStateContext';
|
||||||
import { useTheme } from '@/contexts/ThemeContext';
|
import { useTheme } from '@/contexts/ThemeContext';
|
||||||
import { reconcileLayoutItems, useLayout } from '@/contexts/LayoutContext';
|
import { reconcileLayoutItems, useLayout } from '@/contexts/LayoutContext';
|
||||||
import { useMediaQuery } from '@/hooks/use-media-query';
|
import { useDesktopSidebar } from '@/hooks/use-media-query';
|
||||||
import type { AppPath } from '@/router';
|
import type { AppPath } from '@/router';
|
||||||
import type { UiLayoutItem } from '@/types';
|
import type { UiLayoutItem } from '@/types';
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ export function Sidebar({ collapsed = false, onItemClick }: SidebarProps) {
|
|||||||
const { updateInfo } = useAppState();
|
const { updateInfo } = useAppState();
|
||||||
const { navItems, setNavItems, editing, setEditing } = useLayout();
|
const { navItems, setNavItems, editing, setEditing } = useLayout();
|
||||||
const { appearance, setAppearance } = useTheme();
|
const { appearance, setAppearance } = useTheme();
|
||||||
const isDesktop = useMediaQuery('(min-width: 768px)');
|
const isDesktop = useDesktopSidebar();
|
||||||
const pinned = appearance.sidebarPinned;
|
const pinned = appearance.sidebarPinned;
|
||||||
|
|
||||||
// Full reconciled nav (incl. hidden) — pinned forced visible, forward-compat.
|
// Full reconciled nav (incl. hidden) — pinned forced visible, forward-compat.
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import {
|
|||||||
import { DEFAULT_LAYOUT, DEFAULT_PAGES, reconcileLayoutItems, useLayout } from '@/contexts/LayoutContext';
|
import { DEFAULT_LAYOUT, DEFAULT_PAGES, reconcileLayoutItems, useLayout } from '@/contexts/LayoutContext';
|
||||||
import { useActionFeedback } from '@/contexts/ActionFeedbackContext';
|
import { useActionFeedback } from '@/contexts/ActionFeedbackContext';
|
||||||
import { useSession } from '@/contexts/SessionContext';
|
import { useSession } from '@/contexts/SessionContext';
|
||||||
|
import { useDesktopSidebar } from '@/hooks/use-media-query';
|
||||||
import { NAV_ITEMS } from '@/components/layout/sidebar';
|
import { NAV_ITEMS } from '@/components/layout/sidebar';
|
||||||
import { TOPBAR_CATALOGUE } from '@/components/layout/top-bar';
|
import { TOPBAR_CATALOGUE } from '@/components/layout/top-bar';
|
||||||
import { TotpPanel } from '@/components/settings/totp-panel';
|
import { TotpPanel } from '@/components/settings/totp-panel';
|
||||||
@@ -375,6 +376,7 @@ function TopbarPanel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function AppearancePanel() {
|
function AppearancePanel() {
|
||||||
|
const isDesktop = useDesktopSidebar();
|
||||||
const { appearance, setAppearance, uploadBackground, removeBackground, resolved } = useTheme();
|
const { appearance, setAppearance, uploadBackground, removeBackground, resolved } = useTheme();
|
||||||
const a = appearance;
|
const a = appearance;
|
||||||
// A Catppuccin flavor fixes its own light/dark + darkness, so the mode and
|
// A Catppuccin flavor fixes its own light/dark + darkness, so the mode and
|
||||||
@@ -566,9 +568,11 @@ function AppearancePanel() {
|
|||||||
<SettingRow label="高对比模式" hint="加强边框与次要文字的对比度。" layout="inline">
|
<SettingRow label="高对比模式" hint="加强边框与次要文字的对比度。" layout="inline">
|
||||||
<ToggleSwitch value={a.highContrast} onChange={(highContrast) => setAppearance({ highContrast })} ariaLabel="高对比模式" />
|
<ToggleSwitch value={a.highContrast} onChange={(highContrast) => setAppearance({ highContrast })} ariaLabel="高对比模式" />
|
||||||
</SettingRow>
|
</SettingRow>
|
||||||
<SettingRow label="钉住侧栏展开" hint="侧栏常驻展开,不再收成图标轨、也不随悬停自动收起。" layout="inline">
|
{isDesktop && (
|
||||||
<ToggleSwitch value={a.sidebarPinned} onChange={(sidebarPinned) => setAppearance({ sidebarPinned })} ariaLabel="钉住侧栏展开" />
|
<SettingRow label="钉住侧栏展开" hint="侧栏常驻展开,不再收成图标轨、也不随悬停自动收起。" layout="inline">
|
||||||
</SettingRow>
|
<ToggleSwitch value={a.sidebarPinned} onChange={(sidebarPinned) => setAppearance({ sidebarPinned })} ariaLabel="钉住侧栏展开" />
|
||||||
|
</SettingRow>
|
||||||
|
)}
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
|
|||||||
@@ -21,3 +21,9 @@ export function useMediaQuery(query: string): boolean {
|
|||||||
export function useFinePointer(): boolean {
|
export function useFinePointer(): boolean {
|
||||||
return useMediaQuery(FINE_POINTER_QUERY);
|
return useMediaQuery(FINE_POINTER_QUERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useDesktopSidebar(): boolean {
|
||||||
|
const isWide = useMediaQuery('(min-width: 768px)');
|
||||||
|
const canHover = useFinePointer();
|
||||||
|
return isWide && canHover;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user