Content deleted Content added
m reword warning text |
rm extra a |
||
(4 intermediate revisions by the same user not shown) | |||
Line 31:
-- @param frame The Scribunto frame.
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 = "" })
local errors = setmetatable({}, { refgroupname = "E" })
Line 52 ⟶ 55:
group = _group or legend
if group[hash] == nil then
group[hash] = plain and "" or frame:extensionTag{
-- <ref name="hash">details</ref>
name = 'ref',
Line 64 ⟶ 67:
-- <ref name="hash"/>
return plain and "" or frame:extensionTag{ name = 'ref', args = {
name = hash,
group = getmetatable(group)["refgroupname"]
Line 101 ⟶ 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("AAA")
: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 151 ⟶ 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 161 ⟶ 207:
.. cat["color"]
.. ")"
)
):css("width", "0"):css("white-space", "nowrap")
▲ end
local sortkeyCategory = mw.html.create("td")
Line 266 ⟶ 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")
Line 283 ⟶ 326:
out = ""
if not plain and not tableEmpty(errors) then
out = out
.. tostring(mw.html.create("h4"):wikitext("Error"))
Line 289 ⟶ 332:
.. buildReflist(errors)
end
if not plain and not tableEmpty(legend) then
out = out
.. tostring(mw.html.create("h4"):wikitext("Legend"))
Line 295 ⟶ 338:
end
out = out .. tostring(categoryTable)
if not plain and not tableEmpty(warnings) then
out = out
.. tostring(mw.html.create("h4"):wikitext("Warnings"))
|