Skip to content

Commit 3148367

Browse files
authored
Rename grid cell to grid item (#6623)
**Problem:** Sometimes we call the grid items "grid cells", which is incorrect (grid cells are the positions in the grid, and not the child items). **Fix:** Rename **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
1 parent 2c8aee3 commit 3148367

21 files changed

+30
-30
lines changed

editor/src/components/canvas/canvas-strategies/strategies/absolute-resize-bounding-box-strategy.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export function absoluteResizeBoundingBoxStrategy(
9898
}
9999

100100
if (
101-
retargetedTargets.some((path) => MetadataUtils.isGridCell(canvasState.startingMetadata, path))
101+
retargetedTargets.some((path) => MetadataUtils.isGridItem(canvasState.startingMetadata, path))
102102
) {
103103
return null
104104
}

editor/src/components/canvas/canvas-strategies/strategies/basic-resize-strategy.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export function basicResizeStrategy(
8383
const elementDimensionsProps = metadata != null ? getElementDimensions(metadata) : null
8484
const elementParentBounds = metadata?.specialSizeMeasurements.immediateParentBounds ?? null
8585

86-
const isGridCell = MetadataUtils.isGridCell(canvasState.startingMetadata, selectedElement)
86+
const isGridCell = MetadataUtils.isGridItem(canvasState.startingMetadata, selectedElement)
8787
if (isGridCell && isFillOrStretchModeApplied(canvasState.startingMetadata, selectedElement)) {
8888
return null
8989
}
@@ -216,7 +216,7 @@ export function basicResizeStrategy(
216216
)
217217

218218
const gridsToRerender = selectedElements
219-
.filter((element) => MetadataUtils.isGridCell(canvasState.startingMetadata, element))
219+
.filter((element) => MetadataUtils.isGridItem(canvasState.startingMetadata, element))
220220
.map(EP.parentPath)
221221

222222
const elementsToRerender = [...selectedElements, ...gridsToRerender]

editor/src/components/canvas/canvas-strategies/strategies/convert-to-absolute-and-move-strategy.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ function convertToAbsoluteAndMoveStrategyFactory(setHuggingParentToFixed: SetHug
180180
originalTargets,
181181
).filter(
182182
// don't show the siblings control for grid cells
183-
(sibling) => !MetadataUtils.isGridCell(canvasState.startingMetadata, sibling.elementPath),
183+
(sibling) => !MetadataUtils.isGridItem(canvasState.startingMetadata, sibling.elementPath),
184184
)
185185

186186
const showSiblingsControl = autoLayoutSiblingsExceptGridCells.length > 1

editor/src/components/canvas/canvas-strategies/strategies/flex-resize-basic-strategy.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export function flexResizeBasicStrategy(
8989
elementParentBounds != null &&
9090
(elementParentBounds.width !== 0 || elementParentBounds.height !== 0)
9191

92-
if (MetadataUtils.isGridCell(canvasState.startingMetadata, selectedElements[0])) {
92+
if (MetadataUtils.isGridItem(canvasState.startingMetadata, selectedElements[0])) {
9393
return null
9494
}
9595

editor/src/components/canvas/canvas-strategies/strategies/flex-resize-strategy.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export function flexResizeStrategy(
109109
elementParentBounds.width !== 0 &&
110110
elementParentBounds.height !== 0
111111

112-
if (MetadataUtils.isGridCell(canvasState.startingMetadata, selectedElements[0])) {
112+
if (MetadataUtils.isGridItem(canvasState.startingMetadata, selectedElements[0])) {
113113
return null
114114
}
115115

editor/src/components/canvas/canvas-strategies/strategies/grid-move-absolute.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const gridMoveAbsoluteStrategy: CanvasStrategyFactory = (
5959
}
6060

6161
const selectedElement = selectedElements[0]
62-
if (!MetadataUtils.isGridCell(canvasState.startingMetadata, selectedElement)) {
62+
if (!MetadataUtils.isGridItem(canvasState.startingMetadata, selectedElement)) {
6363
return null
6464
}
6565

@@ -215,7 +215,7 @@ function runGridMoveAbsolute(
215215

216216
// if moving an absolutely-positioned child which does not have pinning
217217
// props, do not set them at all.
218-
if (MetadataUtils.hasNoGridCellPositioning(selectedElementMetadata.specialSizeMeasurements)) {
218+
if (MetadataUtils.hasNoGridItemPositioning(selectedElementMetadata.specialSizeMeasurements)) {
219219
return [
220220
showGridControls('mid-interaction', gridPath, targetCellCoords, targetRootCell),
221221
...gridChildAbsoluteMoveCommands(

editor/src/components/canvas/canvas-strategies/strategies/grid-move-rearrange-duplicate-strategy.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const gridMoveRearrangeDuplicateStrategy: CanvasStrategyFactory = (
4343
}
4444

4545
const selectedElement = selectedElements[0]
46-
if (!MetadataUtils.isGridCell(canvasState.startingMetadata, selectedElement)) {
46+
if (!MetadataUtils.isGridItem(canvasState.startingMetadata, selectedElement)) {
4747
return null
4848
}
4949

editor/src/components/canvas/canvas-strategies/strategies/grid-move-rearrange-strategy.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const gridMoveRearrangeStrategy: CanvasStrategyFactory = (
5050
}
5151

5252
const selectedElement = selectedElements[0]
53-
if (!MetadataUtils.isGridCell(canvasState.startingMetadata, selectedElement)) {
53+
if (!MetadataUtils.isGridItem(canvasState.startingMetadata, selectedElement)) {
5454
return null
5555
}
5656

editor/src/components/canvas/canvas-strategies/strategies/grid-move-reorder-strategy.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const gridMoveReorderStrategy: CanvasStrategyFactory = (
5353
}
5454

5555
const selectedElement = selectedElements[0]
56-
if (!MetadataUtils.isGridCell(canvasState.startingMetadata, selectedElement)) {
56+
if (!MetadataUtils.isGridItem(canvasState.startingMetadata, selectedElement)) {
5757
return null
5858
}
5959

editor/src/components/canvas/canvas-strategies/strategies/grid-rearrange-keyboard-strategy.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function gridRearrangeResizeKeyboardStrategy(
3232

3333
const target = selectedElements[0]
3434

35-
if (!MetadataUtils.isGridCell(canvasState.startingMetadata, target)) {
35+
if (!MetadataUtils.isGridItem(canvasState.startingMetadata, target)) {
3636
return null
3737
}
3838

editor/src/components/canvas/canvas-strategies/strategies/grid-resize-element-strategy.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const gridResizeElementStrategy: CanvasStrategyFactory = (
4040
if (selectedElementMetadata == null) {
4141
return null
4242
}
43-
const isElementInsideGrid = MetadataUtils.isGridCell(
43+
const isElementInsideGrid = MetadataUtils.isGridItem(
4444
canvasState.startingMetadata,
4545
selectedElement,
4646
)

editor/src/components/canvas/canvas-strategies/strategies/keyboard-absolute-resize-strategy.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export function keyboardAbsoluteResizeStrategy(
145145
return null
146146
}
147147

148-
if (MetadataUtils.isGridCell(canvasState.startingMetadata, selectedElements[0])) {
148+
if (MetadataUtils.isGridItem(canvasState.startingMetadata, selectedElements[0])) {
149149
return null
150150
}
151151

editor/src/components/canvas/canvas-strategies/strategies/reparent-utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -551,13 +551,13 @@ function pasteIntoNextGridCell(
551551
// if the copied elements are grid cells and the target is a grid cell, paste next to it
552552

553553
const copyDataElementsAreGridCells = copyData.elementPaste.every(({ originalElementPath }) =>
554-
MetadataUtils.isGridCell(copyData.originalContextMetadata, originalElementPath),
554+
MetadataUtils.isGridItem(copyData.originalContextMetadata, originalElementPath),
555555
)
556556
if (!copyDataElementsAreGridCells) {
557557
return null
558558
}
559559

560-
const targetIsGridChild = MetadataUtils.isGridCell(metadata, selectedView)
560+
const targetIsGridChild = MetadataUtils.isGridItem(metadata, selectedView)
561561
if (!targetIsGridChild) {
562562
return null
563563
}

editor/src/components/canvas/canvas-strategies/strategies/resize-grid-strategy.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export const resizeGridStrategy: CanvasStrategyFactory = (
7777
'some',
7878
)
7979

80-
const isGridCell = MetadataUtils.isGridCell(canvasState.startingMetadata, selectedElement)
80+
const isGridCell = MetadataUtils.isGridItem(canvasState.startingMetadata, selectedElement)
8181
const isGrid = MetadataUtils.isGridLayoutedContainer(
8282
MetadataUtils.findElementByElementPath(canvasState.startingMetadata, selectedElement),
8383
)

editor/src/components/canvas/controls/grid-controls.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ const GridControl = React.memo<GridControlProps>(({ grid, controlsVisible }) =>
662662
Substores.metadata,
663663
(store) =>
664664
store.editor.selectedViews.every((elementPath) =>
665-
MetadataUtils.isGridCellWithPositioning(store.editor.jsxMetadata, elementPath),
665+
MetadataUtils.isGridItemWithPositioning(store.editor.jsxMetadata, elementPath),
666666
),
667667
'GridControl targetsAreCellsWithPositioning',
668668
)

editor/src/components/canvas/controls/select-mode/absolute-resize-control.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export const AbsoluteResizeControl = controlForStrategyMemoized(
147147
let diagonally = true
148148

149149
for (const element of selectedElementsRef.current) {
150-
if (MetadataUtils.isGridCell(metadata, element)) {
150+
if (MetadataUtils.isGridItem(metadata, element)) {
151151
if (isFillOrStretchModeAppliedOnAnySide(metadata, element)) {
152152
diagonally = false
153153
}

editor/src/components/canvas/controls/select-mode/select-mode-hooks.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ function useSelectOrLiveModeSelectAndHover(
724724
foundTarget != null &&
725725
draggingAllowed &&
726726
// grid has its own drag handling
727-
!MetadataUtils.isGridCell(
727+
!MetadataUtils.isGridItem(
728728
editorStoreRef.current.editor.jsxMetadata,
729729
foundTarget.elementPath,
730730
)

editor/src/components/inspector/inspector-common.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ export function detectFillHugFixedState(
746746
getSimpleAttributeAtPath(right(element.element.value.props), PP.create('style', 'height')),
747747
)
748748

749-
if (MetadataUtils.isGridCell(metadata, elementPath)) {
749+
if (MetadataUtils.isGridItem(metadata, elementPath)) {
750750
const isStretchingExplicitly =
751751
(element.specialSizeMeasurements.alignSelf === 'stretch' &&
752752
axis === 'horizontal' &&
@@ -1205,7 +1205,7 @@ export function getFixedFillHugOptionsForElement(
12051205
? 'hug'
12061206
: null,
12071207
fillContainerApplicable(metadata, selectedView)
1208-
? MetadataUtils.isGridCell(metadata, selectedView)
1208+
? MetadataUtils.isGridItem(metadata, selectedView)
12091209
? 'stretch'
12101210
: 'fill'
12111211
: null,

editor/src/components/inspector/inspector-strategies/fill-container-basic-strategy.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export const fillContainerStrategyGridParent = (
167167
name: 'Set to Fill Container, in grid layout',
168168
strategy: () => {
169169
const elements = elementPaths.filter(
170-
(path) => fillContainerApplicable(metadata, path) && MetadataUtils.isGridCell(metadata, path),
170+
(path) => fillContainerApplicable(metadata, path) && MetadataUtils.isGridItem(metadata, path),
171171
)
172172

173173
if (elements.length === 0) {

editor/src/components/inspector/sections/layout-section/self-layout-subsection/simplified-layout-subsection.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const SimplifiedLayoutSubsection = React.memo(() => {
6161
Substores.metadata,
6262
(store) =>
6363
store.editor.selectedViews.length === 1 &&
64-
MetadataUtils.isGridCell(store.editor.jsxMetadata, store.editor.selectedViews[0]),
64+
MetadataUtils.isGridItem(store.editor.jsxMetadata, store.editor.selectedViews[0]),
6565
'Inspector shouldShowGridCellSection',
6666
)
6767

editor/src/core/model/element-metadata-utils.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -381,19 +381,19 @@ export const MetadataUtils = {
381381
isGridLayoutedContainer(instance: ElementInstanceMetadata | null): boolean {
382382
return instance?.specialSizeMeasurements.layoutSystemForChildren === 'grid'
383383
},
384-
isGridCell(metadata: ElementInstanceMetadataMap, path: ElementPath): boolean {
384+
isGridItem(metadata: ElementInstanceMetadataMap, path: ElementPath): boolean {
385385
const elementMetadata = MetadataUtils.findElementByElementPath(metadata, path)
386386
return elementMetadata?.specialSizeMeasurements.parentLayoutSystem === 'grid'
387387
},
388-
isGridCellWithPositioning(metadata: ElementInstanceMetadataMap, path: ElementPath): boolean {
388+
isGridItemWithPositioning(metadata: ElementInstanceMetadataMap, path: ElementPath): boolean {
389389
const element = MetadataUtils.findElementByElementPath(metadata, path)
390390
return (
391-
MetadataUtils.isGridCell(metadata, path) &&
391+
MetadataUtils.isGridItem(metadata, path) &&
392392
element != null &&
393-
!MetadataUtils.hasNoGridCellPositioning(element.specialSizeMeasurements)
393+
!MetadataUtils.hasNoGridItemPositioning(element.specialSizeMeasurements)
394394
)
395395
},
396-
hasNoGridCellPositioning(specialSizeMeasurements: SpecialSizeMeasurements): boolean {
396+
hasNoGridItemPositioning(specialSizeMeasurements: SpecialSizeMeasurements): boolean {
397397
return (
398398
specialSizeMeasurements.elementGridPropertiesFromProps.gridColumnStart == null &&
399399
specialSizeMeasurements.elementGridPropertiesFromProps.gridColumnEnd == null &&
@@ -632,7 +632,7 @@ export const MetadataUtils = {
632632
return (
633633
MetadataUtils.isFlexLayoutedContainer(
634634
MetadataUtils.findElementByElementPath(jsxMetadata, EP.parentPath(path)),
635-
) || MetadataUtils.isGridCell(jsxMetadata, path)
635+
) || MetadataUtils.isGridItem(jsxMetadata, path)
636636
)
637637
},
638638
getRelativeAlignJustify: function (

0 commit comments

Comments
 (0)