Module:Sandbox/LVL: Difference between revisions

Jump to navigation Jump to search
LVL (talk | contribs)
No edit summary
LVL (talk | contribs)
No edit summary
Line 467: Line 467:
-- Initializations and declarations
-- Initializations and declarations
local row_str = ""
local body_rows_str = ""
local body_str = ""
local in_development
local in_development
local is_disabled
local is_disabled
Line 524: Line 523:
if (not is_disabled) then  
if (not is_disabled) then  
--Add the row's stats
local row_content = ""
row_str = ""
-- Retrieve hero's localized name
-- Retrieve hero's localized name
Line 539: Line 537:
hero_icon = mw.getCurrentFrame():expandTemplate{ title = template_title, args = template_args }
hero_icon = mw.getCurrentFrame():expandTemplate{ title = template_title, args = template_args }
-- First column in each row is hero name. Make it sticky to the left for horizontal scrolling.
-- First column in each row is hero name. Make it sticky. Add z-index to fix overlap.
row_str = row_str .. '<td style="position: sticky; left: 0; background-color: ' .. sticky_cell_bg .. ';">' .. hero_icon .. "</td>"
row_content = row_content .. '<td style="position: sticky; left: 0; z-index: 1; background-color: ' .. sticky_cell_bg .. ';">' .. hero_icon .. "</td>"
-- Consecutive columns are then stats
-- Consecutive columns are then stats
Line 591: Line 589:
-- Add it to the row
-- Add it to the row
row_str = row_str .. "<td>" .. stat_value .. scaling_strs .. "</td>"
row_content = row_content .. "<td>" .. stat_value .. scaling_strs .. "</td>"
end
end
end
end
Line 597: Line 595:
-- Add row to the body
-- Add row to the body
row_str = "<tr>" .. row_str .. "</tr>"
body_rows_str = body_rows_str .. "<tr>" .. row_content .. "</tr>"
body_str = body_str .. row_str
first_hero = false
end
end
end
end
end
end
-- Wrap body rows in tbody for semantic HTML and correct sticky behavior
local body_str = "<tbody>" .. body_rows_str .. "</tbody>"
-- First header is Hero. The top-left corner cell needs to be sticky in both directions.
-- First header is Hero. The top-left corner cell needs to be sticky in both directions.
local headers_str = '<th style="position: sticky; top: 0; left: 0; z-index: 2; background-color: ' .. sticky_header_bg .. ';">' .. "Hero" .. "</th>"
local header_cells_str = '<th style="position: sticky; top: 0; left: 0; z-index: 2; background-color: ' .. sticky_header_bg .. ';">' .. "Hero" .. "</th>"
local header_style
local header_style
local category_data = attribute_module.get_category_data()
local category_data = attribute_module.get_category_data()
Line 664: Line 662:
header_style = header_base_style .. category_rgb .. ');"'
header_style = header_base_style .. category_rgb .. ');"'
headers_str = headers_str .. "<th" .. header_style .. ">" .. attr_localized .. postfix .. "</th>"
header_cells_str = header_cells_str .. "<th" .. header_style .. ">" .. attr_localized .. postfix .. "</th>"
end
end
end
end
end
end
headers_str = "<tr>" .. headers_str .. "</tr>"
-- Wrap header cells in thead and tr for semantic HTML and correct sticky behavior
local headers_str = "<thead><tr>" .. header_cells_str .. "</tr></thead>"


local table_str = '<table class="wikitable sortable" style="table-layout: auto; width: 100%;">' .. headers_str .. body_str .. "</table>"
local table_str = '<table class="wikitable sortable" style="table-layout: auto; width: 100%;">' .. headers_str .. body_str .. "</table>"