Module:NavboxMobile: Difference between revisions

No edit summary
No edit summary
Line 295: Line 295:


         if args[groupKey] then
         if args[groupKey] then
            -- Add custom inline styles based on group levels
            local inlineStyles = ""
             -- Render the group (heading)
             -- Render the group (heading)
             local groupRow = addTableRow(tbl)
             local groupRow = addTableRow(tbl)
Line 305: Line 302:
                 :addClass('navboxMobile-group-level' .. parentLevel) -- Level-specific class
                 :addClass('navboxMobile-group-level' .. parentLevel) -- Level-specific class
                 :attr('data-level', parentLevel) -- Optional attribute for CSS targeting
                 :attr('data-level', parentLevel) -- Optional attribute for CSS targeting
                :cssText(inlineStyles)
                 :wikitext(processItem(args[groupKey]))
                 :wikitext(processItem(args[groupKey]))


Line 313: Line 309:
                 local listCell = listRow:tag('td')
                 local listCell = listRow:tag('td')
                     :attr('colspan', 2)
                     :attr('colspan', 2)
                     :addClass('navboxMobile-list-content')
                     :addClass('navboxMobile-list-content') -- Base content class
                     :addClass('navboxMobile-list-level' .. parentLevel) -- Level-specific class
                     :addClass('navboxMobile-list-level' .. parentLevel) -- Level-specific class
                     :addClass((i % 2 == 1) and 'navboxMobile-odd' or 'navboxMobile-even')
                     :addClass((i % 2 == 1) and 'navboxMobile-odd' or 'navboxMobile-even') -- Odd/even styling
                     :css('padding', '0 0.25em')
                     :addClass('hlist') -- Maintain hlist styling
                    :css('width', parentLevel == 2 and '95%' or '90%') -- Adjust width for narrowing
                     :wikitext(processItem(args[listKey], args.nowrapitems))
                     :cssText(inlineStyles) -- Apply the same styles as the group heading
                    :cssText(args[listKey .. 'style'])


                 if args[listKey] == 'child' then
                 if args[listKey] == 'child' then
                     local newPath = (path ~= "" and path .. "_" or "") .. i
                     local newPath = (path ~= "" and path .. "_" or "") .. i
                     renderListRow(tbl, tostring(newPath), parentLevel + 1)
                     renderListRow(tbl, tostring(newPath), parentLevel + 1)
                else
                    listCell
                        :addClass('hlist')
                        :wikitext(processItem(args[listKey], args.nowrapitems))
                 end
                 end
             end
             end
Line 333: Line 323:
     end
     end
end
end