Module:MasonryLayout: Difference between revisions

// via Wikitext Extension for VSCode
// via Wikitext Extension for VSCode
Line 129: Line 129:
      
      
     return TemplateHelpers.withCache(cacheKey, function()
     return TemplateHelpers.withCache(cacheKey, function()
         -- Base height calculation
        -- Special handling for intro cards (text content, not tables)
        if cardData.contentType == 'intro' then
            local textLength = cardData.contentLength or 0
            local estimatedHeight = math.max(80, math.min(200, textLength / 4))
            return estimatedHeight
        end
       
        -- Special handling for infoBox to ensure conservative estimation
        if cardData.contentType == 'infoBox' then
            local baseHeight = SIZE_ESTIMATES.BASE_CARD_HEIGHT * 0.8 -- More conservative base
            local rowCount = cardData.rowCount or 5 -- Default to 5 rows for infoBox
            local rowHeight = rowCount * SIZE_ESTIMATES.ROW_HEIGHT
            return baseHeight + rowHeight
        end
       
         -- Base height calculation for regular cards
         local baseHeight = SIZE_ESTIMATES.BASE_CARD_HEIGHT
         local baseHeight = SIZE_ESTIMATES.BASE_CARD_HEIGHT