From c60491decaba87eb17e5f3ed9216c88629236abb Mon Sep 17 00:00:00 2001 From: Andymick Date: Sat, 18 Jul 2026 11:51:07 +0100 Subject: [PATCH] Add rulers and cm measurements to personalization canvas - Display X and Y rulers with 2cm increments - Show position and size in centimeters (cm) instead of pixels - Calculate cmPerPx from product print area for accurate conversion - Rulers positioned above and to the left of design canvas - Labels show cm measurements for easy reference while personalizing Users can now see exact placement and dimensions in cm during design, with visual ruler guides for precise positioning. Co-Authored-By: Claude Haiku 4.5 --- src/components/DesignCanvas.tsx | 86 +++++++++++++++++++++++++++++++-- 1 file changed, 81 insertions(+), 5 deletions(-) diff --git a/src/components/DesignCanvas.tsx b/src/components/DesignCanvas.tsx index 63535d0..032a8ba 100644 --- a/src/components/DesignCanvas.tsx +++ b/src/components/DesignCanvas.tsx @@ -200,6 +200,77 @@ function PrintSurface({
{photo}
+ + {/* Horizontal Ruler */} +
+ {Array.from({ length: Math.ceil((stageW / (10 * (product.printAreaWidthMm / 100)))) }).map((_, i) => { + const cm = i * 2; + const px = (cm * stageW) / (product.printAreaWidthMm / 10); + if (px > stageW) return null; + return ( +
+ {cm}cm +
+ ); + })} +
+ + {/* Vertical Ruler */} +
+ {Array.from({ length: Math.ceil((stageH / (10 * (product.printAreaWidthMm / 100)))) }).map((_, i) => { + const cm = i * 2; + const px = (cm * stageH) / (product.printAreaWidthMm / 10); + if (px > stageH) return null; + return ( +
+ {cm} +
+ ); + })} +
+
(px * cmPerPx).toFixed(2); const setActiveElements = view === 'front' ? setElementsFront : setElementsBack; // Keep whichever transformer actually owns the selected element in sync, and @@ -779,25 +855,25 @@ export default function DesignCanvas({ product }: { product: ProductDTO }) { {selected && (
-

Position & Size

+

Position & Size (cm)

X: - {Math.round(selected.x)} px + {pxToCm(selected.x)} cm
Y: - {Math.round(selected.y)} px + {pxToCm(selected.y)} cm
{selected.type === 'image' && ( <>
Width: - {Math.round(selected.width)} px + {pxToCm(selected.width)} cm
Height: - {Math.round(selected.height)} px + {pxToCm(selected.height)} cm
)}