Module:BubbleBox

local p = require("Module:SiteColor")

function p.main(frame) -- content is the first unnamed positional paramter local content = frame:getParent.args[1] or ""

-- border is optional named parameter and defaults to Generic local border = frame:getParent.args['border'] or p.getSiteColor("Generic") -- background is optional named parameter and defaults to rgba({border}, 0.25) local background = frame:getParent.args['background'] or "rgba(" .. border .. ", 0.25)" if background == "bubbles" then background = "bubbleboxbg" end

-- style is an optional named parameter css list to add to the container local style = frame:getParent.args['style'] or ""

-- collapsed is an optional named parameter; if present it should be a bool local collapsed = frame:getParent.args['collapsed'] -- tags is an optional named parameter and adds to JS tags. local tags = frame:getParent.args['tags'] or "" -- first, implement the template styles. local templateStyles = mw.html.create('templatestyles', {selfClosing = true}) templateStyles:attr("src", "BubbleBox/styles.css")

-- create the main div local div = mw.html.create('div') div:addClass(background) if collapsed ~= nil then div:addClass("mw-collapsible") end if collapsed == "true" then div:addClass("mw-collapsed") end div:addClass(tags) div:cssText("color: box-shadow: 0px 0px 15px #ffffff inset; border-width: 10px 1px 10px 1px; border-style: solid; border-color: rgb(" .. border .. "); border-radius: 10px; padding: 15px; margin: 4px; " .. style)

if background ~= "bubbleboxbg" then div:css("background-color", background) end

if collapsed ~= nil then div:wikitext(content) -- collapsible content box div:tag('div') div:addClass('mw-collapsible-content') div:done -- end of collapsible content box elseif content ~= "open" then -- append content div:wikitext(content) -- close tag (no close if marked open) div:done end

return tostring(templateStyles) .. tostring(div) end

return p