Module:ReceptionTable

From JoJo's Bizarre Encyclopedia - JoJo Wiki
Revision as of 17:03, 25 February 2024 by Vish (talk | contribs)
Jump to navigation Jump to search

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

local p = {}

-- Function to create the header of the table
function p.header(frame)
    local part = frame.args.part or 'pb'
    local headerColor = frame.args.headerColor or '#ffffff'
    local width = frame.args.width or '80%'
    local borderColor = frame.args.borderColor or 'var(--' .. string.lower(part) .. '2)'

    local header = '{| class="wikitable receptionTable diamonds" style="width:' .. width .. '; border: 2px groove ' .. borderColor .. '\n'
    header = header .. '! class="receptionTableHeader ' .. part .. '" style="color:' .. headerColor .. ';" | Volume\n'
    header = header .. '! class="receptionTableHeader ' .. part .. '" style="min-width:150px; color:' .. headerColor .. ';" | Date\n'
    header = header .. '! class="receptionTableHeader ' .. part .. '" style="color:' .. headerColor .. ';" | Rank\n'
    header = header .. '! class="receptionTableHeader ' .. part .. '" style="color:' .. headerColor .. ';" | Copies Sold\n'
    header = header .. '! class="receptionTableHeader ' .. part .. '" style="color:' .. headerColor .. ';" | Total\n'
    return header
end

-- Function to create a row in the table
function p.row(frame)
	local part = frame.args.part or 'pb'
    local volume = frame.args.volume or ''
    local date = frame.args.date or ''
    local rank = frame.args.rank or ''
    local copiesSold = frame.args.copiesSold or ''
    local total = frame.args.total or ''
    local rowspan = frame.args.rowspan or 1
    
    -- Create the row with the necessary cells and rowspan
    local row = '|-'
    if volume ~= '' then
        row = row .. 'class="receptionTableSection"\n! class="receptionTableImage ' .. part .. '4 diamonds"' .. 'style="width:5%;" rowspan="' .. rowspan .. '" | ' .. volume .. '\n'
    end
    row = row .. '\n| ' .. date .. '\n| ' .. rank .. '\n| ' .. copiesSold .. '\n| ' .. total
    return row
end

-- Function to close the table
function p.footer(frame)
    return '|}\n'
end

return p