Module:ReceptionTable

From JoJo's Bizarre Encyclopedia - JoJo Wiki
Revision as of 03:22, 25 February 2024 by Paisley Park (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'

    -- Added a style for background color to the table and set a minimum width for the date column
    local header = '{| class="wikitable receptionTable diamonds"\n'
    -- Updated to include the 'part' variable as a class for each header cell and added a color parameter for each
    header = header .. '! class="' .. part .. '" style="color:' .. headerColor .. ';" | Volume\n'
    header = header .. '! class="' .. part .. '" style="min-width:150px; color:' .. headerColor .. ';" | Date\n'
    header = header .. '! class="' .. part .. '" style="color:' .. headerColor .. ';" | Copies Sold\n'
    header = header .. '! class="' .. part .. '" style="color:' .. headerColor .. ';" | Rank\n'
    return header
end

-- Function to create a row in the table
function p.row(frame)
    local volume = frame.args.volume or ''
    local date = frame.args.date or ''
    local copiesSold = frame.args.copiesSold or ''
    local rank = frame.args.rank or ''
    local rowspan = frame.args.rowspan or 1
    
    -- Create the row with the necessary cells and rowspan
    local row = '|-\n'
    if volume ~= '' then
        row = row .. '! rowspan="' .. rowspan .. '" | ' .. volume .. '\n'
    end
    -- No background color for date as per your last message
    row = row .. '| ' .. date .. '\n| ' .. copiesSold .. '\n| ' .. rank .. '\n'
    return row
end

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

return p