Module:UserGenderBox

From Inkipedia, the Splatoon wiki

Displays a userbox regarding a user's gender identity or pronouns.

This module passes arguments to Module:Userbox after helpfully switching based on the first parameter.


Usage

Parameters

Parameter Type Status Description
identifier Named or unnamed (first positional) Optional, defaults to "" The identifier that the module should use. Pre-defined ones are:
  • male or boy
  • female or girl
  • nb or nonbinary or non-binary
  • trans or transgender

Otherwise, if the identifier contains a '/', and gender is not set, then the box assumes this is a pronoun(s).
Otherwise, the box prefixes the identifier with "This user is "

gender Named or unnamed (second positional) Optional The gender to use. If identifier is set above, you need not set this. You could set this for a more specific gender, e.g. calling {{UserGenderBox|trans|transmasc}}.

If text is set, this parameter does nothing.

text Named only Optional Fully overrides the box text.
punctuation Named only Optional, defaults to . Prefixes the text with the punctuation. By default this is a period however some users have changed this to !.

If text is set, this parameter does nothing.

genderColor Named only Optional, defaults to "inherit" Customizes the gender's color with the given color. Typical CSS rules apply, e.g. use #ABC123, rbg(50, 100, 150), or pink etc.

For additional parameters, see Module:Userbox. All parameters there are also valid for this module.


Examples

Markup

* {{UserGenderBox}}
* {{UserGenderBox|male}}
* {{UserGenderBox|female}}
* {{UserGenderBox|nb|genderColor=darkorchid}}
* {{UserGenderBox|trans}}
* {{UserGenderBox|transgender|transfem|genderColor=#F5A9B8|id-c=white|info-c=white|punctuation=!}}
* {{UserGenderBox|she/they}}
* {{UserGenderBox|they/<br>them|text=This user is non-binary!}}
* {{UserGenderBox|It|text=This user only uses it/its pronouns}}

Output

?This user keeps their gender a mystery.
MaleUser.svgThis user is male.
FemaleUser.svgThis user is female.
Non-binaryUser.svgThis user is non-binary.
Trans flag square.svgThis user is trans.
Trans flag square.svgThis user is transfem!
she/theyThis user uses she/they pronouns.
they/
them
This user is non-binary!
itThis user only uses it/its pronouns

local p = {}
local userboxModule = require('Module:Userbox')

function p.main(frame)
    local args = frame:getParent().args
    return p.getBox(args)
end

function p.getBox(args)
    local identifier = (args[1] or args["identifier"])
    identifier = (identifier ~= nil and identifier ~= "") and string.lower(identifier) or "?"
    local gender = args[2] or args["gender"]
    gender = (gender ~= nil and gender ~= "") and gender or nil  -- if gender is empty, set to nil
    local text = args["text"]
    text = (text ~= nil and text ~= "") and text or nil  -- if text is empty, set to nil
    local punctuation = args["punctuation"] or "."
    local genderColor = args["genderColor"] or "inherit"

    local logoImage, infoText
    if identifier == "?" then
    	logoImage = identifier
    	infoText = text or 'This user keeps their <span style="color: ' .. genderColor .. '">' .. (gender or "gender") .. '</span> a mystery' .. punctuation
    elseif identifier == "male" or identifier == "boy" then
        logoImage = "[[File:MaleUser.svg|42x42px|link=]]"
        infoText = text or 'This user is <span style="color: ' .. genderColor .. '">' .. (gender or "male") .. '</span>' .. punctuation
    elseif identifier == "female" or identifier == "girl" then
        logoImage = "[[File:FemaleUser.svg|42x42px|link=]]"
        infoText = text or 'This user is <span style="color: ' .. genderColor .. '">' .. (gender or "female") .. '</span>' .. punctuation
    elseif identifier == "nb" or identifier == "nonbinary" or identifier == "non-binary" then
        logoImage = "[[File:Non-binaryUser.svg|42x42px|link=]]"
        infoText = text or 'This user is <span style="color: ' .. genderColor .. '">' .. (gender or "non-binary") .. '</span>' .. punctuation
    elseif identifier == "trans" or identifier == "transgender" then
        logoImage = "[[File:Trans flag square.svg|42x42px|link=]]"
        infoText = text or 'This user is <span style="color: ' .. genderColor .. '">' .. (gender or "trans") .. '</span>' .. punctuation
    elseif (gender == nil or gender == '') and mw.ustring.find(identifier, '/') then  -- assume pronouns usage
        logoImage = identifier
        infoText = text or 'This user uses <span style="color: ' .. genderColor .. '">' .. (identifier or 'no') .. '</span> pronouns' .. punctuation
    else
    	logoImage = identifier
    	infoText = text or 'This user is <span style="color: ' .. genderColor .. '">' .. (gender or identifier) .. '</span>' .. punctuation
    end

    -- Set the logo and info text in args before calling Userbox
    args["id"] = logoImage
    args["info"] = infoText
    args["border-c"] = args["border-c"] or "#088A08"
    args["id-c"] = args["id-c"] or "#D0F5A9"
    args["info-c"] = args["info-c"] or "#BCF5A9"
    args["id-s"] = args["id-s"] or 11
    return userboxModule.getBox(args)
end

return p