diff --git a/src/components/DesignCanvas.tsx b/src/components/DesignCanvas.tsx index 7368b4a..51947dc 100644 --- a/src/components/DesignCanvas.tsx +++ b/src/components/DesignCanvas.tsx @@ -168,8 +168,6 @@ function PrintSurface({ onNodeReady, scale, product, - referenceWidthCm, - referenceHeightCm, }: { photo: React.ReactNode; printArea: PrintArea; @@ -185,8 +183,6 @@ function PrintSurface({ onNodeReady: () => void; scale: number; product: ProductDTO; - referenceWidthCm: number | null; - referenceHeightCm: number | null; }) { const stageW = printArea.wPct * DISPLAY; const stageH = printArea.hPct * DISPLAY; @@ -208,7 +204,7 @@ function PrintSurface({ {/* Horizontal Ruler */} - {referenceWidthCm && referenceWidthCm > 0 && ( + {product.referenceWidthCm && product.referenceWidthCm > 0 && (
{(() => { const marks = []; - const pxPerCm = DISPLAY / referenceWidthCm; + const pxPerCm = DISPLAY / product.referenceWidthCm; - for (let cm = 0; cm <= Math.ceil(referenceWidthCm); cm += 2) { + for (let cm = 0; cm <= Math.ceil(product.referenceWidthCm); cm += 2) { const px = cm * pxPerCm; if (px > DISPLAY) break; marks.push( @@ -250,7 +246,7 @@ function PrintSurface({ )} {/* Vertical Ruler */} - {referenceHeightCm && referenceHeightCm > 0 && ( + {product.referenceHeightCm && product.referenceHeightCm > 0 && (
{(() => { const marks = []; - const pxPerCm = DISPLAY / referenceHeightCm; + const pxPerCm = DISPLAY / product.referenceHeightCm; - for (let cm = 0; cm <= Math.ceil(referenceHeightCm); cm += 2) { + for (let cm = 0; cm <= Math.ceil(product.referenceHeightCm); cm += 2) { const px = cm * pxPerCm; if (px > DISPLAY) break; marks.push( @@ -406,8 +402,6 @@ export default function DesignCanvas({ product }: { product: ProductDTO }) { const [justAdded, setJustAdded] = useState(false); const [showLoginPrompt, setShowLoginPrompt] = useState(false); const [nodeReadyTick, setNodeReadyTick] = useState(0); - const [referenceWidthCm, setReferenceWidthCm] = useState(null); - const [referenceHeightCm, setReferenceHeightCm] = useState(null); const stageFrontRef = useRef(null); const stageBackRef = useRef(null); @@ -443,10 +437,9 @@ export default function DesignCanvas({ product }: { product: ProductDTO }) { const activeStageW = activePrintArea.wPct * DISPLAY; const activeStageH = activePrintArea.hPct * DISPLAY; - // Calculate cm per pixel for display using reference size + // Calculate cm per pixel for display using product reference size // Reference size maps to full canvas width/height (560px) - const cmPerPx = referenceWidthCm && referenceWidthCm > 0 ? referenceWidthCm / DISPLAY : 0; - const cmPerPxHeight = referenceHeightCm && referenceHeightCm > 0 ? referenceHeightCm / DISPLAY : 0; + const cmPerPx = product.referenceWidthCm && product.referenceWidthCm > 0 ? product.referenceWidthCm / DISPLAY : 0; const pxToCm = (px: number) => { if (!cmPerPx || cmPerPx <= 0) return '—'; const cm = px * cmPerPx; @@ -750,8 +743,6 @@ export default function DesignCanvas({ product }: { product: ProductDTO }) { onNodeReady={() => setNodeReadyTick((t) => t + 1)} scale={canvasScale} product={product} - referenceWidthCm={referenceWidthCm} - referenceHeightCm={referenceHeightCm} /> {hasBack && ( @@ -770,8 +761,6 @@ export default function DesignCanvas({ product }: { product: ProductDTO }) { onNodeReady={() => setNodeReadyTick((t) => t + 1)} scale={canvasScale} product={product} - referenceWidthCm={referenceWidthCm} - referenceHeightCm={referenceHeightCm} /> )} @@ -861,38 +850,6 @@ export default function DesignCanvas({ product }: { product: ProductDTO }) {
)} - {canPersonalize && ( -
-

Reference Size (cm)

-
-
- - setReferenceWidthCm(e.target.value ? Number(e.target.value) : null)} - placeholder="e.g. 40" - className="w-full border border-line bg-paper px-3 py-2 text-sm placeholder:text-muted" - /> -
-
- - setReferenceHeightCm(e.target.value ? Number(e.target.value) : null)} - placeholder="e.g. 60" - className="w-full border border-line bg-paper px-3 py-2 text-sm placeholder:text-muted" - /> -
-
-
- )} - {canPersonalize && (

@@ -1040,9 +997,9 @@ export default function DesignCanvas({ product }: { product: ProductDTO }) {

- {canPersonalize && (!referenceWidthCm || !referenceHeightCm) && ( -

Please enter the reference size (width and height) before adding to bag

- )} - {canPersonalize && (elementsFront.length === 0 && elementsBack.length === 0) && (referenceWidthCm && referenceHeightCm) && ( + {elementsFront.length === 0 && elementsBack.length === 0 && (

Add text or images to personalize your design before adding to bag

)} {justAdded &&

Added to your bag.

}