Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
ruggi committed Jul 15, 2024
1 parent dd4cff1 commit 366c79d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions editor/src/components/canvas/controls/grid-controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ export const GridResizingControl = React.memo((props: GridResizingControlProps)
>
{props.axis === 'row' ? '↕' : '↔'}
{when(
props.dimension.label != null,
<span style={{ position: 'absolute', top: 12 }}>{props.dimension.label}</span>,
props.dimension.areaName != null,
<span style={{ position: 'absolute', top: 12 }}>{props.dimension.areaName}</span>,
)}
</div>
{when(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1975,7 +1975,7 @@ export const GridCSSNumberKeepDeepEquality: KeepDeepEqualityCall<GridCSSNumber>
createCallWithTripleEquals<number>(),
(cssNum) => cssNum.unit,
nullableDeepEquality(createCallWithTripleEquals<GridCSSNumberUnit>()),
(cssNum) => cssNum.label,
(cssNum) => cssNum.areaName,
nullableDeepEquality(StringKeepDeepEquality),
gridCSSNumber,
)
Expand Down
30 changes: 16 additions & 14 deletions editor/src/components/inspector/common/css-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,18 +589,18 @@ const GridCSSNumberUnits: Array<GridCSSNumberUnit> = [...LengthUnits, ...Resolut
export interface GridCSSNumber {
value: number
unit: GridCSSNumberUnit | null
label: string | null
areaName: string | null
}

export function gridCSSNumber(
value: number,
unit: GridCSSNumberUnit | null,
label: string | null,
areaName: string | null,
): GridCSSNumber {
return {
value,
unit,
label,
value: value,
unit: unit,
areaName: areaName,
}
}

Expand Down Expand Up @@ -768,9 +768,9 @@ export function printArrayCSSNumber(array: Array<GridCSSNumber>): string {
return array
.map((dimension) => {
const printed = printCSSNumber(dimension, null)
const label = dimension.label != null ? `[${dimension.label}] ` : ''
const areaName = dimension.areaName != null ? `[${dimension.areaName}] ` : ''
const value = typeof printed === 'string' ? printed : `${printed}`
return `${label}${value}`
return `${areaName}${value}`
})
.join(' ')
}
Expand Down Expand Up @@ -850,20 +850,20 @@ export function parseToCSSGridNumber(input: unknown): Either<string, GridCSSNumb
const match = input.match(gridCSSTemplateNumberRegex)
if (match != null) {
return {
label: match[1],
areaName: match[1],
inputToParse: match[2],
}
}
}
return { label: null, inputToParse: input }
return { areaName: null, inputToParse: input }
}
const { label, inputToParse } = getParts()
const { areaName, inputToParse } = getParts()

return mapEither((value) => {
return {
value: value.value,
unit: value.unit as GridCSSNumberUnit | null,
label: label,
areaName: areaName,
}
}, parseCSSGrid(inputToParse))
}
Expand Down Expand Up @@ -912,6 +912,8 @@ export function parseGridRange(input: unknown): Either<string, GridRange> {
}
}

const reGridAreaNameBrackets = /^\[.+\]$/

export function tokenizeGridTemplate(str: string): string[] {
let tokens: string[] = []
let parts = str.replace(/\]/g, '] ').split(/\s+/)
Expand All @@ -921,9 +923,9 @@ export function tokenizeGridTemplate(str: string): string[] {
if (part == null) {
break
}
if (part.match(/^\[.+\]$/) != null && parts.length > 0) {
const withLabel = `${part} ${parts.shift()}`
tokens.push(withLabel)
if (part.match(reGridAreaNameBrackets) != null && parts.length > 0) {
const withAreaName = `${part} ${parts.shift()}`
tokens.push(withAreaName)
} else {
tokens.push(part)
}
Expand Down

0 comments on commit 366c79d

Please sign in to comment.