Content deleted Content added
completely hide legend on plain mode |
enable verbose color information |
||
Line 32:
function p.demo(frame)
local plain = (frame.args["plain"] or frame:getParent().args["plain"] or "") ~= ""
local verbose = (frame.args["verbose"] or frame:getParent().args["verbose"] or "") ~= ""
local legend = setmetatable({}, { refgroupname = "" })
Line 103 ⟶ 104:
end
return finalWikitext
function colorInfo(color, verbose, extra)
local catColorBlackRatio = colorRatio({ "#" .. color, "black" })
local catColorLinkRatio = colorRatio({ "#" .. color, "#0645ad" })
local catColorVisitedLinkRatio = colorRatio({ "#" .. color, "#0b0080" })
local nc = tostring(mw.html.create("abbr")
:attr("title", "Does not satisfy the minimum WCAG 2.1 compliance level for color contrast (AA)")
);
local aa = tostring(mw.html.create("abbr")
:wikitext("AA")
:attr("title", "WCAG 2.1 Level AA: Acceptable compliance")
);
local aaa = tostring(mw.html.create("abbr")
:wikitext("AA")
:attr("title", "WCAG 2.1 Level AAA: Optimal compliance")
);
function contrastLevel(contrast)
return contrast >= 7 and aaa or (contrast >= 4.5 and aa or nc)
end
return mw.html.create("td")
:attr("data-sort-value", math.min(catColorBlackRatio))
:wikitext(
"#" .. color .. (extra or "") .. contrastCheck(color) .. (verbose and ("<br/>"
.. tostring(
mw.html.create("abbr")
:attr("title", "Contrast to black")
:wikitext("CTB")
) .. ": " .. string.format("%.2f", catColorBlackRatio) .. " (" .. contrastLevel(catColorBlackRatio) .. ")<br/>"
.. tostring(
mw.html.create("abbr")
:attr("title", "Contrast to links")
:wikitext("CTL")
) .. ": " .. string.format("%.2f", catColorLinkRatio) .. " (" .. contrastLevel(catColorLinkRatio) .. ")<br/>"
.. tostring(
mw.html.create("abbr")
:attr("title", "Contrast to visited links")
:wikitext("CTVL")
) .. ": " .. string.format("%.2f", catColorVisitedLinkRatio) .. " (" .. contrastLevel(catColorVisitedLinkRatio) .. ")") or "")
)
end
Line 153 ⟶ 198:
local colorPreview = mw.html.create("td")
:attr("style", "background-color: #" .. actualColor .. "; padding: 0; width: 1.8em")
local color =
verbose,
▲ color:wikitext(createLegend(
"Overriden from original color ({{color box|#"
.. cat["color"]
Line 163 ⟶ 207:
.. cat["color"]
.. ")"
)
):css("width", "0"):css("white-space", "nowrap")
▲ end
local sortkeyCategory = mw.html.create("td")
Line 268 ⟶ 309:
:node(mw.html.create("td")
:attr("style", "background-color: #" .. color .. "; padding: 0; width: 1.8em"))
:node(
:
:
:node(mw.html.create("td")
:attr("colspan", "2")
|