From 47263231af58ac2e9a5d5f600a08389f411c55ff Mon Sep 17 00:00:00 2001 From: Riccardo Giorato Date: Fri, 26 Dec 2025 17:40:41 +0100 Subject: [PATCH] Move info and redraw actions to ComicCanvas, update sidebar UI Shifted the info and redraw buttons from the editor toolbar to the ComicCanvas component, allowing for contextual actions per page. Enhanced ComicCanvas to support page navigation via image clicks and added optional callbacks for info and navigation. Updated the page sidebar to display page thumbnails instead of numbers, improved the add page button, and adjusted button sizes for better usability. --- app/editor/[storySlug]/page.tsx | 16 ++++----- components/editor/comic-canvas.tsx | 44 +++++++++++++++++++++-- components/editor/editor-toolbar.tsx | 53 +++++++++------------------- components/editor/page-sidebar.tsx | 51 +++++++++++++++++--------- 4 files changed, 101 insertions(+), 63 deletions(-) diff --git a/app/editor/[storySlug]/page.tsx b/app/editor/[storySlug]/page.tsx index cc14c41..8551d40 100644 --- a/app/editor/[storySlug]/page.tsx +++ b/app/editor/[storySlug]/page.tsx @@ -128,14 +128,10 @@ export default function StoryEditorPage() { if (wasGenerating) { setShowGenerateModal(true); } - - toast({ - title: "API key saved", - description: "Your Together API key has been saved successfully", - duration: 3000, - }); }; + + const handleGeneratePage = async (data: { prompt: string; style: string; @@ -216,7 +212,6 @@ export default function StoryEditorPage() {
setShowInfoSheet(true)} onContinueStory={handleAddPage} /> @@ -229,7 +224,12 @@ export default function StoryEditorPage() { loadingPageId={loadingPageId} onApiKeyClick={handleApiKeyClick} /> - + setShowInfoSheet(true)} + onNextPage={() => setCurrentPage((prev) => (prev < pages.length - 1 ? prev + 1 : prev))} + onPrevPage={() => setCurrentPage((prev) => (prev > 0 ? prev - 1 : prev))} + />
void; + onNextPage?: () => void; + onPrevPage?: () => void; } -export function ComicCanvas({ page }: ComicCanvasProps) { +export function ComicCanvas({ page, onInfoClick, onNextPage, onPrevPage }: ComicCanvasProps) { return (
{/* Dot grid background */} @@ -32,7 +35,20 @@ export function ComicCanvas({ page }: ComicCanvasProps) { {`Page { + const rect = e.currentTarget.getBoundingClientRect(); + const clickX = e.clientX - rect.left; + const imageWidth = rect.width; + + if (clickX > imageWidth / 2) { + // Right half - next page + onNextPage?.(); + } else { + // Left half - previous page + onPrevPage?.(); + } + }} />
@@ -44,6 +60,28 @@ export function ComicCanvas({ page }: ComicCanvasProps) {
+ {/* Action buttons below the page image */} +
+ {onInfoClick && ( + + )} + + +
+
{/*
Page {page.id}
*/} diff --git a/components/editor/editor-toolbar.tsx b/components/editor/editor-toolbar.tsx index 8682f30..c5ed48c 100644 --- a/components/editor/editor-toolbar.tsx +++ b/components/editor/editor-toolbar.tsx @@ -6,13 +6,11 @@ import { useRouter } from "next/navigation"; interface EditorToolbarProps { title: string; - onInfoClick: () => void; onContinueStory?: () => void; } export function EditorToolbar({ title, - onInfoClick, onContinueStory, }: EditorToolbarProps) { const router = useRouter(); @@ -34,41 +32,24 @@ export function EditorToolbar({
-
- +
+ - - - - - -
+ +
); } diff --git a/components/editor/page-sidebar.tsx b/components/editor/page-sidebar.tsx index 12d9f18..6153315 100644 --- a/components/editor/page-sidebar.tsx +++ b/components/editor/page-sidebar.tsx @@ -31,37 +31,56 @@ export function PageSidebar({ onApiKeyClick, }: PageSidebarProps) { return ( -