Module:Storm categories: Difference between revisions

Content deleted Content added
+EF0
add color ratio problem check
Line 1:
local colorRatio = require("Module:Color contrast")._ratio;
local p = {}
 
Line 444 ⟶ 445:
end
return n
end
 
function inlineError(details)
return mw.html.create("span")
:css("color", "darkred")
:css("font-weight", "bold")
:wikitext("(")
:node(
mw.html.create("span")
:attr("title", details)
:css("text-decoration", "underline")
:css("text-decoration-style", "dotted")
:wikitext("?")
)
:wikitext(")")
end
 
Line 482 ⟶ 498:
local color = mw.html.create("td")
:wikitext("#" .. cat["color"])
local catColorBlackRatio = colorRatio({ "#" .. cat["color"], "black" });
if catColorBlackRatio == "?" then
color
:wikitext(" ")
:node(inlineError("This color must be a hexadecimal color."))
elseif catColorBlackRatio < 4.5 then
color
:wikitext(" ")
:node(inlineError("This color has contrast issues with black (not WCAG 2.0 AA-compatible)."))
end
local sortkeyCategory = mw.html.create("td")
:attr("data-sort-value", cat["sortkey"])