Module:Talent
From eSportsAmaze
More actions
Documentation for this module may be created at Module:Talent/doc
local p = {}
local html = mw.html
function p.main(frame)
local args = frame:getParent().args
local container = html.create('div'):addClass('talent-box')
-- Iterate through group1, group2, group3... to keep order
for i = 1, 20 do
local role = args['group' .. i]
local people = args['list' .. i]
if role and role ~= "" and people and people ~= "" then
-- 1. Create the Group Section
local section = container:tag('div'):addClass('talent-section')
-- Role Title (e.g., "HOSTS")
section:tag('div'):addClass('talent-role-header'):wikitext(role)
-- Grid for Chips
local grid = section:tag('div'):addClass('talent-grid')
-- 2. Process the list of names
local names = mw.text.split(people, ",")
for _, name in ipairs(names) do
name = mw.text.trim(name)
if name ~= "" then
local chip = grid:tag('div'):addClass('talent-chip')
-- A. Avatar Image (Assumes "File:PlayerName.png")
-- We use [[File:Name.png|...]] syntax
local imgName = "File:" .. name .. ".png"
-- This div holds the image (and handles fallback via CSS if needed)
chip:tag('div'):addClass('talent-img')
:wikitext('[[File:' .. name .. '.png|link=|class=talent-avatar-img|50px]]')
-- B. Name Label (Linked)
chip:tag('div'):addClass('talent-name')
:wikitext('[[' .. name .. ']]')
end
end
end
end
return tostring(container)
end
return p