Module:Progression rainbow: Difference between revisions

Content deleted Content added
add tooltips showing % and class
Override the default A-class color
 
(5 intermediate revisions by 4 users not shown)
Line 3:
 
]]
require('Module:No globalsstrict')
 
local p = {}
Line 96:
total = tonumber(args[9]) or 100
end
local height = arg_or_default(args, 'height', nil)
local root = mw.html.create('ul')
root:addClass('progression-rainbow')
if height then
root:css('height', height)
end
 
local current_frame = mw.getCurrentFrame()
Line 104 ⟶ 109:
if class.count ~= 0 then
local percentage = percent(class.count, total)
-- The default Start-class color is difficult to distinguish next to
-- the Stub-class color, so we pick a midpoint between Stub and C
if class.class == 'Start' then
root:newline() -- sprinkled through to make the HTML easier to read
root:tag('li')
:css('background', '#ffca66')
:css('color','inherit')
:css('width', percentage)
:attr('title', string.format('%s %s', percentage, class.category))
:tag('span')
:addClass('sr-only')
:wikitext(string.format('%s %s', percentage, class.category))
:done()
:done()
-- The default A-class color is difficult to distinguish next to
-- the GA-class color, so we pick a midpoint between GA and FA
elseif class.class == 'A' then
root:newline() -- sprinkled through to make the HTML easier to read
root:tag('li')
:css('background', '#64e2ff')
:css('color','inherit')
:css('width', percentage)
:attr('title', string.format('%s %s', percentage, class.category))
:tag('span')
:addClass('sr-only')
:wikitext(string.format('%s %s', percentage, class.category))
:done()
:done()
else
root:newline() -- sprinkled through to make the HTML easier to read
root:tag('li')
Line 109 ⟶ 143:
title = 'class/colour', args = { class.class }
})
:css('color','inherit')
:css('width', percentage)
:attr('title', string.format('%s %s', percentage, class.category))
Line 116 ⟶ 151:
:done()
:done()
end
end
end