Difference between revisions of "Template:Icon"

From Project: Gorgon Wiki
Jump to: navigation, search
m (Documentation of new "label" parameter.)
(WIP.)
Line 1: Line 1:
[[File:{{#switch:{{lc:{{{1|}}}}}
+
[[File:item-icon-{{#switch:{{{1|}}}
<!-- special case, "none" is mistaken as a horizontal alignment option -->
+
<!-- icon substitutions for lookalike items (in alpha) -->
  | none      = item-icon-none.png
+
  | lemon    = banana
<!-- icons with a custom wiki page destination -->
+
  | #default = {{{1|none}}}
  | firedust = item-icon-firedust.png{{!}}link=Fire Dust
+
}}.png|class=js-icon-tt|{{#if: {{{size|}}} | {{{size}}}{{!}}sub{{!}} }}|{{#switch:{{{1|}}}
| saltpeter = item-icon-saltpeter.png{{!}}link=Saltpeter
+
<!-- set the item name based on icon name, and link for some -->
| sulfur    = item-icon-sulfur.png{{!}}link=Sulfur
+
  | firedust  = Fire Dust{{!}}link=Fire Dust
<!-- Add mouseover title to help identify similar looking icons in the recipes table -->
+
  | saltpeter = Saltpeter{{!}}link=Saltpeter
| banana    = item-icon-banana.png{{!}}Banana
+
  | sulfur   = Sulfur{{!}}link=Sulfur
| beet      = item-icon-beet.png{{!}}Beet
+
  | milk      = Bottle of Milk
| butter    = item-icon-butter.png{{!}}Butter
+
  | redapple  = Red Apple
| beet      = item-icon-grape.png{{!}}Grapes
+
  | water    = Bottle of Water
  | lemon    = item-icon-banana.png{{!}}Lemon
 
  | milk      = item-icon-milk.png{{!}}Bottle of Milk
 
  | orange   = item-icon-orange.png{{!}}Orange
 
  | potato    = item-icon-banana.png{{!}}Potato
 
  | redapple  = item-icon-redapple.png{{!}}Red Apple
 
| salt      = item-icon-salt.png{{!}}Salt
 
| sugar    = item-icon-sugar.png{{!}}Sugar
 
  | water    = item-icon-water.png{{!}}Bottle of Water
 
 
<!-- default uses the shop item naming convention -->
 
<!-- default uses the shop item naming convention -->
  | #default  = item-icon-{{{1|none}}}.png{{!}}{{#if: {{{label|}}}|{{{label}}}|{{{1}}} }}
+
  | #default  = {{#if:{{{label|}}}|{{{label}}}|{{ucfirst:{{{1}}}}} }}
<!-- WTF?
+
}}]]<noinclude>
==> if size not provided, try to get the icon name to show as red text when icon is missing, and otherwise show custom title above
 
==> if size is provided, then custom captions above don't work, short of using more complex templating due to caption not being a named param.
 
-->
 
}}{{#if: {{{size|}}} | {{!}}{{{size}}}{{!}}sub{{!}} }}]]<noinclude>
 
 
__NOTOC__
 
__NOTOC__
 
==Syntax==
 
==Syntax==
Line 52: Line 40:
  
 
==Examples==
 
==Examples==
Default 32x32px icon.
+
Default 32x32px icon. By default the capitalized icon name becomes the tooltip: "lemon" => "Lemon".
 
<pre>
 
<pre>
{{icon|saltpeter}}
+
{{icon|lemon}}
 
</pre>
 
</pre>
  
Line 62: Line 50:
 
</pre>
 
</pre>
  
Provide a title (mouseover) for items that have similar icons.
+
Provide the full name for items that have similar looking icons with '''label''' parameter.
 
<pre>
 
<pre>
 
{{icon|genericpot|label=Advanced Holistic Ink}}
 
{{icon|genericpot|label=Advanced Holistic Ink}}
 
</pre>
 
</pre>
 
 
  
 
[[Category:Formatting templates|ItemT]]
 
[[Category:Formatting templates|ItemT]]
 
</noinclude>
 
</noinclude>

Revision as of 16:42, 29 October 2014

{{{1}}}

Syntax

{{icon|<name>|size=16px}}

Description

This template has several purposes:

  • Makes some item icons link to relevant article pages instead of the default "File history" page (eg. Saltpeter).
  • It can save many edits in the future, for example certain foods that have the same icon now (banana & lemon), could have a unique icon later. The article refers to the individual foods, so the article won't need updating.
  • Adds mouseover title.
  • Reduces custom mediawiki code in the articles.

TODO: later, this template could automatically add a javascript popup to show the full item name.

Parameters

parameter 1
Name of the icon. See Item Icons Guide for available icons (eg. "firstaid"). If not provided, an empty box is shown.
size
OPTIONAL. Changes the size of the icon (default is 32px).
label
OPTIONAL. Give the mouseover tooltip text, for items that have the same icon.

Examples

Default 32x32px icon. By default the capitalized icon name becomes the tooltip: "lemon" => "Lemon".

{{icon|lemon}}

Smaller inline icon.

{{icon|saltpeter|size=16px}}

Provide the full name for items that have similar looking icons with label parameter.

{{icon|genericpot|label=Advanced Holistic Ink}}