diff --git a/editor/src/components/canvas/canvas-strategies/strategies/grid-resize-element-strategy.spec.browser2.tsx b/editor/src/components/canvas/canvas-strategies/strategies/grid-resize-element-strategy.spec.browser2.tsx
index 94ec2157177d..7b37b16fa49b 100644
--- a/editor/src/components/canvas/canvas-strategies/strategies/grid-resize-element-strategy.spec.browser2.tsx
+++ b/editor/src/components/canvas/canvas-strategies/strategies/grid-resize-element-strategy.spec.browser2.tsx
@@ -125,6 +125,50 @@ describe('grid resize element strategy', () => {
gridRowStart: '2',
})
})
+
+ it('can enlarge element in grid component', async () => {
+ const editor = await renderTestEditorWithCode(
+ ProjectCodeGridComponent,
+ 'await-first-dom-report',
+ )
+
+ await runCellResizeTest(
+ editor,
+ 'column-end',
+ gridCellTargetId(EP.fromString('sb/scene/grid'), 2, 10),
+ )
+
+ const { gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd } =
+ editor.renderedDOM.getByTestId('grid-child').style
+ expect({ gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd }).toEqual({
+ gridColumnEnd: '11',
+ gridColumnStart: '7',
+ gridRowStart: '2',
+ gridRowEnd: 'auto',
+ })
+ })
+
+ it('can shrink element in grid component', async () => {
+ const editor = await renderTestEditorWithCode(
+ ProjectCodeGridComponent,
+ 'await-first-dom-report',
+ )
+
+ await runCellResizeTest(
+ editor,
+ 'column-end',
+ gridCellTargetId(EP.fromString('sb/scene/grid'), 2, 8),
+ )
+
+ const { gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd } =
+ editor.renderedDOM.getByTestId('grid-child').style
+ expect({ gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd }).toEqual({
+ gridColumnEnd: '9',
+ gridColumnStart: '7',
+ gridRowEnd: 'auto',
+ gridRowStart: '2',
+ })
+ })
})
describe('column-start', () => {
@@ -165,6 +209,50 @@ describe('grid resize element strategy', () => {
gridRowStart: '2',
})
})
+
+ it('can enlarge element in grid component', async () => {
+ const editor = await renderTestEditorWithCode(
+ ProjectCodeGridComponent,
+ 'await-first-dom-report',
+ )
+
+ await runCellResizeTest(
+ editor,
+ 'column-start',
+ gridCellTargetId(EP.fromString('sb/scene/grid'), 2, 6),
+ )
+
+ const { gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd } =
+ editor.renderedDOM.getByTestId('grid-child').style
+ expect({ gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd }).toEqual({
+ gridColumnEnd: '10',
+ gridColumnStart: '6',
+ gridRowEnd: 'auto',
+ gridRowStart: '2',
+ })
+ })
+
+ it('can shrink element in grid component', async () => {
+ const editor = await renderTestEditorWithCode(
+ ProjectCodeGridComponent,
+ 'await-first-dom-report',
+ )
+
+ await runCellResizeTest(
+ editor,
+ 'column-start',
+ gridCellTargetId(EP.fromString('sb/scene/grid'), 2, 8),
+ )
+
+ const { gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd } =
+ editor.renderedDOM.getByTestId('grid-child').style
+ expect({ gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd }).toEqual({
+ gridColumnEnd: '10',
+ gridColumnStart: '8',
+ gridRowEnd: 'auto',
+ gridRowStart: '2',
+ })
+ })
})
describe('row-end', () => {
@@ -203,6 +291,45 @@ describe('grid resize element strategy', () => {
})
}
})
+
+ it('can resize element in grid component', async () => {
+ const editor = await renderTestEditorWithCode(
+ ProjectCodeGridComponent,
+ 'await-first-dom-report',
+ )
+
+ await runCellResizeTest(
+ editor,
+ 'row-end',
+ gridCellTargetId(EP.fromString('sb/scene/grid'), 3, 6),
+ )
+ {
+ const { gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd } =
+ editor.renderedDOM.getByTestId('grid-child').style
+ expect({ gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd }).toEqual({
+ gridColumnEnd: '10',
+ gridColumnStart: '7',
+ gridRowEnd: '4',
+ gridRowStart: '2',
+ })
+ }
+
+ await runCellResizeTest(
+ editor,
+ 'row-end',
+ gridCellTargetId(EP.fromString('sb/scene/grid'), 2, 8),
+ )
+ {
+ const { gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd } =
+ editor.renderedDOM.getByTestId('grid-child').style
+ expect({ gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd }).toEqual({
+ gridColumnEnd: '10',
+ gridColumnStart: '7',
+ gridRowEnd: 'auto',
+ gridRowStart: '2',
+ })
+ }
+ })
})
describe('row-start', () => {
@@ -243,6 +370,47 @@ describe('grid resize element strategy', () => {
})
}
})
+
+ it('can resize element in grid component', async () => {
+ const editor = await renderTestEditorWithCode(
+ ProjectCodeGridComponent,
+ 'await-first-dom-report',
+ )
+
+ await runCellResizeTest(
+ editor,
+ 'row-start',
+ gridCellTargetId(EP.fromString('sb/scene/grid'), 1, 6),
+ )
+
+ {
+ const { gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd } =
+ editor.renderedDOM.getByTestId('grid-child').style
+ expect({ gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd }).toEqual({
+ gridColumnEnd: '10',
+ gridColumnStart: '7',
+ gridRowEnd: '3',
+ gridRowStart: '1',
+ })
+ }
+
+ {
+ await runCellResizeTest(
+ editor,
+ 'row-start',
+ gridCellTargetId(EP.fromString('sb/scene/grid'), 2, 8),
+ )
+
+ const { gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd } =
+ editor.renderedDOM.getByTestId('grid-child').style
+ expect({ gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd }).toEqual({
+ gridColumnEnd: '10',
+ gridColumnStart: '7',
+ gridRowEnd: 'auto',
+ gridRowStart: '2',
+ })
+ }
+ })
})
it('can resize element with mouse move outside of grid cells', async () => {
@@ -286,6 +454,50 @@ describe('grid resize element strategy', () => {
}
})
+ it('can resize element with mouse move outside of grid cells in grid component', async () => {
+ const editor = await renderTestEditorWithCode(
+ ProjectCodeGridComponent,
+ 'await-first-dom-report',
+ )
+ await runCellResizeTest(
+ editor,
+ 'column-end',
+ gridCellTargetId(EP.fromString('sb/scene/grid'), 1, 8),
+ )
+
+ {
+ const { gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd } =
+ editor.renderedDOM.getByTestId('grid-child').style
+ expect({ gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd }).toEqual({
+ gridColumnEnd: '9',
+ gridColumnStart: '7',
+ gridRowEnd: 'auto',
+ gridRowStart: '2',
+ })
+ }
+
+ {
+ // moving a 2 cell wide element in the middle, over the gap between 2 cells
+ await runCellResizeTestWithDragVector(
+ editor,
+ 'row-start',
+ localPoint({
+ x: 0,
+ y: -50,
+ }),
+ )
+
+ const { gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd } =
+ editor.renderedDOM.getByTestId('grid-child').style
+ expect({ gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd }).toEqual({
+ gridColumnEnd: '9',
+ gridColumnStart: '7',
+ gridRowEnd: '3',
+ gridRowStart: '1',
+ })
+ }
+ })
+
it('removes the grid-area prop on resize', async () => {
const editor = await renderTestEditorWithCode(ProjectCodeWithGridArea, 'await-first-dom-report')
@@ -434,6 +646,29 @@ export var storyboard = (
gridRowEnd: 'auto',
})
})
+
+ it('also works for stretching cells in grid component', async () => {
+ const editor = await renderTestEditorWithCode(
+ ProjectCodeGridComponent,
+ 'await-first-dom-report',
+ )
+
+ await runCellResizeTest(
+ editor,
+ 'column-end',
+ gridCellTargetId(EP.fromString('sb/scene/grid'), 2, 10),
+ EP.fromString('sb/scene/grid/eee'),
+ )
+
+ const { gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd } =
+ editor.renderedDOM.getByTestId('grid-child-stretch').style
+ expect({ gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd }).toEqual({
+ gridColumnEnd: '11',
+ gridColumnStart: '4',
+ gridRowStart: '4',
+ gridRowEnd: 'auto',
+ })
+ })
})
const ProjectCode = `import * as React from 'react'
@@ -536,6 +771,120 @@ export var storyboard = (
)
`
+const ProjectCodeGridComponent = `import * as React from 'react'
+import { Scene, Storyboard, Placeholder } from 'utopia-api'
+
+export var storyboard = (
+