import { useState } from 'react' import { createPortal } from 'react-dom' import { useNavigate } from 'react-router' import { BookOpen, Download, Maximize2, Minus, Plus } from 'lucide-react' import { useJourneyStudio } from '../../pages/journeyStudio/useJourneyStudio' import { foliosOf } from './bookSheets' import { StudioSidebar } from './StudioSidebar' import type { RailSection } from './sidebar/railSections' import { ProviderPicker } from '../Journey/JourneyDetailPageProviderPicker' import { useAuthStore } from '../../store/authStore' import { StudioCanvas } from './StudioCanvas' import { StudioInspector } from './StudioInspector' import { StudioPaletteScope } from './paint/StudioPalette' import { downloadSpread } from './spreadFile' import { StudioExport } from './StudioExport' import { StudioAssistantColumn, StudioPageStage } from './StudioAssistantPanel' import { useStudioAssistant } from './useStudioAssistant' import { StudioHeader } from './StudioHeader' import { StudioNotices } from './StudioNotices' import '../../styles/dashboard.css' import '../../styles/studio.css' import './bookFontFaces' import { useWarmBookFaces } from './bookFontWarm' /** * The Studio shell: top bar, page rail, workbench, inspector. * * It is a child route of the journey and portals itself over it, so the journey * stays mounted underneath and shows through the blurred 16px margin. That * margin is the whole point — you are meant to see that you never left. * * `.trek-dash` on the root is not decoration: every colour, radius and shadow in * studio.css resolves against those tokens, so Studio follows the user's theme * and accent without a second palette to keep in sync. */ export default function StudioShell() { const s = useJourneyStudio() const navigate = useNavigate() const [bookView, setBookView] = useState(true) const [exporting, setExporting] = useState(false) // The rail's open section lives here, so the inspector can open the Theme or the Layers panel beside it. const [railSection, setRailSection] = useState('pages') const assistant = useStudioAssistant({ journeyId: s.journeyId, flush: s.flushBook }) // The book's faces into the offline cache as it opens (bookFontWarm.ts). useWarmBookFaces() if (s.isMobile) { return createPortal(
{s.t('journey.studio.desktopOnly')}
{s.t('journey.studio.desktopOnlyHint')}
, document.body, ) } const originStyle = s.origin ? ({ '--st-ox': `${s.origin.x}px`, '--st-oy': `${s.origin.y}px` } as React.CSSProperties) : undefined return createPortal( <>
setExporting(true)} assistant={assistant} /> {/* The journey gallery's picker, inside Studio's own layer (#2271). */} {s.providerPick && s.journey && ( e.type !== 'skeleton' || e.title)} trips={s.journey.trips} existingAssetIds={new Set((s.journey.gallery ?? []).filter(p => p.asset_id).map(p => p.asset_id!))} initialEntryId={s.providerPick.entryId} onClose={s.closeProviderPick} onAdd={s.addFromProvider} /> )}
{exporting && s.doc && ( setExporting(false)} /> )}
, document.body, ) } export type Studio = ReturnType function Workbench({ s, bookView, setBookView }: { s: Studio; bookView: boolean; setBookView: (on: boolean) => void }) { return (
s.moveCursor(s.activeSpread, x, y)} onDropFiles={s.canEdit ? s.dropFiles : undefined} fileDropLabel={s.t('journey.studio.dropFilesHere')} /> {/* Pictures dropped on the sheet are on their way. The page keeps rendering underneath; the veil only says that something is happening where the pointer let go, so the second or two before the frame appears does not read as the drop having been ignored. */} {s.canvasUpload && (
{s.t('journey.studio.uploading', { done: s.canvasUpload.done, total: s.canvasUpload.total })}
)}
{s.zoomPercent}% {/* How the page is looked at, so with the zoom rather than in the head band. */} {/* The page, as a file. Here rather than in a menu because it belongs to the spread on screen — the zoom bar is the only chrome that is about *this* page rather than about the book. What comes out is the design without the photographs, which is the thing worth passing on. */}
) }