Module:Sandbox/LVL: Difference between revisionsGive feedback
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 525: | Line 525: | ||
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 | -- First column in each row is hero name. Make it sticky to the left for horizontal scrolling. | ||
row_str = row_str .. "<td>" .. hero_icon .. "</td>" | -- Added explicit background-color and a box-shadow for better UX. | ||
local hero_cell_style = 'style="position: sticky; left: 0; background-color: #f8f9fa; box-shadow: 2px 0 5px -2px rgba(0,0,0,0.2);"' | |||
row_str = row_str .. "<td " .. hero_cell_style .. ">" .. hero_icon .. "</td>" | |||
-- Consecutive columns are then stats | -- Consecutive columns are then stats | ||
| Line 592: | Line 594: | ||
-- First header is Hero | -- First header is Hero. The top-left corner cell needs to be sticky in both directions. | ||
local headers_str = "<th>" .. "Hero" .. "</th>" | -- z-index: 2 ensures it's on top of other sticky cells. Added explicit background and shadow. | ||
local hero_header_style = 'style="position: sticky; top: 0; left: 0; z-index: 2; background-color: #eaecf0; box-shadow: 2px 0 5px -2px rgba(0,0,0,0.2);"' | |||
local headers_str = "<th " .. hero_header_style .. ">" .. "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 644: | Line 648: | ||
end | end | ||
header_style = ' style="background-color: ' .. "rgb(" .. category_rgb .. ') ;"' | -- Make header cells sticky to the top (for vertical scrolling). z-index: 1 keeps them above the body but below the corner cell. | ||
header_style = ' style="position: sticky; top: 0; z-index: 1; background-color: ' .. "rgb(" .. category_rgb .. ') ;"' | |||
headers_str = headers_str .. "<th" .. header_style .. ">" .. attr_localized .. postfix .. "</th>" | headers_str = headers_str .. "<th" .. header_style .. ">" .. attr_localized .. postfix .. "</th>" | ||
| Line 652: | Line 657: | ||
headers_str = "<tr>" .. headers_str .. "</tr>" | headers_str = "<tr>" .. headers_str .. "</tr>" | ||
local | local table_str = '<table class="wikitable sortable" style="table-layout: auto; width: 100%;">' .. headers_str .. body_str .. "</table>" | ||
local output_str = '<div style="overflow-x: auto; width: 100%;">' .. table_str .. '</div>' | |||
return output_str | |||
local | |||
return | |||
end | end | ||