import type { BookPageSetup } from '@trek/shared' import { MAX_BOOK_LAYOUTS, bookLayoutPreview as layoutPreview, bookLayoutRole as layoutRole, nextBookLayoutName as nextLayoutName, } from '@trek/shared' import { BookmarkPlus, Trash2 } from 'lucide-react' import { useStudioStore } from '../../store/studioStore' import { Tooltip } from '../shared/Tooltip' import { SpreadView } from './SpreadView' /** * The book's own layouts, above the built-in ones (#2316). * * One button keeps the page on screen as a layout; each card lays the page on * screen out that way, keeping its pictures and words. The cards draw the * layout with the same renderer as the page, so what is kept is what is shown. */ export function StudioSavedLayouts({ page, width, pxPerMm, t, }: { page: BookPageSetup; width: number; pxPerMm: number; t: (k: string) => string }) { const doc = useStudioStore(s => s.doc) const active = useStudioStore(s => s.activeSpread) const saveLayout = useStudioStore(s => s.saveLayout) const removeLayout = useStudioStore(s => s.removeLayout) const applyLayout = useStudioStore(s => s.applyLayout) const spread = doc?.spreads[active] if (!doc || !spread) return null const all = doc.layouts ?? [] const role = layoutRole(spread) const fitting = all.filter(l => l.role === role) const full = all.length >= MAX_BOOK_LAYOUTS const canSave = spread.elements.length > 0 && !full const single = role !== 'inner' const wMm = page.pageWidth * (single ? 1 : 2) const scale = width / (wMm * pxPerMm) return (
{t('journey.studio.myLayoutsEmpty')}
}