Module:Infobox

local p = {}

local function printRow(dl, row) if row.content == nil then return end dl:tag('dt') :cssText('grid-column-start: 1; padding: 2px 8px 2px 3px; text-align: right; border-right: 2px solid #aaa; margin: 0 -2px 0 0;') :wikitext(row.label) dl:tag('dd') :cssText('grid-column-start: 2; margin: 0; padding: 2px 7px; border-left: 2px solid #aaa;') :wikitext(row.content) end

function p._main(args) local infoboxType = args.infoboxType local title = args.title local icon = args.icon local rows = args.rows local root = mw.html.create('div') root :addClass('infobox '..infoboxType) :cssText('float: right; margin-left: 15px; width: 300px; border: 1px solid #aaa; background: #eee; font-size: 12px;') local heading = root:tag('div') heading :addClass('heading') :cssText('background: goldenrod; font-weight: 700; font-size: 140%; line-height: 1.25em; display: flex; flex-direction: row; justify-items: flex-start; text-align: center; min-height: 64px;') :tag('div') :addClass('infobox-icon') :cssText('flex: 0 0 64px; padding: 0.25rem;') -- For now, let's just pass in the icon, whether it's rendered or a simple file link. -- TODO: Maybe handle the icon in this module instead? :wikitext(icon) :done :tag('p') :addClass('name') :cssText('flex: 1 1 100%; display: flex; text-align: center; align-items: center; justify-content: center; margin: 0; padding: 0.25rem;') :wikitext(title) :done local wrapper = root:tag('div') wrapper :addClass('wrapper') :cssText('flex: 1 1 100%; overflow: hidden;') local dl = wrapper:tag('dl') dl:cssText('display: grid; grid-template-columns: 100px 1fr;') for i, row in ipairs(rows) do		printRow(dl, row) end return tostring(root) end

return p