Module:Swatches/doc
Jump to navigation
Jump to search
This is the documentation page for Module:Swatches
Module:Swatches
Renders cosmetic swatches defined in Module:Swatches/data.
This module provides two functions:
get- renders a single swatch infobox by name.list- renders a filtered list of swatch infoboxes.
Usage
Get a single swatch
Renders a single swatch infobox by name. The swatch name is case-sensitive and must match the key defined in Module:Swatches/data.
{{#invoke:Swatches|get|<NAME>}}
List all swatches
If no scope is provided, all swatches in the dataset are shown:
{{#invoke:Swatches|list}}
List swatches for a scope page
Scope can be specified to show all swatches that are compatible with at least one class in that scope:
{{#invoke:Swatches|list|<SCOPE>}}
List swatches for a class page
Class can additionally be specified to show only swatches that are compatible with that class:
{{#invoke:Swatches|list|<SCOPE>|<CLASS>}}
Render swatches expanded
By default, the swatch list is collapsed. To render it expanded, pass a truthy value to the expanded parameter.
{{#invoke:Swatches|list|expanded=yes}}
Parameters
get
- 1
- string
- Swatch name (case-sensitive). Must match a key in Module:Swatches/data.
- Returns an error message if the swatch does not exist.
list
- 1 (optional)
- string
- Compatibility scope to filter swatches (case-insensitive).
- If omitted, all swatches are shown.
- If specified, must match a scope defined in Module:Swatches/data. An error message is returned if the value is invalid.
- Valid values (singular and plural forms both accepted):
- •
Vehicle - •
Weapon - •
Garment - •
Placeable
- •
- 2 (optional)
- string
- Name of a class within the specified scope, to further filter swatch compatibility (case-insensitive).
{{PAGENAME}}can be used if the page title matches the dataset naming.- Examples:
- •
Sandbike - •
Flamethrowers - •
Heavy Armor
- •
- expanded (optional)
- boolean
- If specified with a truthy value, output will be expanded by default.
- Valid values:
- •
true - •
yes - •
1
- •
Notes
list
- Listed content is placed inside a collapsible container, which is collapsed by default (
mw-collapsible mw-collapsed). - When expanded, the swatch infobox cards are wrapped in an outer container that inherits the shared `flex-container` layout class, which provides standardised responsive flex behaviour across the wiki.
- Swatch compatibility rules are defined in Module:Swatches/data using the optional
scopesandonlyClassesfields. classis matched case-insensitively against class names withinonlyClassestokens in Module:Swatches/data.