From b7d07ed0467bb649040a3e288616b8c05331c5b4 Mon Sep 17 00:00:00 2001
From: Federico Ruggi <1081051+ruggi@users.noreply.github.com>
Date: Fri, 22 Nov 2024 15:10:39 +0100
Subject: [PATCH] Grid cell lines (#6674)
**Problem:**
When a grid item is selected, there should be outline lines around the
cell bounds, which also expand to meet the ruler markers.
**Fix:**
Implement one component to render the cell bounds outline, and one
component for the lines stretching to the markers from the cell
perimeter.
https://github.com/user-attachments/assets/9a69b131-a052-42ab-88c6-f1534c3865af
**Manual Tests:**
I hereby swear that:
- [x] I opened a hydrogen project and it loaded
- [x] I could navigate to various routes in Play mode
Fixes #6675
---
.../canvas/controls/grid-controls.tsx | 108 +++++++++++++++++-
1 file changed, 103 insertions(+), 5 deletions(-)
diff --git a/editor/src/components/canvas/controls/grid-controls.tsx b/editor/src/components/canvas/controls/grid-controls.tsx
index 7992c4155988..a6f18b1d6e64 100644
--- a/editor/src/components/canvas/controls/grid-controls.tsx
+++ b/editor/src/components/canvas/controls/grid-controls.tsx
@@ -28,6 +28,7 @@ import {
import type { CanvasPoint, CanvasRectangle, LocalRectangle } from '../../../core/shared/math-utils'
import {
canvasPoint,
+ canvasRectangle,
isFiniteRectangle,
isInfinityRectangle,
nullIfInfinity,
@@ -2160,6 +2161,8 @@ const rulerMarkerIconSize = 12 // px
type RulerMarkerData = {
parentGrid: GridContainerProperties
+ cellRect: CanvasRectangle
+ gridRect: CanvasRectangle
columnStart: RulerMarkerPositionData
columnEnd: RulerMarkerPositionData
rowStart: RulerMarkerPositionData
@@ -2243,8 +2246,18 @@ const RulerMarkers = React.memo((props: { path: ElementPath }) => {
store.editor.jsxMetadata,
)
+ const cellRect = parentGridCellGlobalFrames[cellBounds.row - 1][cellBounds.column - 1]
+ const cellRectResized = canvasRectangle({
+ x: cellRect.x,
+ y: cellRect.y,
+ width: width,
+ height: height,
+ })
+
return {
parentGrid: parentGrid,
+ cellRect: cellRectResized,
+ gridRect: gridRect,
columnStart: {
top: gridRect.y,
left: left,
@@ -2280,6 +2293,7 @@ const RulerMarkers = React.memo((props: { path: ElementPath }) => {
return (