Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/concrete-utopia/utopia in…
Browse files Browse the repository at this point in the history
…to spike/plugin-prop-setter
  • Loading branch information
bkrmendy committed Oct 25, 2024
2 parents edcdf24 + fc4cfb4 commit 8d0953f
Show file tree
Hide file tree
Showing 19 changed files with 688 additions and 172 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ jobs:
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
## [Try me](https://${{ secrets.STAGING_SERVER }}/p/?accessLevel=public&branch_name=${{ steps.extract_branch.outputs.branch }})
## [Try me](https://${{ secrets.STAGING_SERVER }}/p/?accessLevel=public&clone=concrete-utopia/hydrogen-editions-24&branch_name=${{ steps.extract_branch.outputs.branch }})
performance-test:
name: Run Performance Tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,14 @@ export function setGridPropsCommands(
const rowStart = gridPositionToValue(gridProps.gridRowStart)
const rowEnd = gridPositionToValue(gridProps.gridRowEnd)

const areaColumnStart = asMaybeNamedAreaOrValue(gridTemplate, 'column', columnStart)
const areaColumnEnd = asMaybeNamedAreaOrValue(gridTemplate, 'column', columnEnd)
const areaRowStart = asMaybeNamedAreaOrValue(gridTemplate, 'row', rowStart)
const areaRowEnd = asMaybeNamedAreaOrValue(gridTemplate, 'row', rowEnd)
const lineColumnStart = asMaybeNamedLineOrValue(gridTemplate, 'column', columnStart)
const lineColumnEnd = asMaybeNamedLineOrValue(gridTemplate, 'column', columnEnd)
const lineRowStart = asMaybeNamedLineOrValue(gridTemplate, 'row', rowStart)
const lineRowEnd = asMaybeNamedLineOrValue(gridTemplate, 'row', rowEnd)

if (columnStart != null && columnStart === columnEnd) {
commands.push(
setProperty('always', elementPath, PP.create('style', 'gridColumn'), areaColumnStart),
setProperty('always', elementPath, PP.create('style', 'gridColumn'), lineColumnStart),
)
} else if (
columnStart != null &&
Expand All @@ -266,40 +266,40 @@ export function setGridPropsCommands(
columnStart === columnEnd - 1
) {
commands.push(
setProperty('always', elementPath, PP.create('style', 'gridColumn'), areaColumnStart),
setProperty('always', elementPath, PP.create('style', 'gridColumn'), lineColumnStart),
)
} else {
if (columnStart != null) {
commands.push(
setProperty('always', elementPath, PP.create('style', 'gridColumnStart'), areaColumnStart),
setProperty('always', elementPath, PP.create('style', 'gridColumnStart'), lineColumnStart),
)
}
if (columnEnd != null) {
commands.push(
setProperty('always', elementPath, PP.create('style', 'gridColumnEnd'), areaColumnEnd),
setProperty('always', elementPath, PP.create('style', 'gridColumnEnd'), lineColumnEnd),
)
}
}

if (rowStart != null && rowStart === rowEnd) {
commands.push(setProperty('always', elementPath, PP.create('style', 'gridRow'), areaRowStart))
commands.push(setProperty('always', elementPath, PP.create('style', 'gridRow'), lineRowStart))
} else if (
rowStart != null &&
typeof rowStart === 'number' &&
rowEnd != null &&
typeof rowEnd === 'number' &&
rowStart === rowEnd - 1
) {
commands.push(setProperty('always', elementPath, PP.create('style', 'gridRow'), areaRowStart))
commands.push(setProperty('always', elementPath, PP.create('style', 'gridRow'), lineRowStart))
} else {
if (rowStart != null) {
commands.push(
setProperty('always', elementPath, PP.create('style', 'gridRowStart'), areaRowStart),
setProperty('always', elementPath, PP.create('style', 'gridRowStart'), lineRowStart),
)
}
if (rowEnd != null) {
commands.push(
setProperty('always', elementPath, PP.create('style', 'gridRowEnd'), areaRowEnd),
setProperty('always', elementPath, PP.create('style', 'gridRowEnd'), lineRowEnd),
)
}
}
Expand Down Expand Up @@ -352,7 +352,7 @@ function getCellCoordsDelta(
return gridCellCoordinates(rowDiff, columnDiff)
}

function asMaybeNamedAreaOrValue(
function asMaybeNamedLineOrValue(
grid: GridContainerProperties,
axis: 'row' | 'column',
value: number | string | null,
Expand All @@ -362,9 +362,9 @@ function asMaybeNamedAreaOrValue(
} else if (typeof value === 'number') {
const template = axis === 'row' ? grid.gridTemplateRows : grid.gridTemplateColumns
if (template?.type === 'DIMENSIONS') {
const maybeAreaStart = template.dimensions.at(value - 1)
if (maybeAreaStart != null && maybeAreaStart.areaName != null) {
return maybeAreaStart.areaName
const maybeLineStart = template.dimensions.at(value - 1)
if (maybeLineStart != null && maybeLineStart.lineName != null) {
return maybeLineStart.lineName
}
}
return value === 0 ? 1 : value
Expand Down Expand Up @@ -602,12 +602,12 @@ function alterGridTemplateDimensions(params: {
if (before.length + after.length === 0) {
return null
}
return gridCSSRepeat(dim.times, [...before, ...after], dim.areaName)
return gridCSSRepeat(dim.times, [...before, ...after], dim.lineName)
case 'REPLACE':
return gridCSSRepeat(
dim.times,
[...before, params.patch.newValue, ...after],
dim.areaName,
dim.lineName,
)
default:
assertNever(params.patch)
Expand Down Expand Up @@ -788,3 +788,12 @@ export function findOriginalGrid(

return findOriginalGrid(metadata, parentPath)
}

// Returns whether the given dimensions are made of just one item, being a CSS keyword with value "auto".
export function isJustAutoGridDimension(dimensions: GridDimension[]): boolean {
return (
dimensions.length === 1 &&
dimensions[0].type === 'KEYWORD' &&
dimensions[0].value.value === 'auto'
)
}
Loading

0 comments on commit 8d0953f

Please sign in to comment.