From a47a480aa29dcb22e1da603ae6499ca0f8a27199 Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Wed, 11 Feb 2026 23:29:26 +0800 Subject: [PATCH] fix(layout): persistent location for the sidebar toggle, closes #3193 (#3269) --- .../app/library/components/LibraryHeader.tsx | 4 +++- .../src/app/reader/components/BooksGrid.tsx | 4 +++- .../src/app/reader/components/HeaderBar.tsx | 21 +++++++++++++++---- .../app/reader/components/ReaderContent.tsx | 8 +++++-- .../app/reader/components/SidebarToggler.tsx | 3 --- .../app/reader/components/sidebar/Header.tsx | 16 ++++++-------- .../app/reader/components/sidebar/SideBar.tsx | 6 ++---- apps/readest-app/src/hooks/useTrafficLight.ts | 2 +- 8 files changed, 38 insertions(+), 26 deletions(-) diff --git a/apps/readest-app/src/app/library/components/LibraryHeader.tsx b/apps/readest-app/src/app/library/components/LibraryHeader.tsx index 4e7c06c1..930f867f 100644 --- a/apps/readest-app/src/app/library/components/LibraryHeader.tsx +++ b/apps/readest-app/src/app/library/components/LibraryHeader.tsx @@ -103,7 +103,9 @@ const LibraryHeader: React.FC = ({ style={{ marginTop: appService?.hasSafeAreaInset ? `max(${insets.top}px, ${systemUIVisible ? statusBarHeight : 0}px)` - : '0px', + : appService?.hasTrafficLight + ? '-2px' + : '0px', }} >
diff --git a/apps/readest-app/src/app/reader/components/BooksGrid.tsx b/apps/readest-app/src/app/reader/components/BooksGrid.tsx index 8f7c4b0b..c7d41340 100644 --- a/apps/readest-app/src/app/reader/components/BooksGrid.tsx +++ b/apps/readest-app/src/app/reader/components/BooksGrid.tsx @@ -27,9 +27,10 @@ import DoubleBorder from './DoubleBorder'; interface BooksGridProps { bookKeys: string[]; onCloseBook: (bookKey: string) => void; + onGoToLibrary: () => void; } -const BooksGrid: React.FC = ({ bookKeys, onCloseBook }) => { +const BooksGrid: React.FC = ({ bookKeys, onCloseBook, onGoToLibrary }) => { const _ = useTranslation(); const { appService } = useEnv(); const { getConfig, getBookData } = useBookDataStore(); @@ -124,6 +125,7 @@ const BooksGrid: React.FC = ({ bookKeys, onCloseBook }) => { isTopLeft={index === 0} isHoveredAnim={bookKeys.length > 2} onCloseBook={onCloseBook} + onGoToLibrary={onGoToLibrary} gridInsets={gridInsets} onDropdownOpenChange={(isOpen) => setDropdownOpenBook(isOpen ? bookKey : '')} /> diff --git a/apps/readest-app/src/app/reader/components/HeaderBar.tsx b/apps/readest-app/src/app/reader/components/HeaderBar.tsx index 22f54546..fd153303 100644 --- a/apps/readest-app/src/app/reader/components/HeaderBar.tsx +++ b/apps/readest-app/src/app/reader/components/HeaderBar.tsx @@ -1,6 +1,7 @@ import clsx from 'clsx'; import React, { useCallback, useEffect, useRef, useState } from 'react'; import { PiDotsThreeVerticalBold } from 'react-icons/pi'; +import { VscLibrary } from 'react-icons/vsc'; import { Insets } from '@/types/misc'; import { useEnv } from '@/context/EnvContext'; @@ -34,6 +35,7 @@ interface HeaderBarProps { isHoveredAnim: boolean; gridInsets: Insets; onCloseBook: (bookKey: string) => void; + onGoToLibrary: () => void; onDropdownOpenChange?: (isOpen: boolean) => void; } @@ -44,6 +46,7 @@ const HeaderBar: React.FC = ({ isHoveredAnim, gridInsets, onCloseBook, + onGoToLibrary, onDropdownOpenChange, }) => { const _ = useTranslation(); @@ -60,6 +63,7 @@ const HeaderBar: React.FC = ({ const [isDropdownOpen, setIsDropdownOpen] = useState(false); const view = getView(bookKey); const iconSize16 = useResponsiveSize(16); + const iconSize18 = useResponsiveSize(18); const headerRef = useRef(null); const windowButtonVisible = appService?.hasWindowBar && !isTrafficLightVisible; @@ -147,7 +151,7 @@ const HeaderBar: React.FC = ({ className={clsx( `header-bar bg-base-100 absolute top-0 z-10 flex h-11 w-full items-center pr-4`, `shadow-xs transition-[opacity,margin-top] duration-300`, - trafficLightInHeader ? 'pl-20' : 'pl-4', + trafficLightInHeader ? 'pl-20' : isSideBarVisible ? 'ps-4' : 'ps-4 sm:ps-1.5', appService?.hasRoundedWindow && 'rounded-window-top-right', !isSideBarVisible && appService?.hasRoundedWindow && 'rounded-window-top-left', isHoveredAnim && 'hover-bar-anim', @@ -167,9 +171,18 @@ const HeaderBar: React.FC = ({ }} >
-
- -
+ {!isSideBarVisible && ( +
+ +
+ )} + {enableAnnotationQuickActions && ( diff --git a/apps/readest-app/src/app/reader/components/ReaderContent.tsx b/apps/readest-app/src/app/reader/components/ReaderContent.tsx index a27b9620..bcebc172 100644 --- a/apps/readest-app/src/app/reader/components/ReaderContent.tsx +++ b/apps/readest-app/src/app/reader/components/ReaderContent.tsx @@ -224,8 +224,12 @@ const ReaderContent: React.FC<{ ids?: string; settings: SystemSettings }> = ({ i return (
- - + + {isSettingsDialogOpen && } {showDetailsBook && ( diff --git a/apps/readest-app/src/app/reader/components/SidebarToggler.tsx b/apps/readest-app/src/app/reader/components/SidebarToggler.tsx index 439da573..98a3b2a8 100644 --- a/apps/readest-app/src/app/reader/components/SidebarToggler.tsx +++ b/apps/readest-app/src/app/reader/components/SidebarToggler.tsx @@ -1,7 +1,6 @@ import React from 'react'; import { TbLayoutSidebar, TbLayoutSidebarFilled } from 'react-icons/tb'; -import { useReaderStore } from '@/store/readerStore'; import { useSidebarStore } from '@/store/sidebarStore'; import { useTranslation } from '@/hooks/useTranslation'; import Button from '@/components/Button'; @@ -13,7 +12,6 @@ interface SidebarTogglerProps { const SidebarToggler: React.FC = ({ bookKey }) => { const _ = useTranslation(); const { sideBarBookKey, isSideBarVisible, setSideBarBookKey, toggleSideBar } = useSidebarStore(); - const { setHoveredBookKey } = useReaderStore(); const handleToggleSidebar = () => { if (sideBarBookKey === bookKey) { toggleSideBar(); @@ -21,7 +19,6 @@ const SidebarToggler: React.FC = ({ bookKey }) => { setSideBarBookKey(bookKey); if (!isSideBarVisible) toggleSideBar(); } - setHoveredBookKey(''); }; return ( - +
+ +
)} setSideBarVisible(false)} onTogglePin={handleSideBarTogglePin} onToggleSearchBar={handleToggleSearchBar} diff --git a/apps/readest-app/src/hooks/useTrafficLight.ts b/apps/readest-app/src/hooks/useTrafficLight.ts index 9c1203b9..525b45a7 100644 --- a/apps/readest-app/src/hooks/useTrafficLight.ts +++ b/apps/readest-app/src/hooks/useTrafficLight.ts @@ -18,7 +18,7 @@ export const useTrafficLight = () => { initializeTrafficLightStore(appService); initializeTrafficLightListeners(); - setTrafficLightVisibility(true); + setTrafficLightVisibility(true, { x: 10, y: 20 }); return () => { cleanupTrafficLightListeners(); };