Module:Color contrast: Difference between revisions
Content added Content deleted
(add option for greatercontrast to form inline css string) |
(typo) |
||
Line 139: | Line 139: | ||
if css then |
if css then |
||
local c1 = args[1] or '' |
|||
⚫ | |||
if mw.ustring.match(c1, '^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$') or |
|||
⚫ | |||
c1 = '#' .. c1 |
|||
end |
end |
||
if mw.ustring.match( |
if mw.ustring.match(c2, '^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$') or |
||
mw.ustring.match( |
mw.ustring.match(c2, '^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$') then |
||
c2 = '#' .. c2 |
|||
end |
end |
||
if mw.ustring.match(v3, '^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$') or |
if mw.ustring.match(v3, '^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$') or |
||
mw.ustring.match(v3, '^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$') then |
mw.ustring.match(v3, '^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$') then |
||
c3 = '#' .. c3 |
|||
end |
end |
||
return 'background-color:' .. |
return 'background-color:' .. c1 .. '; color:' .. ((ratio1 > 0) and (ratio2 > 0) and ((ratio1 + bias > ratio2) and c2 or c3) or '') .. ';' |
||
.. ((ratio1 > 0) and (ratio2 > 0) and ((ratio1 + bias > ratio2) and c2 or c3) or '') .. ';' |
|||
end |
end |
||