Spaces:
Runtime error
Runtime error
File size: 1,532 Bytes
cb3fdda eae27f0 cb3fdda b6caea7 cb3fdda eae27f0 cb3fdda eae27f0 cb3fdda |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
import { allLayouts } from "@/app/layouts"
import { useStore } from "@/app/store"
import { cn } from "@/lib/utils"
import { useEffect, useRef } from "react"
export function Page({ page }: { page: number }) {
const zoomLevel = useStore(state => state.zoomLevel)
const layouts = useStore(state => state.layouts)
// const prompt = useStore(state => state.prompt)
const LayoutElement = (allLayouts as any)[layouts[page]]
/*
const [canLoad, setCanLoad] = useState(false)
useEffect(() => {
if (prompt?.length) {
setCanLoad(false)
setTimeout(() => {
setCanLoad(true)
}, page * 4000)
}
}, [prompt])
*/
const setPage = useStore(state => state.setPage)
const pageRef = useRef<HTMLDivElement>(null)
useEffect(() => {
const element = pageRef.current
if (!element) { return }
setPage(element)
}, [pageRef.current])
return (
<div
ref={pageRef}
className={cn(
`w-full`,
// we are trying to reach a "book" look
// we are using aspect-[297/210] because it matches A4 (297mm x 210mm)
// `aspect-[210/297]`,
`aspect-[250/297]`,
`transition-all duration-100 ease-in-out`,
`border border-stone-200`,
`shadow-2xl`,
`print:shadow-none`,
`print:border-0`,
`print:width-screen`
)}
style={{
padding: `${Math.round((zoomLevel / 100) * 16)}px`
// marginLeft: `${zoomLevel > 100 ? `100`}`
}}
>
<LayoutElement />
</div>
)
} |