Module:Shindo and Module:Shindo/sandbox: Difference between pages
(Difference between pages)
imported>SamBroGaming Undid revision 1296854156 by Awesome Aasim (talk) This sweeping change affects light mode users as well, and considering it has had zero discussion anywhere I could find, I am reverting it |
imported>Awesome Aasim Undid revision 1296900379 by Awesome Aasim (talk) |
||
| Line 8: | Line 8: | ||
-- @require Module:Message | -- @require Module:Message | ||
-- @require Module:Yesno | -- @require Module:Yesno | ||
-- @require Module:LightDarkColor | |||
-- @release beta | -- @release beta | ||
-- | -- | ||
| Line 19: | Line 20: | ||
local message = require("Module:Message")(messages) | local message = require("Module:Message")(messages) | ||
local yn = require("Module:Yesno") | local yn = require("Module:Yesno") | ||
local ldColor = require("Module:LightDarkColor") | |||
--- Gets the grayscale value of a specific color | --- Gets the grayscale value of a specific color | ||
| Line 30: | Line 32: | ||
return (tbl[1] + tbl[2] + tbl[3]) / 3 / 255 | return (tbl[1] + tbl[2] + tbl[3]) / 3 / 255 | ||
end | end | ||
local colorStore = {} | |||
--- Gets the color as a comma-separated value for CSS | --- Gets the color as a comma-separated value for CSS | ||
| Line 40: | Line 44: | ||
-- @return {string} The color in the format red, green, blue | -- @return {string} The color in the format red, green, blue | ||
local function rgbColor(tbl) | local function rgbColor(tbl) | ||
local color = table.concat({tbl[1], tbl[2], tbl[3]}, ",") | |||
if not colorStore[color] then | |||
local res = ldColor._RGB({tbl[1], tbl[2], tbl[3]}) | |||
res[4] = res[4] / 2 | |||
colorStore[color] = res | |||
end | |||
return table.concat(colorStore[color], ',') | |||
end | end | ||
| Line 113: | Line 123: | ||
local color = data[scale].colors[order] | local color = data[scale].colors[order] | ||
local colorIntensity = getValueOfColor(color) | local colorIntensity = getValueOfColor(color) | ||
return 'background-color: | return 'background-color:rgba(' .. rgbColor(color) .. '); color:' .. ('var(--color-base)') .. ";" | ||
end | end | ||
| Line 148: | Line 158: | ||
end | end | ||
out = out .. (args.tagProps ~= nil and args.tagProps or "") | out = out .. (args.tagProps ~= nil and args.tagProps or "") | ||
out = out .. 'class="module-shindo" ' | |||
if (yn(doColor)) then | if (yn(doColor)) then | ||
out = out .. 'style="background-color:rgba(' .. rgbColor(color) .. '); color:' .. ( | out = out .. 'style="background-color:rgba(' .. rgbColor(color) .. '); color:' .. ('var(--color-base)') .. ';' .. (args.style or "") .. '" | ' | ||
elseif (args.style) then | elseif (args.style) then | ||
out = out .. 'style="' .. (args.style or "") .. '" | ' | out = out .. 'style="' .. (args.style or "") .. '" | ' | ||
| Line 157: | Line 168: | ||
end | end | ||
if yn(doColor) then | if yn(doColor) then | ||
out = out .. '<span style=\"color:' .. ( | out = out .. '<span style=\"color:' .. ('var(--color-base)') .. ';">' | ||
end | end | ||
out = out .. listIntensitiesFromScale(scale, intensities, labelScale, false) | out = out .. listIntensitiesFromScale(scale, intensities, labelScale, false) | ||
| Line 166: | Line 177: | ||
out = out .. "]]" | out = out .. "]]" | ||
end | end | ||
return out | return out .. mw.getCurrentFrame():extensionTag('templatestyles', '', {src = 'Module:Shindo/styles.css'}) | ||
end | end | ||
| Line 208: | Line 219: | ||
local out = '' | local out = '' | ||
if yn(doColor) then | if yn(doColor) then | ||
out = out .. '<' .. (args.tag or "span") .. ' style="background-color:rgba(' .. rgbColor(color) .. '); padding:4px; color:' .. ( | out = out .. '<' .. (args.tag or "span") .. ' style="background-color:rgba(' .. rgbColor(color) .. '); padding:4px; color:' .. ('var(--color-base)') .. '; ' | ||
elseif args.style then | elseif args.style then | ||
out = out .. '<' .. (args.tag or "span") .. ' style="' | out = out .. '<' .. (args.tag or "span") .. ' style="' | ||
| Line 221: | Line 232: | ||
end | end | ||
out = out .. (args.tagProps ~= nil and args.tagProps or "") | out = out .. (args.tagProps ~= nil and args.tagProps or "") | ||
out = out .. 'class="module-shindo" ' | |||
out = out .. ">" | out = out .. ">" | ||
if yn(link) then | if yn(link) then | ||
| Line 226: | Line 238: | ||
end | end | ||
if yn(doColor) then | if yn(doColor) then | ||
out = out .. '<span style=\"color:' .. ( | out = out .. '<span style=\"color:' .. ('var(--color-base)') .. ';">' | ||
end | end | ||
out = out .. listIntensitiesFromScale(scale, intensities, labelScale, scale2) | out = out .. listIntensitiesFromScale(scale, intensities, labelScale, scale2) | ||
| Line 241: | Line 253: | ||
end | end | ||
if yn(doColor) then | if yn(doColor) then | ||
out = out .. '<span style=\"color:' .. ( | out = out .. '<span style=\"color:' .. ('var(--color-base)') .. ';">' | ||
end | end | ||
out = out .. listIntensitiesFromScale(scale2, intensities2, true, true) | out = out .. listIntensitiesFromScale(scale2, intensities2, true, true) | ||
| Line 253: | Line 265: | ||
end | end | ||
out = out .. '</' .. (args.tag or "span") .. '>' | out = out .. '</' .. (args.tag or "span") .. '>' | ||
return mw.getCurrentFrame():preprocess(out) | return mw.getCurrentFrame():preprocess(out) .. mw.getCurrentFrame():extensionTag('templatestyles', '', {src = 'Module:Shindo/styles.css'}) | ||
end | end | ||