Module:BadgeLua/doc
More actions
This is the documentation page for Module:BadgeLua
|type = website |description = Module:BadgeLua/doc is a template page used on the Star Citizen Wiki. Templates are pages that are embedded (transcluded) into other pages to allow for the repetition of information. |site_name = Star Citizen Wiki |locale = en-gb }}
Lua interface for an inline pill-shaped badge, with an optional icon, custom text color, and custom background. Suited to status tags, version markers, or any short metadata that should read as a distinct chip rather than plain text.
Editors use this through {{Badge}}; see Template:Badge. Required directly by several rendering modules, including Module:Rarity, Module:DietaryEffect, and Module:Entity/ProductionStatus.
For module editors
API
p.render(props): builds and returns the badge markup plus its bundled<templatestyles>tags.props:text(required),variant(error/success/warning),icon(file name, rendered via Module:Icon at 16px),mask(render the icon as acurrentColormask instead of a thumbnail),link(wrap the whole pill in one anchor),color/backgroundColor(inline CSS overrides),class.p.main(frame): wikitext entry point behind{{Badge}}. Reads args via Module:Arguments; the first positional argument becomestext, andbgis a shorthand forbackgroundColor(an explicitbackgroundColor=wins).maskis normalised through Module:Yesno.
Gotchas
- An unrecognised
variantis silently ignored, so a typo never emits a broken half-styled class. color/backgroundColorrender as inline styles, so they win over thevariantclass for text and background color, but a variant's border color has no inline counterpart and stays whatever the class set.- Icon's own
<templatestyles>tag is appended only wheniconis set, so a plain text badge doesn't load it unconditionally. linkwraps the already-rendered pill string in[[Target|…]]; the<templatestyles>tags stay outside the link label.
Styles
.t-badge, .t-badge__icon, and .t-badge__text are a contract other code targets directly rather than through props: Module:Rarity and Module:Entity/ProductionStatus override the base look with higher-specificity selectors (.t-badge.rarity-badge--*), and the aggridRenderers gadget (MediaWiki:Gadget-aggridRenderers.js/.css) reconstructs the same class names in JS so an AG Grid badge cell matches a wikitext one. Renaming a class here breaks all of them silently.