Module:Box
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Box/doc
local p = {}
function p.render(frame)
local args = frame:getParent().args
local title = args.Title or "Title"
local icon = args.Icon or ""
local bg = args.bg or "#7b9cd1"
local bg2 = args.bg2 or "#e7bafd4d"
local width = args.width or "auto"
local align = args.align or ""
local height = args.height or "auto"
local style = args.Style or ""
local color = args.Color or "white"
local rows = {}
local i = 1
while args["r"..i] do
table.insert(rows, args["r"..i])
i = i + 1
end
local rowItems = ""
for _, row in ipairs(rows) do
if style == "2" then
rowItems = rowItems .. row .. "\n"
else
rowItems = rowItems .. "<li>" .. row .. "</li>\n"
end
end
if #rows > 3 then
height = "300px"
else
height = "auto"
end
local boxContent = '<div class="boxTemplate" style="width:'..width..'; display: flow-root; '
if align == "center" then
boxContent = boxContent .. 'margin:auto;'
elseif align == "left" then
boxContent = boxContent .. 'margin-left:0; margin-right:auto; display:inline-table;'
elseif align == "right" then
boxContent = boxContent .. 'margin-left:auto; margin-right:0; display:inline-table;'
end
boxContent = boxContent .. ' background-color: '..bg2..';">'
boxContent = boxContent .. '<div class="boxTemplateTitle diamond" style="background-color:'..bg..'; color: '..color..';'
if style == "capital" then
boxContent = boxContent .. ' text-transform:uppercase;'
end
boxContent = boxContent .. '">'
if icon ~= "" then
boxContent = boxContent .. '[[File:'..icon..'|20px|link=]]'
end
boxContent = boxContent .. " '''"..title.."'''</div>"
boxContent = boxContent .. '<div class="boxTemplate2 volume">'
boxContent = boxContent .. '<ul class="'
if style == "2" then
boxContent = boxContent .. 'boxTemplateList2'
else
boxContent = boxContent .. 'boxTemplateList'
end
boxContent = boxContent .. ' style="max-height:'..height..'; overflow-y: auto;"">'
boxContent = boxContent .. rowItems
boxContent = boxContent .. '</ul></div></div>'
return boxContent
end
return p