FANDOM


--[[----------------------------------------------------------------------------
	Module:Color
		For documentation, see Template:Color
----------------------------------------------------------------------------]]--
local p = {}
 
local COLORS = mw.loadData('Module:Color/data')
 
local function getColor(str)
	if not str or type(str) ~= 'string' or str == '' then return end
	return COLORS[str] or str
end
 
function p.main(frame)
	if not frame then error('Color.main: No frame found') end
	local fgcol = getColor(frame.args[1])
	local str = frame.args[2]
	local bgcol = getColor(frame.args[3])
	local glow = getColor(frame.args.glow)
	if not str then return '' end
	local span = mw.html.create('span'):wikitext(str)
	if fgcol then span:css('color', fgcol) end
	if bgcol then span:css('background-color', bgcol) end
	if glow then span:css('text-shadow', '0 0 8px ' .. glow) end
	return span
end
 
return p
Community content is available under CC-BY-SA unless otherwise noted.