Template:Tabber: Difference between revisions

From Elwiki
No edit summary
No edit summary
 
(18 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly><div class="tabdiv tabber-new {{{$divclass|}}}" style="{{{$divstyle|}}}">
<includeonly><div class="tabdiv tabber-new {{{$divclass|}}}" style="{{{$divstyle|}}}">
<ul style="{{{$ulstyle|}}}" class="tabber-ul {{{$ulclass|}}}">{{#forargs:
<ul style="{{{$ulstyle|}}}" class="tabber-ul {{{$ulclass|}}}">{{#vardefine:i|0}}{{#forargs:
| key
| key
| value
| value
Line 6: Line 6:
{{#if: {{#var:value}} |
{{#if: {{#var:value}} |
{{#if:{{#pos:{{#var:key}}|$|0}}
{{#if:{{#pos:{{#var:key}}|$|0}}
     ||<li class="tabber-tab {{{$tab{{#var:key}}class|}}}" style="{{{$tabstyle|}}}">{{#var:key}}</li>
     ||<li class="tabber-tab {{{$tab{{#var:i}}class|}}} {{#ifeq:{{#var:i}}|0|active}} {{{$tabclass|}}}" style="{{{$tabstyle|}}};{{{$tab{{#var:i}}style|}}}"><span class="tabber-tab-content">{{#var:key}}</span></li>{{#vardefine:i|{{#expr:{{#var:i}}+1}}}}
}}
}}
}}
}}
}}
}}
</ul>{{#forargs:
</ul>{{#vardefine:i|0}}{{#forargs:
| key
| key
| value
| value
Line 17: Line 17:
{{#if:{{#pos:{{#var:key}}|$|0}}
{{#if:{{#pos:{{#var:key}}|$|0}}
     |
     |
     |<div class="tabber-content {{{$con{{#var:key}}class|}}}" style="{{#ifeq:{{#var:key}}|1||display: none;}}{{{$constyle|}}}">
     |<div class="tabber-content {{{$conclass|}}} {{{$con{{#var:i}}class|}}}" style="{{#ifeq:{{#var:i}}|0||display: none;}}{{{$constyle|}}}">
{{#var:value}}
{{#var:value}}
</div>
</div>{{#vardefine:i|{{#expr:{{#var:i}}+1}}}}
}}
}}
}}
}}
}}</div></includeonly><noinclude>
}}{{#vardefine:i|0}}</div></includeonly><noinclude>
{{Doc}}</noinclude>
{{Doc}}
</noinclude>

Latest revision as of 15:29, 5 August 2022

Information: If you want to test this template, please use Sandbox.
This documentation is transcluded from Template:Tabber/doc.
Information: If you are experiencing issues with post-expand template include limits or tables/other templates transcluded inside tab contents, consider using the Extension.

Overview

This is the refreshed version of Template:Tabs and what you should be using for making tabs now. This version is enhanced with Mobile Frontend support and is generally cleaned up. Also, the syntax has been updated.

Parameters

 Tip: All parameters get parsed as tab=content, unless they start with the $ sign. These parameters are optional.
  • $divclass - adds a custom class to the wrapper of the tabs. Available:
    • tabber-center that centers tabs horizontally,
    • tabber-vertical that swaps the layout to vertical mode,
    • tabber-border that adds a subtle border with padding around contents,
    • tabber-padding that increases the content padding,
    • fancy that changes the design to resemble the in-game one.
  • $divstyle - adds a style to the wrapper of the tabs
  • $tab[number]style - adds styles to the tab on the specified index
  • $con[number]style - adds styles to the content box on the specified index
  • $tabstyle - adds styles to tabs
  • $constyle - adds styles to content boxes
  • $conclass - adds classes to content boxes
  • $ulstyle - adds styles to tab list
  • $ulclass - adds classes to tab list

Example usage

{{Tabber
|Orange=Content of tab 1
|Banana=Content of tab 2
|Grape=Content of tab 3
|Pie=Content of tab 4
}}

Result:

  • Orange
  • Banana
  • Grape
  • Pie

Content of tab 1

  Tip: Nested tabs are also supported. Using tabber-border in $divclass recommended.
{{Tabber
|$divclass=tabber-border
|Tab 1=
{{Tabber
|Tab 1=Content of tab 1
|Tab 2=Content of tab 2
}}
|Tab 2=Content of tab 2
}}

Result:

  • Tab 1
  • Tab 2
  • Tab 1
  • Tab 2

Content of tab 1

  Warning: Templates do not work well with tables and other templates, but there is a workaround for that. Before providing the parameter's value that contains MediaWiki markup, use <dfn>{{</dfn> and insert <dfn>}}</dfn> at the end of the parameter's value. Using it is not required until you notice that something breaks.

Use like so:

{{Tabber
|$divclass=tabber-vertical
|Tab 1=<dfn>{{</dfn>
{| class="wikitable"
|'''Orange'''
|'''Apple'''
|-
|Bread
|Pie
|-
|Butter
|Ice cream 
|}
<dfn>}}</dfn>
|Tab 2=Content of tab 2
}}

Result:

  • Tab 1
  • Tab 2

{{

Orange Apple
Bread Pie
Butter Ice cream

}}

  Tip: You can also style tabs with a similar design to the one that appears in-game when setting the $divclass parameter to fancy. You can combine it with other classes. Recommended: tabber-vertical.
{{Tabber
|$divclass=tabber-vertical fancy
|Latin=Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|Fruits=<dfn>{{</dfn>
{| class="wikitable"
|'''Orange'''
|'''Apple'''
|-
|Apple
|Grapes
|-
|Avocado
|Pineapples
|}
<dfn>}}</dfn>
}}

Result:

  • Latin
  • Fruits

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.