Module:Navbox/sandbox: Difference between revisions

Content deleted Content added
Don't override system messages for non-English readers
check contrast ratios in CSS styles
Line 271:
local function hasBackgroundColors()
return mw.ustring.match(args.titlestyle or '','background') or mw.ustring.match(args.groupstyle or '','background') or mw.ustring.match(args.basestyle or '','background')
end
 
local function isIllegible()
local m_contrast = require('Module:Color contrast')
local ratio, parse_css = m_contrast._ratio, m_contrast.extract_css_colors
 
for key, style in pairs(args) do
if key:match("style$") then
if ratio { error = 0, parse_css(style) } < 4.5 then
return true
end
end
end
 
return false
end
 
Line 277 ⟶ 292:
if needsHorizontalLists() then table.insert(cats, 'Navigational boxes without horizontal lists') end
if hasBackgroundColors() then table.insert(cats, 'Navboxes using background colours') end
if isIllegible() then table.insert(cats, 'Potentially illegible navboxes') end
return cats
end