diff --git a/src/components/frontend/garage/GarageGrid.tsx b/src/components/frontend/garage/GarageGrid.tsx index 157b4baf..322c74ef 100644 --- a/src/components/frontend/garage/GarageGrid.tsx +++ b/src/components/frontend/garage/GarageGrid.tsx @@ -1,6 +1,6 @@ "use client"; -import { useEffect, useMemo, useRef, useState } from "react"; +import { type CSSProperties, useEffect, useMemo, useRef, useState } from "react"; import { DndContext, type DragEndEvent, @@ -106,6 +106,29 @@ export function VehicleFace({ dragging?: boolean; }) { const fp = footprint(item); + const cardW = fp.width * cellSize - 2; + const cardH = fp.height * cellSize - 2; + // Thumbnail caps are applied PRE-rotation, so for rotated cards the long + // edge must be capped by the card's HEIGHT (it becomes vertical after the + // 90deg turn) and vice versa. Pixel math, since % would resolve against + // the wrong axis of the already-rotated card. The rotated image is taken + // out of flow and anchored to the card centre so the 90deg turn happens + // around the card's middle (an in-flow image would rotate around its own + // top-biased box and clip against the card edge). + const thumbStyle: CSSProperties = item.rotated + ? { + position: "absolute", + left: "50%", + top: "50%", + width: Math.floor(cardH * 0.85), + height: Math.floor(cardW * 0.85), + objectFit: "contain", + transform: "translate(-50%, -50%) rotate(90deg)", + } + : { + maxWidth: Math.floor(cardW * 0.85), + maxHeight: Math.floor(cardH * 0.55), + }; return (
) : (