Module:Infobox: Difference between revisions
Appearance
base infobox |
uses common colors |
||
| Line 6: | Line 6: | ||
:addClass('infobox') | :addClass('infobox') | ||
:css('width', '250px') | :css('width', '250px') | ||
:css('border', '1px solid | :css('border', '1px solid var(--vw-bg-subtle)') | ||
:css('font-size', '90%') | :css('font-size', '90%') | ||
:css('float', 'right') | :css('float', 'right') | ||
:css('margin', '0 0 1em 1em') | :css('margin', '0 0 1em 1em') | ||
:css('border-collapse', 'collapse') | :css('border-collapse', 'collapse') | ||
:css('background', ' | :css('background', 'var(--vw-bg-surface)') | ||
-- Title | |||
if args.title and args.title ~= '' then | if args.title and args.title ~= '' then | ||
root:tag('tr') | root:tag('tr') | ||
| Line 19: | Line 19: | ||
:attr('colspan', '2') | :attr('colspan', '2') | ||
:css('text-align', 'center') | :css('text-align', 'center') | ||
:css('background', ' | :css('background', 'var(--vw-accent)') | ||
:css('color', ' | :css('color', 'var(--vw-bg-page)') | ||
:css('padding', '6px') | :css('padding', '6px') | ||
:wikitext(args.title) | :wikitext(args.title) | ||
end | end | ||
-- Image | -- Image | ||
if args.image and args.image ~= '' then | if args.image and args.image ~= '' then | ||
| Line 56: | Line 56: | ||
:css('text-align', 'left') | :css('text-align', 'left') | ||
:css('padding', '4px 6px') | :css('padding', '4px 6px') | ||
:css('background', ' | :css('background', 'var(--vw-accent-subtle)') | ||
:css('width', '45%') | :css('width', '45%') | ||
:wikitext(label) | :wikitext(label) | ||
Revision as of 22:48, 13 April 2026
Documentation for this module may be created at Module:Infobox/doc
local p = {}
function p.render(frame)
local args = frame:getParent().args
local root = mw.html.create('table')
:addClass('infobox')
:css('width', '250px')
:css('border', '1px solid var(--vw-bg-subtle)')
:css('font-size', '90%')
:css('float', 'right')
:css('margin', '0 0 1em 1em')
:css('border-collapse', 'collapse')
:css('background', 'var(--vw-bg-surface)')
-- Title
if args.title and args.title ~= '' then
root:tag('tr')
:tag('th')
:attr('colspan', '2')
:css('text-align', 'center')
:css('background', 'var(--vw-accent)')
:css('color', 'var(--vw-bg-page)')
:css('padding', '6px')
:wikitext(args.title)
end
-- Image
if args.image and args.image ~= '' then
local caption = args.caption or ''
root:tag('tr')
:tag('td')
:attr('colspan', '2')
:css('text-align', 'center')
:css('padding', '6px')
:wikitext('[[File:' .. args.image .. '|200px]]')
if caption ~= '' then
root:tag('tr')
:tag('td')
:attr('colspan', '2')
:css('text-align', 'center')
:css('font-size', '85%')
:css('padding', '2px 6px')
:wikitext(caption)
end
end
-- Data rows
local i = 1
while args['label' .. i] or args['data' .. i] do
local label = args['label' .. i]
local data = args['data' .. i]
if data and data ~= '' then
local row = root:tag('tr')
if label and label ~= '' then
row:tag('th')
:css('text-align', 'left')
:css('padding', '4px 6px')
:css('background', 'var(--vw-accent-subtle)')
:css('width', '45%')
:wikitext(label)
end
row:tag('td')
:css('padding', '4px 6px')
:attr('colspan', (label and label ~= '') and '1' or '2')
:wikitext(data)
end
i = i + 1
end
return tostring(root)
end
return p