Module:Sandbox/LVL: Difference between revisionsGive feedback
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 467: | Line 467: | ||
-- Initializations and declarations | -- Initializations and declarations | ||
local | local body_rows_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 | ||
local row_content = "" | |||
-- 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 | -- First column in each row is hero name. Make it sticky. Add z-index to fix overlap. | ||
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_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 | ||
body_rows_str = body_rows_str .. "<tr>" .. row_content .. "</tr>" | |||
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 | 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 .. ');"' | ||
header_cells_str = header_cells_str .. "<th" .. header_style .. ">" .. attr_localized .. postfix .. "</th>" | |||
end | end | ||
end | end | ||
end | end | ||
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>" | ||