Skip to content

Commit

Permalink
factor out isDynamicGridTemplate
Browse files Browse the repository at this point in the history
  • Loading branch information
ruggi committed Oct 8, 2024
1 parent 9cc1134 commit bee4923
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions editor/src/components/canvas/dom-walker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -931,16 +931,8 @@ function getSpecialMeasurements(

const containerGridPropertiesFromProps = getGridContainerProperties(element.style)
const containerGridProperties = getGridContainerProperties(elementStyle, {
dynamicCols:
containerGridPropertiesFromProps.gridTemplateColumns?.type === 'DIMENSIONS' &&
containerGridPropertiesFromProps.gridTemplateColumns.dimensions.some((d) =>
isDynamicGridRepeat(d),
),
dynamicRows:
containerGridPropertiesFromProps.gridTemplateRows?.type === 'DIMENSIONS' &&
containerGridPropertiesFromProps.gridTemplateRows.dimensions.some((d) =>
isDynamicGridRepeat(d),
),
dynamicCols: isDynamicGridTemplate(containerGridPropertiesFromProps.gridTemplateColumns),
dynamicRows: isDynamicGridTemplate(containerGridPropertiesFromProps.gridTemplateRows),
})

const containerElementPropertiesFromProps = getGridElementProperties(
Expand Down Expand Up @@ -1009,6 +1001,10 @@ function getSpecialMeasurements(
)
}

function isDynamicGridTemplate(template: GridAutoOrTemplateBase | null) {
return template?.type === 'DIMENSIONS' && template.dimensions.some((d) => isDynamicGridRepeat(d))
}

function elementContainsOnlyText(element: HTMLElement): boolean {
if (element.childNodes.length === 0) {
return false
Expand Down

0 comments on commit bee4923

Please sign in to comment.