Module:Userbox

From Inkipedia, the Splatoon wiki

Usage

{{Userbox
|id       = id text or image
|id-c     = id background color
|id-fc    = id font color
|id-s     = id text size
|info     = info text
|info-c   = info background color
|info-fc  = info font color
|info-s   = info text size
|border-c = box color
|border-s = border width in pixels
}}
  • It is suggested that you limit the size of any images in the id box to 40 pixels.
  • For a list of colors and the Hex triplet (eg., 007BA7) codes for them, see this Wikipedia page.
  • This page is to active userboxes.

Example

{{Userbox
|id= [[File:Squidpromo.jpg|48px]]
|id-c= #74DF00
|info= This user loves Splatoon!
|info-c= #BCF5A9
|border-c= #088A08
}}

Which will give:

Squidpromo.jpgThis user loves Splatoon!

local p = {}

function p.main(frame)
	-- pass frame args wholly to getBox
    local args = frame:getParent().args
    return p.getBox(args)
end

function p.getBox(args)
    local float = args["float"] or "left"
    local borderWidth = args["border-width"] or args["border-s"] or 1
    local borderColor = args["border-color"] or args["border-c"] or args["id-c"] or "#999"
    local infoBackground = args["info-background"] or args["info-c"] or "#EEE"
    local logoBackground = args["logo-background"] or args["id-c"] or "#DDD"
    local logoSize = args["logo-size"] or args["id-s"] or 14
    local logoColor = args["logo-color"] or args["id-fc"] or "black"
    local logoText = args["logo"] or args["id"] or "''id''"
    local infoSize = args["info-size"] or args["info-s"] or 8
    local infoColor = args["info-color"] or args["info-fc"] or "black"
    local infoText = args["info"] or "''info''"
    
    local ruserbox = mw.html.create("div")
    ruserbox:attr("id", "ruserboxx")
    ruserbox:css("float", float)
    ruserbox:css("border", borderWidth .. "px solid " .. borderColor)
    ruserbox:css("margin", "1px")

    local table = mw.html.create("table")
    table:attr("cellspacing", "0")
    table:css("width", "238px")
    table:css("background", infoBackground)

    local row = mw.html.create("tr")

    local logoCell = mw.html.create("td")
    logoCell:css("width", "45px")
    logoCell:css("height", "45px")
    logoCell:css("background", logoBackground)
    logoCell:css("text-align", "center")
    logoCell:css("font-size", logoSize .. "pt")
    logoCell:css("color", logoColor)
    logoCell:wikitext("'''" .. logoText .. "'''")

    local infoCell = mw.html.create("td")
    infoCell:css("font-size", infoSize .. "pt")
    infoCell:css("padding", "4pt")
    infoCell:css("line-height", "1.25em")
    infoCell:css("color", infoColor)
    infoCell:wikitext(infoText)

    row:node(logoCell)
    row:node(infoCell)

    table:node(row)
    ruserbox:node(table)

    return tostring(ruserbox)
end

return p