Module:Box
Documentation for this module may be created at Module:Box/doc
local box = {
blue = {
bg = '#f5faff',
border = '#cedff2',
title_bg = '#cedff2',
title_border = '#a3b0bf',
},
green = {
bg = '#f5fffa',
border = '#cef2e0',
title_bg = '#cef2e0',
title_border = '#a3bfb1',
},
grey = {
bg = '#f9f9f9',
border = '#ddd',
title_bg = '#eee',
title_border = '#afa3bf',
},
yellow = {
bg = '#FFFFF5',
border = '#F8E47A',
title_bg = '#FFFFCC',
title_border = '#a3b0bf',
},
}
function renderBox(args)
local color = ''
local tmpcol = args["color"]
local width = args["width"] or ''
local height = args["height"] or ''
local title = args["title"] or ''
local text = args["text"] or ''
-- if no color is specified, or if the color does not exist, color is set to grey
if type(box[tmpcol]) ~= 'nil' then
color = tmpcol
else
color = 'grey'
end
local tline = ''
local output = ''
if title == '' and text == '' then
return ''
end
if title ~= '' then
tline = '! <p style="margin:0; background:' .. box[color]["title_bg"] ..'; font-size:120%; font-weight:bold; border:1px solid ' .. box[color]["title_border"] ..'; text-align:left; color:#000; padding:0.2em 0.4em;">' .. title ..'</p>\n'
end
output = '{|style="border-spacing:8px;margin:0px -8px"\n' ..
'|class="MainPageBG" style="width:' .. width .. '; height:' .. height .. '; border:1px solid ' .. box[color]["border"] .. '; background:' .. box[color]["bg"] .. '; vertical-align:top; color:#000"|\n' ..
'{|width="100%" cellpadding="2" cellspacing="5" style="vertical-align:top; background:' .. box[color]["bg"] .. ';"\n' ..
tline ..
'|-\n' ..
'|style="color:#000"|' .. text .. '\n' ..
'|-\n' ..
'|}\n' ..
'|}\n'
return output
end
local function showT(frame)
-- Called by "{{box|...}}".
return renderBox(frame:getParent().args)
end
local function show(frame)
-- Called by "{{#invoke:box|show|...}}".
return renderBox(frame.args)
end
return {
showT = showT,
show = show,
}