이 모듈에 대한 설명문서는 모듈:Color/설명문서에서 만들 수 있습니다
local color = {}
local getArgs = require( 'Module:Arguments' ).getArgs
local scheme = mw.loadData( 'Module:Color/Scheme' )
local typeScheme = scheme.type
local attackScheme = scheme.attack
-- 틀:색
function color.toText ( frame )
local args = getArgs( frame )
-- {{{2}}}가 비었을 경우 틀에서 아무 것도 출력 안 함
if args[2] == nil then return '' end
local color = args[1] ~= nil and '#' .. args[1] or 'inherit'
local ret = mw.html.create( 'span' )
:css( 'color', color )
:wikitext( args[2] )
:done()
return ret
end
-- 틀:색2
function color.toLink ( frame )
local args = getArgs( frame )
-- {{{2}}}가 비었을 경우 틀에서 아무 것도 출력 안 함
if args[2] == nil then return '' end
local color = args[1] ~= nil and '#' .. args[1] or 'initial'
local text = args[2]
local textAlt = args[3] ~= nil and args[3] or text
return '[[' .. text .. '|<span style="color:' .. color ..'">' .. textAlt .. '</span>]]'
end
local function formatTypeLink( typeName )
if typeScheme[typeName] ~= nil then
return '<span class="cell-fill" style="background: ' .. typeScheme[typeName][2] .. '">[[' .. typeName .. ' (타입)|<span class="text-white">' .. typeName .. '</span>]]</span>'
else
return '<strong class="text-warning">타입명이 잘못되었습니다.</strong>'
end
end
-- 틀:색타
function color.toTypeLink ( frame )
local args = getArgs( frame )
local ret = ''
if args[1] ~= nil then
ret = formatTypeLink( args[1] )
end
if args[2] ~= nil then
ret = '<div class="cell-split">' .. ret .. formatTypeLink( args[2] ) .. '</div>'
end
return ret
end
-- 틀:기분
function color.toAttackText ( frame )
local args = getArgs( frame )
-- {{{1}}}이 비었을 경우 틀에서 아무 것도 출력 안 함
if args[1] == nil then return '' end
local bgColor = args[1]
local color = args[2] ~= nil and '#' .. args[2] or 'inherit'
local ret = mw.html.create( 'span' )
:css( 'background', attackScheme[bgColor][2] )
:css( 'color', color )
:css( 'padding', '0 .25em' )
:wikitext( args[1] )
:done()
return ret
end
return color