Difference between revisions of "Template:Progress bar"

From BlogNomic Wiki
Jump to navigation Jump to search
(trying a template)
 
(add support for unknown values, since we have one)
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly><span>
+
<includeonly><span><div style="border:1px solid #000; margin:0 0 1px 0"><div style="background:{{{color|#0f0}}}; text-align:right; white-space: nowrap; padding:0em; width:{{#switch: {{{1|}}}| ? = 0 | {{#ifexpr: {{{1|0}}} < 0 |0|{{#ifexpr: {{{1|0}}} > {{{2|100}}} | 100 |{{formatnum:{{#if:{{#if:{{{1|}}}|{{{1}}}|0}}|{{#expr:100*{{#if:{{{1|}}}|{{{1}}}|0}}/{{{2|{{{total|100}}}}}}round {{{decimal|1}}}}}}}}}}}}}}}%{{#switch: {{{1|}}}| ? = ; color:#aaa }}">&nbsp;&nbsp;{{{1}}}/{{{2}}}{{#if:{{{3|}}}|&nbsp;{{{3}}}}}&nbsp;&nbsp;</div></div></span></includeonly><noinclude>
<div style="border:1px solid #000;">
+
Template for displaying a progress bar, for use on a gamestate page.
<div style="background:#0f0; text-align:right; padding:0em; width:{{formatnum:{{#if:{{#if:{{{1|}}}|{{{1}}}|0}}|{{#expr:100*{{#if:{{{1|}}}|{{{1}}}|0}}/{{{2|{{{total|100}}}}}}round {{{decimal|1}}}}}}}}}%">
+
 
&nbsp;&nbsp;{{{1}}}/{{{2}}}&nbsp;&nbsp;
+
==Usage==
</div>
+
 
</div></includeonly><noinclude>
+
===Regular===
Example usage: <pre>{{progress bar|3|7}}</pre> produces:
+
<code><nowiki>{{progress bar|3|7}}</nowiki></code> produces:
  
 
{{progress bar|3|7}}
 
{{progress bar|3|7}}
 +
 +
Overfilled bars are capped at the maximum:
 +
 +
{{progress bar|10|7}}
 +
 +
Negative numbers show as empty:
 +
 +
{{progress bar|-2|7}}
 +
 +
A question mark can be used for an unknown value, which shows as empty and greyed out:
 +
 +
{{progress bar|?|7}}
 +
 +
===Specify units===
 +
<code><nowiki>{{progress bar|3|7|players}}</nowiki></code> produces:
 +
 +
{{progress bar|3|7|players}}
 +
 +
===Colour===
 +
<code><nowiki>{{progress bar|3|7|color=#f90}}</nowiki></code> produces:
 +
 +
{{progress bar|3|7|color=#f90}}
 +
[[Category:Display templates]]
 
</noinclude>
 
</noinclude>

Latest revision as of 14:28, 24 October 2024

Template for displaying a progress bar, for use on a gamestate page.

Usage

Regular

{{progress bar|3|7}} produces:

  3/7  

Overfilled bars are capped at the maximum:

  10/7  

Negative numbers show as empty:

  -2/7  

A question mark can be used for an unknown value, which shows as empty and greyed out:

  ?/7  

Specify units

{{progress bar|3|7|players}} produces:

  3/7 players  

Colour

{{progress bar|3|7|color=#f90}} produces:

  3/7