Module:AbilitySection: Difference between revisionsGive feedback
Wrap single-tab tabber in .single-tabbed div for CSS targeting (with help from vergir-bot LLM) |
Make AbilitySection insert heading with ability's name |
||
| Line 2: | Line 2: | ||
local p = {} | local p = {} | ||
local utils = require "Module:Abilities/utils" | |||
local lang = require "Module:Lang" | |||
local icon_module = require "Module:Icon" | |||
local resource_lookup = mw.loadJsonData("Data:ResourceLookup.json") | |||
-- Tab definitions — order here determines display order. | -- Tab definitions — order here determines display order. | ||
| Line 9: | Line 13: | ||
{ key = 'tips', label = 'Tips' }, | { key = 'tips', label = 'Tips' }, | ||
} | } | ||
local function get_hero_key(hero_name) | |||
if hero_name == nil or hero_name == '' then return nil end | |||
if string.sub(hero_name, 1, 5) == "hero_" then return hero_name end | |||
local entry = resource_lookup[hero_name:lower()] | |||
if entry == nil then return nil end | |||
return entry.key | |||
end | |||
local function trim(s) | local function trim(s) | ||
| Line 65: | Line 77: | ||
local interactions = trim(args.interactions or '') | local interactions = trim(args.interactions or '') | ||
local tips = trim(args.tips or '') | local tips = trim(args.tips or '') | ||
local hero_key = get_hero_key(hero_name) | |||
local heading = '' | |||
if hero_key ~= nil then | |||
local ability = utils.get_ability_card_data(hero_key, ability_num) | |||
if ability ~= nil then | |||
local ability_name = lang.get_string(ability.Key) | |||
local icon_html = icon_module._render(ability_name, { size = '30px', ['icon-only'] = 'true', ['no-link'] = 'true' }) | |||
heading = '<h3 class="ability-name">' .. icon_html .. ' ' .. ability_name .. '</h3>' | |||
end | |||
end | |||
local card = frame:expandTemplate{ | local card = frame:expandTemplate{ | ||
| Line 83: | Line 106: | ||
end | end | ||
local ability_section = '<div class="ability-section">' | |||
.. '<div class="ability-section-card">' .. card .. '</div>' | .. '<div class="ability-section-card">' .. card .. '</div>' | ||
.. details_col | .. details_col | ||
.. '</div>' | |||
return '<div class="ability-section-wrapper">' | |||
.. heading | |||
.. ability_section | |||
.. '</div>' | .. '</div>' | ||
end | end | ||
return p | return p | ||