Module:BubbleBox

local p = {}

local siteColor = require('Module:SiteColor')

function p.main(frame) local args = frame:getParent.args -- content is the first unnamed positional paramter local content = args[1] or '' -- background is optional named parameter and defaults to rgba({border}, 0.25) local background = args['background'] or '' -- border is optional named parameter and defaults to Generic local border = args['border'] or siteColor.getSiteColor("Generic") -- collapsed is an optional named parameter; if present it should be a bool local collapsed = args['collapsed'] or '' -- style is an optional named parameter css list to add to the container local style = args['style'] or '' -- tags is an optional named parameter and adds to JS tags. local tags = args['tags'] or '' -- pass args to getBox return p.getBox(content, background, border, collapsed, style, tags) end

function p.getBox(content, background, border, collapsed, style, tags) local classes = {} local styles = {}

-- table insert: -- https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#table.insert if background == 'bubbles' then table.insert(classes, 'bubbleboxbg') else table.insert(classes, background) table.insert(styles, 'background-color: ' .. (background ~=  and background or 'rgba(' .. (border ~=  and border or siteColor.getSiteColor("Generic")) .. ', 0.25)')) end

if collapsed ~= '' then table.insert(classes, 'mw-collapsible') if collapsed == 'true' then table.insert(classes, 'mw-collapsed') end end

if tags ~= '' then table.insert(classes, tags) end

table.insert(styles, 'box-shadow: 0px 0px 15px #ffffff inset') table.insert(styles, 'border-width: 10px 1px 10px 1px') table.insert(styles, 'border-style: solid') table.insert(styles, 'border-color: rgb(' .. (border ~= '' and border or siteColor.getSiteColor("Generic")) .. ')')   table.insert(styles, 'border-radius: 10px') table.insert(styles, 'padding: 15px') table.insert(styles, 'margin: 4px')

if style ~= '' then table.insert(styles, style) end

local result = '' if collapsed ~= '' then result = result .. content .. ' '   else result = result .. content .. ' '   end result = result .. ' '

return result end

return p