* Gets metrics for a container block
(block: BlockState)
| 120 | * Gets metrics for a container block |
| 121 | */ |
| 122 | function getContainerMetrics(block: BlockState): BlockMetrics { |
| 123 | const measuredWidth = block.layout?.measuredWidth |
| 124 | const measuredHeight = block.layout?.measuredHeight |
| 125 | |
| 126 | const containerWidth = Math.max( |
| 127 | measuredWidth ?? 0, |
| 128 | resolveNumeric(block.data?.width, CONTAINER_DIMENSIONS.DEFAULT_WIDTH) |
| 129 | ) |
| 130 | const containerHeight = Math.max( |
| 131 | measuredHeight ?? 0, |
| 132 | resolveNumeric(block.data?.height, CONTAINER_DIMENSIONS.DEFAULT_HEIGHT) |
| 133 | ) |
| 134 | |
| 135 | return { |
| 136 | width: containerWidth, |
| 137 | height: containerHeight, |
| 138 | minWidth: CONTAINER_DIMENSIONS.DEFAULT_WIDTH, |
| 139 | minHeight: CONTAINER_DIMENSIONS.DEFAULT_HEIGHT, |
| 140 | paddingTop: BLOCK_DIMENSIONS.HEADER_HEIGHT, |
| 141 | paddingBottom: BLOCK_DIMENSIONS.HEADER_HEIGHT, |
| 142 | paddingLeft: BLOCK_DIMENSIONS.HEADER_HEIGHT, |
| 143 | paddingRight: BLOCK_DIMENSIONS.HEADER_HEIGHT, |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * Counts visible preview subblocks using the same visibility rules as the |
no test coverage detected