From 45bb0bd0299ffe192dc2640cb14b2e3121011642 Mon Sep 17 00:00:00 2001 From: Z8MB1E Date: Tue, 13 Oct 2026 16:43:02 -0400 Subject: [PATCH] feat(garage): rotate vehicle thumbnails with their cards Vehicle orientation is meaningful in a bay, so a parked-then-turned vehicle now shows its silhouette turned too. The rotated image is sized from the card's pixel dimensions (long edge against the card height) and anchored to the card centre so the 90deg turn happens around the middle instead of clipping against the top edge. Name labels stay upright. --- src/components/frontend/garage/GarageGrid.tsx | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) 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 (
) : (