Skip to content

Commit b6297d9

Browse files
authored
Rename areaName to lineName (#6583)
**Problem:** Grid dimension (which should be named tracks 🙃 , but that's for another day) have a field called `areaName` but it should actually be called `lineName` (https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout/Grid_layout_using_named_grid_lines). **Fix:** Rename `areaName` to `lineName`, and all its related mentions and (indirect) references. Fixes #6582
1 parent a689345 commit b6297d9

File tree

11 files changed

+126
-126
lines changed

11 files changed

+126
-126
lines changed

editor/src/components/canvas/canvas-strategies/strategies/grid-helpers.ts

+18-18
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,14 @@ export function setGridPropsCommands(
249249
const rowStart = gridPositionToValue(gridProps.gridRowStart)
250250
const rowEnd = gridPositionToValue(gridProps.gridRowEnd)
251251

252-
const areaColumnStart = asMaybeNamedAreaOrValue(gridTemplate, 'column', columnStart)
253-
const areaColumnEnd = asMaybeNamedAreaOrValue(gridTemplate, 'column', columnEnd)
254-
const areaRowStart = asMaybeNamedAreaOrValue(gridTemplate, 'row', rowStart)
255-
const areaRowEnd = asMaybeNamedAreaOrValue(gridTemplate, 'row', rowEnd)
252+
const lineColumnStart = asMaybeNamedLineOrValue(gridTemplate, 'column', columnStart)
253+
const lineColumnEnd = asMaybeNamedLineOrValue(gridTemplate, 'column', columnEnd)
254+
const lineRowStart = asMaybeNamedLineOrValue(gridTemplate, 'row', rowStart)
255+
const lineRowEnd = asMaybeNamedLineOrValue(gridTemplate, 'row', rowEnd)
256256

257257
if (columnStart != null && columnStart === columnEnd) {
258258
commands.push(
259-
setProperty('always', elementPath, PP.create('style', 'gridColumn'), areaColumnStart),
259+
setProperty('always', elementPath, PP.create('style', 'gridColumn'), lineColumnStart),
260260
)
261261
} else if (
262262
columnStart != null &&
@@ -266,40 +266,40 @@ export function setGridPropsCommands(
266266
columnStart === columnEnd - 1
267267
) {
268268
commands.push(
269-
setProperty('always', elementPath, PP.create('style', 'gridColumn'), areaColumnStart),
269+
setProperty('always', elementPath, PP.create('style', 'gridColumn'), lineColumnStart),
270270
)
271271
} else {
272272
if (columnStart != null) {
273273
commands.push(
274-
setProperty('always', elementPath, PP.create('style', 'gridColumnStart'), areaColumnStart),
274+
setProperty('always', elementPath, PP.create('style', 'gridColumnStart'), lineColumnStart),
275275
)
276276
}
277277
if (columnEnd != null) {
278278
commands.push(
279-
setProperty('always', elementPath, PP.create('style', 'gridColumnEnd'), areaColumnEnd),
279+
setProperty('always', elementPath, PP.create('style', 'gridColumnEnd'), lineColumnEnd),
280280
)
281281
}
282282
}
283283

284284
if (rowStart != null && rowStart === rowEnd) {
285-
commands.push(setProperty('always', elementPath, PP.create('style', 'gridRow'), areaRowStart))
285+
commands.push(setProperty('always', elementPath, PP.create('style', 'gridRow'), lineRowStart))
286286
} else if (
287287
rowStart != null &&
288288
typeof rowStart === 'number' &&
289289
rowEnd != null &&
290290
typeof rowEnd === 'number' &&
291291
rowStart === rowEnd - 1
292292
) {
293-
commands.push(setProperty('always', elementPath, PP.create('style', 'gridRow'), areaRowStart))
293+
commands.push(setProperty('always', elementPath, PP.create('style', 'gridRow'), lineRowStart))
294294
} else {
295295
if (rowStart != null) {
296296
commands.push(
297-
setProperty('always', elementPath, PP.create('style', 'gridRowStart'), areaRowStart),
297+
setProperty('always', elementPath, PP.create('style', 'gridRowStart'), lineRowStart),
298298
)
299299
}
300300
if (rowEnd != null) {
301301
commands.push(
302-
setProperty('always', elementPath, PP.create('style', 'gridRowEnd'), areaRowEnd),
302+
setProperty('always', elementPath, PP.create('style', 'gridRowEnd'), lineRowEnd),
303303
)
304304
}
305305
}
@@ -352,7 +352,7 @@ function getCellCoordsDelta(
352352
return gridCellCoordinates(rowDiff, columnDiff)
353353
}
354354

355-
function asMaybeNamedAreaOrValue(
355+
function asMaybeNamedLineOrValue(
356356
grid: GridContainerProperties,
357357
axis: 'row' | 'column',
358358
value: number | string | null,
@@ -362,9 +362,9 @@ function asMaybeNamedAreaOrValue(
362362
} else if (typeof value === 'number') {
363363
const template = axis === 'row' ? grid.gridTemplateRows : grid.gridTemplateColumns
364364
if (template?.type === 'DIMENSIONS') {
365-
const maybeAreaStart = template.dimensions.at(value - 1)
366-
if (maybeAreaStart != null && maybeAreaStart.areaName != null) {
367-
return maybeAreaStart.areaName
365+
const maybeLineStart = template.dimensions.at(value - 1)
366+
if (maybeLineStart != null && maybeLineStart.lineName != null) {
367+
return maybeLineStart.lineName
368368
}
369369
}
370370
return value === 0 ? 1 : value
@@ -602,12 +602,12 @@ function alterGridTemplateDimensions(params: {
602602
if (before.length + after.length === 0) {
603603
return null
604604
}
605-
return gridCSSRepeat(dim.times, [...before, ...after], dim.areaName)
605+
return gridCSSRepeat(dim.times, [...before, ...after], dim.lineName)
606606
case 'REPLACE':
607607
return gridCSSRepeat(
608608
dim.times,
609609
[...before, params.patch.newValue, ...after],
610-
dim.areaName,
610+
dim.lineName,
611611
)
612612
default:
613613
assertNever(params.patch)

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export const resizeGridStrategy: CanvasStrategyFactory = (
165165

166166
const isFractional = mergedUnit.value === 'fr'
167167
const precision = modifiers.cmd ? 'coarse' : 'precise'
168-
const areaName = mergedValues.dimensions[control.columnOrRow]?.areaName ?? null
168+
const lineName = mergedValues.dimensions[control.columnOrRow]?.lineName ?? null
169169

170170
const newValue = Math.max(
171171
0,
@@ -181,7 +181,7 @@ export const resizeGridStrategy: CanvasStrategyFactory = (
181181
originalValues.dimensions,
182182
expandedOriginalValues,
183183
control.columnOrRow,
184-
gridCSSNumber(cssNumber(newValue, mergedUnit.value), areaName),
184+
gridCSSNumber(cssNumber(newValue, mergedUnit.value), lineName),
185185
)
186186

187187
const propertyValueAsString = printArrayGridDimensions(newDimensions)

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ const GridResizingStripedIndicator = React.memo((props: GridResizingControlProps
309309
}}
310310
>
311311
{when(
312-
props.dimension.areaName != null,
312+
props.dimension.lineName != null,
313313
<div
314314
style={{
315315
position: 'absolute',
@@ -321,7 +321,7 @@ const GridResizingStripedIndicator = React.memo((props: GridResizingControlProps
321321
borderRadius: '0 0 3px 0',
322322
}}
323323
>
324-
{props.dimension.areaName}
324+
{props.dimension.lineName}
325325
</div>,
326326
)}
327327
</div>,

editor/src/components/editor/store/store-deep-equality-instances.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1977,7 +1977,7 @@ export const GridCSSNumberKeepDeepEquality: KeepDeepEqualityCall<GridCSSNumber>
19771977
combine2EqualityCalls(
19781978
(p) => p.value,
19791979
CSSNumberKeepDeepEquality,
1980-
(p) => p.areaName,
1980+
(p) => p.lineName,
19811981
NullableStringKeepDeepEquality,
19821982
gridCSSNumber,
19831983
)
@@ -1986,7 +1986,7 @@ export const GridCSSKeywordKeepDeepEquality: KeepDeepEqualityCall<GridCSSKeyword
19861986
combine2EqualityCalls(
19871987
(p) => p.value,
19881988
createCallWithTripleEquals(),
1989-
(p) => p.areaName,
1989+
(p) => p.lineName,
19901990
NullableStringKeepDeepEquality,
19911991
gridCSSKeyword,
19921992
)
@@ -2030,7 +2030,7 @@ export const GridCSSRepeatKeepDeepEquality: KeepDeepEqualityCall<GridCSSRepeat>
20302030
createCallWithTripleEquals(),
20312031
(p) => p.value,
20322032
arrayDeepEquality(GridDimensionKeepDeepEquality),
2033-
(p) => p.areaName,
2033+
(p) => p.lineName,
20342034
NullableStringKeepDeepEquality,
20352035
gridCSSRepeat,
20362036
)
@@ -2064,7 +2064,7 @@ export const GridCSSMinmaxKeepDeepEquality: KeepDeepEqualityCall<GridCSSMinmax>
20642064
GridCSSNumberOrKeywordKeepDeepEquality,
20652065
(p) => p.max,
20662066
GridCSSNumberOrKeywordKeepDeepEquality,
2067-
(p) => p.areaName,
2067+
(p) => p.lineName,
20682068
NullableStringKeepDeepEquality,
20692069
gridCSSMinmax,
20702070
)

0 commit comments

Comments
 (0)