Module:Infobox: Difference between revisions

reducing some padding
padding 0.5em 1em
 
(15 intermediate revisions by the same user not shown)
Line 4: Line 4:
local args = frame:getParent().args
local args = frame:getParent().args
local root = mw.html.create('table')
local root = mw.html.create('table')
:addClass('infobox')
    :addClass('infobox')
:css('border', '1px solid var(--vw-border)')
    :css('border', '1px solid var(--vw-border)')
:css('font-size', '90%')
    :css('border-radius', '4px')
:css('background', 'var(--vw-bg-subtle)')
    :css('overflow', 'hidden')
    :css('font-size', '90%')
    :css('background', 'var(--vw-bg-subtle)')
    :css('padding-bottom', '4px')
-- Title
local light = (args['titlebg-light'] and args['titlebg-light'] ~= '') and args['titlebg-light'] or 'var(--vw-accent-subtle)'
local dark  = (args['titlebg-dark']  and args['titlebg-dark']  ~= '') and args['titlebg-dark']  or 'var(--vw-accent-subtle)'
local titlebg = 'light-dark(' .. light .. ', ' .. dark .. ')'
if args.title and args.title ~= '' then
if args.title and args.title ~= '' then
root:tag('tr')
    root:tag('tr')
:tag('th')
        :tag('th')
:attr('colspan', '2')
            :attr('colspan', '2')
:css('width', '100%')
            :css('width', '100%')
:css('text-align', 'center')
            :css('text-align', 'center')
:css('font-size', '115%')
            :css('font-size', '125%')
:css('background', 'var(--vw-accent-subtle)')
            :css('background', titlebg)
:css('padding', '6px')
            :css('padding', '0.5em 1em')
:wikitext(args.title)
            :wikitext(args.title)
end
end
-- Image
-- Image
if args.image and args.image ~= '' then
if args.image and args.image ~= '' then
local caption = args.caption or ''
    local caption = args.caption or ''
root:tag('tr')
    local imgBottomPad = caption ~= '' and '6px 6px 2px 6px' or '6px'
:tag('td')
    root:tag('tr')
:attr('colspan', '2')
        :tag('td')
:css('text-align', 'center')
            :attr('colspan', '2')
:css('padding', '6px')
            :css('text-align', 'center')
:wikitext('[[File:' .. args.image .. '|300px]]')
            :css('padding', imgBottomPad)
if caption ~= '' then
            :wikitext('[[File:' .. args.image .. '|300px]]')
root:tag('tr')
    if caption ~= '' then
:tag('td')
        root:tag('tr')
:attr('colspan', '2')
            :tag('td')
:css('text-align', 'center')
                :attr('colspan', '2')
:css('font-size', '90%')
                :css('text-align', 'center')
:css('padding', '2px 6px')
                :css('padding', '0px 6px 4px 6px')
:wikitext(caption)
                :wikitext(caption)
end
    end
end
end


Line 57: Line 63:
:css('background', 'var(--vw-bg-heading)')
:css('background', 'var(--vw-bg-heading)')
:css('padding', '4px 6px')
:css('padding', '4px 6px')
:css('font-size', '90%')
:wikitext(header)
:wikitext(header)
elseif data and data ~= '' then
elseif data and data ~= '' then
Line 64: Line 69:
row:tag('th')
row:tag('th')
:css('text-align', 'left')
:css('text-align', 'left')
:css('padding', '2px 6px')
:css('padding', '2px 6px 2px 6px')
:css('background', 'var(--vw-bg-subtle)')
:css('background', 'var(--vw-bg-subtle)')
:css('width', '45%')
:css('width', '45%')
Line 70: Line 75:
end
end
row:tag('td')
row:tag('td')
:css('padding', '2px 6px')
:css('padding', '2px 6px 2px 6px')
:attr('colspan', (label and label ~= '') and '1' or '2')
:attr('colspan', (label and label ~= '') and '1' or '2')
:wikitext(data)
:wikitext(data)