Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:S5TechniqueTable: Difference between revisions

From Gensopedia
mNo edit summary
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 6: Line 6:
         :addClass('table')
         :addClass('table')
         :css('border', '1px solid #0077c0')
         :css('border', '1px solid #0077c0')
        :css('font-size', '90%')
       
    -- Inject responsive CSS (font size drops to 80% at ≤ 360px)
    local style = mw.html.create('style'):wikitext([[
@media screen and (max-width: 360px) {
    .attacktable-responsive {
        font-size: 80%;
    }
}
]])


     -- Add identifying class for CSS
     -- Add identifying class for CSS

Latest revision as of 16:52, 10 December 2025

Documentation for this module may be created at Module:S5TechniqueTable/doc

local p = {}

function p.render(frame)
    -- Create outer table
    local tbl = mw.html.create('table')
        :addClass('table')
        :css('border', '1px solid #0077c0')

    -- Add identifying class for CSS
    tbl:addClass('attacktable-responsive')

    -- Header row
    local headerRow = tbl:tag('tr')
    local headers = {
        { text = 'Name',    width = '35%', border = 'border-top-left-radius:0;' },
        { text = 'Type',    width = '10%' },
        { text = 'Element', width = '10%' },
        { text = 'Target',  width = '10%' },
        { text = 'Effect',  width = '35%', border = 'border-top-right-radius:0;' }
    }

    for _, h in ipairs(headers) do
        headerRow:tag('th')
            :addClass('header')
            :cssText(h.border or '')
            :css('width', h.width)
            :css('text-align', 'center')
            :wikitext(h.text)
            :done()
    end

    -- Collect rows
    for i = 1, 7 do
        local attack = frame.args['attack_' .. i]
        if attack and attack ~= '' then
            local r = tbl:tag('tr')
            r:tag('td'):wikitext(attack or 'Attack ' .. i)
            r:tag('td'):wikitext(frame.args['type_' .. i] or 'Physical')
            r:tag('td'):wikitext(frame.args['element_' .. i] or 'Darkness')
            r:tag('td'):wikitext(frame.args['range_' .. i] or 'Single')
            r:tag('td'):wikitext(frame.args['effect_' .. i] or '—')
        end
    end

    return tostring(tbl)
end

return p