From 23fa884af75860bdb4bbcf77a3d5791071fd20b8 Mon Sep 17 00:00:00 2001 From: Julien Froidefond Date: Wed, 4 Mar 2026 06:49:40 +0100 Subject: [PATCH] fix: restore reader direction and double-page navigation UI --- src/components/reader/PhotoswipeReader.tsx | 2 +- .../reader/components/ControlButtons.tsx | 4 +- .../reader/components/PageDisplay.tsx | 58 +++++++++++++------ 3 files changed, 43 insertions(+), 21 deletions(-) diff --git a/src/components/reader/PhotoswipeReader.tsx b/src/components/reader/PhotoswipeReader.tsx index ebd1a3f..88302cf 100644 --- a/src/components/reader/PhotoswipeReader.tsx +++ b/src/components/reader/PhotoswipeReader.tsx @@ -1,4 +1,3 @@ - "use client"; import { useEffect, useState, useCallback, useRef } from "react"; @@ -218,6 +217,7 @@ export function PhotoswipeReader({ book, pages, onClose, nextBook }: BookReaderP shouldShowDoublePage={(page) => shouldShowDoublePage(page, pages.length)} imageBlobUrls={imageBlobUrls} getPageUrl={getPageUrl} + isRTL={isRTL} /> @@ -199,7 +199,7 @@ export const ControlButtons = ({ iconClassName="h-8 w-8" className={cn( "absolute top-1/2 z-20 -translate-y-1/2 rounded-full border border-border/60 bg-background/55 shadow-[0_8px_24px_-16px_rgba(0,0,0,0.75)] backdrop-blur-xl transition-all duration-300 hover:bg-background/70", - direction === "rtl" ? "left-4" : "right-4", + "right-4", showControls ? "opacity-100" : "opacity-0 pointer-events-none" )} /> diff --git a/src/components/reader/components/PageDisplay.tsx b/src/components/reader/components/PageDisplay.tsx index 844dda6..e366c9b 100644 --- a/src/components/reader/components/PageDisplay.tsx +++ b/src/components/reader/components/PageDisplay.tsx @@ -1,6 +1,5 @@ import { useState, useCallback, useEffect } from "react"; import { cn } from "@/lib/utils"; -import { useReadingDirection } from "../hooks/useReadingDirection"; interface PageDisplayProps { currentPage: number; @@ -9,6 +8,7 @@ interface PageDisplayProps { shouldShowDoublePage: (page: number) => boolean; imageBlobUrls: Record; getPageUrl: (pageNum: number) => string; + isRTL: boolean; } export function PageDisplay({ @@ -18,12 +18,12 @@ export function PageDisplay({ shouldShowDoublePage, imageBlobUrls, getPageUrl, + isRTL, }: PageDisplayProps) { const [isLoading, setIsLoading] = useState(true); const [hasError, setHasError] = useState(false); const [secondPageLoading, setSecondPageLoading] = useState(true); const [secondPageHasError, setSecondPageHasError] = useState(false); - const { isRTL } = useReadingDirection(); const handleImageLoad = useCallback(() => { setIsLoading(false); @@ -53,7 +53,7 @@ export function PageDisplay({ return (
-
+
{/* Page 1 */}
@@ -79,10 +79,21 @@ export function PageDisplay({ )} {hasError ? (
- - - - + + + + Image non disponible
@@ -94,7 +105,7 @@ export function PageDisplay({ src={imageBlobUrls[currentPage] || getPageUrl(currentPage)} alt={`Page ${currentPage}`} className={cn( - "max-h-full max-w-full cursor-pointer rounded-md object-contain transition-opacity", + "max-h-full max-w-full cursor-pointer object-contain transition-opacity", isLoading ? "opacity-0" : "opacity-100" )} loading="eager" @@ -114,9 +125,9 @@ export function PageDisplay({ {/* Page 2 (double page) */} {isDoublePage && shouldShowDoublePage(currentPage) && (
{secondPageLoading && ( @@ -132,10 +143,21 @@ export function PageDisplay({ )} {secondPageHasError ? (
- - - - + + + + Image non disponible
@@ -147,7 +169,7 @@ export function PageDisplay({ src={imageBlobUrls[currentPage + 1] || getPageUrl(currentPage + 1)} alt={`Page ${currentPage + 1}`} className={cn( - "max-h-full max-w-full cursor-pointer rounded-md object-contain transition-opacity", + "max-h-full max-w-full cursor-pointer object-contain transition-opacity", secondPageLoading ? "opacity-0" : "opacity-100" )} loading="eager"