Template:Navbar/doc: Difference between revisions

From HIBIKIFORUM
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{documentation subpage}}
{{Documentation subpage}}
{{template rating|p}}
{{lua|Module:Navbar}}
{{#ifeq:{{BASEPAGENAME}}|Navbar}}
__NOTOC__


{{tl|Navbar}} provides a small "view '''·''' talk '''·''' edit" navigation bar. It is primarily used for content-heavy templates and other transcluded content blocks, so that the content inside the template or block is more easily editable in situations where it was found, without having track it down through examining transclusion code.
{{tl|Navbar}} provides a small "view '''·''' talk '''·''' edit" navigation bar. It is primarily used for content-heavy templates and other transcluded content blocks, so that the content inside the template or block is more easily editable in situations where it was found, without having track it down through examining transclusion code.


==Usage==
== Usage ==
===General===
=== General ===
When one of the following examples is placed inside a given template (or block of content used for selective transclusion), it adds basic navbar navigational functionality:
When one of the following examples is placed inside a given template (or block of content used for selective transclusion), it adds basic navbar navigational functionality:
:<code><nowiki>{{navbar|{{subst:PAGENAME}}|mini=y}}</nowiki></code>
: {{tlc|navbar|{{((}}subst:PAGENAME{{))}}|mini{{=}}y}}
:<code><nowiki>{{navbar|{{subst:PAGENAME}}|plain=y}}</nowiki></code>
: {{tlc|navbar|{{((}}subst:PAGENAME{{))}}|plain{{=}}y}}
:<code><nowiki>{{navbar|{{subst:PAGENAME}}|fontstyle=color: green; font-style: italic;}}</nowiki></code>
: {{tlc|navbar|{{((}}subst:PAGENAME{{))}}|fontstyle{{=}}color: green; font-style: italic;}}


The <code><nowiki>{{subst:PAGENAME}}</nowiki></code> will be substituted with the page name of the real location of the content when parsed by the servers. For example, <code><nowiki>{{navbar|Navbar/doc}}</nowiki></code> gives:<br />{{navbar|Navbar/doc}}
The <code><nowiki>{{subst:PAGENAME}}</nowiki></code> will be substituted with the page name of the real location of the content when parsed by the servers. For example, {{tlc|navbar|Navbar/doc}} gives:<br />{{navbar|Navbar/doc}}


When used in content that is selectively transcluded but which is also used as-is in its original location, this template should be wrapped in <code>|includeonly|p</code> markup, so that it only appears when transcluded.
When used in content that is selectively transcluded but which is also used as-is in its original location, this template should be wrapped in {{tag|includeonly}} markup, so that it only appears when transcluded.


===Font size and weight ===
=== Font size and weight ===
Font-size is 88% when used in a topical navbar template or in plain text, and 100% when nested in a navbox or infobox (because those templates' text size is already reduced; the "100%" is relative to the surrounding template's own content, not that of the entire page). The <code>|fontstyle</code> parameter can be used to adjust font size as needed (e.g. to reduce font size even more when the template is used inside a block element with a large font size). Do not abuse this to make excessively small text (i.e. less than 85% of the normal page text), since that causes accessibility problems for many readers.
Font-size is 88% when used in a topical navbar template or in plain text, and 100% when nested in a navbox or infobox (because those templates' text size is already reduced; the "100%" is relative to the surrounding template's own content, not that of the entire page). The {{para|fontstyle}} parameter can be used to adjust font size as needed (e.g. to reduce font size even more when the template is used inside a block element with a large font size). Do not abuse this to make excessively small text (i.e. less than 85% of the normal page text), since that causes accessibility problems for many readers.


In a topical navbar, the weight is "normal"; when nested in a navbox or infobox, it inherits the style of the surrounding content. The middot bullets are bold for better visibility.   
In a topical navbar, the weight is "normal"; when nested in a navbox or infobox, it inherits the style of the surrounding content. The middot bullets are bold for better visibility.   


==Examples==
=== Block level element ===
===Required parameters===
The template generates block-level markup with {{tag|div}} tags, and therefore, any surrounding markup cannot include {{tag|span}} tags, which would cause a lint error.
*<code><nowiki>{{navbar|Template Name}}</nowiki></code> – the template name is required.


===Optional parameters===
== Examples ==
=== Required parameters ===
* {{tlc|navbar|Template Name}} – the template name is required.
 
=== Optional parameters ===
{| class="wikitable"
{| class="wikitable"
! Options !! Parameters !! Produces... !! "Shortcut" template
! Options !! Parameters !! Produces... !! "Shortcut" template
|-
|-
| Basic || <code><nowiki>{{navbar|Template Name}}</nowiki></code> || {{navbar|Navbar/doc}} ||
| Basic || {{tlc|navbar|Template Name}} || {{navbar|Navbar/doc}} ||
|-
|-
| Different text || <code><nowiki>{{navbar|Template Name|</nowiki>'''text'''<nowiki>=This template:}}</nowiki></code> || {{navbar|Navbar/doc|text=This template:}} ||
| Different text || {{tlc|navbar|Template Name|'''text'''{{=}}This template:}} || {{navbar|Navbar/doc|text=This template:}} ||
|-
|-
| Without "This box:" text || <code><nowiki>{{navbar|Template Name|</nowiki>'''plain'''<nowiki>=y}}</nowiki></code> || {{navbar|Navbar/doc|plain=y}} || {{tl|view}}
| Without "This box:" text || {{tlc|navbar|Template Name|'''plain'''{{=}}y}} || {{navbar|Navbar/doc|plain=y}} || {{tls|view}}
|-
|-
| Short version || <code><nowiki>{{navbar|Template Name|</nowiki>'''mini'''<nowiki>=y}}</nowiki></code> || {{navbar|Navbar/doc|mini=y}} || {{tl|v}}
| Short version || {{tlc|navbar|Template Name|'''mini'''{{=}}y}} || {{navbar|Navbar/doc|mini=y}} || {{tls|v}}
|-
|-
| With brackets || <code><nowiki>{{navbar|Template Name|</nowiki>'''brackets'''<nowiki>=y}}</nowiki></code> || {{navbar|Navbar/doc|brackets=y}} ||
| With brackets || {{tlc|navbar|Template Name|'''brackets'''{{=}}y}} || {{navbar|Navbar/doc|brackets=y}} ||
|-
|-
| With font styling examples ([[Span and div|span]]) || <code><nowiki>{{navbar|Template Name|</nowiki>'''fontstyle'''<nowiki>=color: green; font-style: italic;}}</nowiki></code> || {{navbar|Navbar/doc|fontstyle=color: green; font-style: italic;}} ||
| With font styling examples ([[Wikipedia:Span and div|span]]) || {{tlc|navbar|Template Name|'''fontstyle'''{{=}}color: green; font-style: italic;}} || {{navbar|Navbar/doc|fontstyle=color: green; font-style: italic;}} ||
|-
|-
| With whole-template styling examples ([[Span and div|div]]) || <code><nowiki>{{navbar|Template Name|</nowiki>'''style'''<nowiki>=float:right; background: Beige; padding: 5px; border: 1px solid;}}</nowiki></code> || {{navbar|Navbar/doc|style=float:right; background: Beige; padding: 5px; border: 1px solid;}} ||
| With whole-template styling examples ([[Wikipedia:Span and div|div]]) || {{tlc|navbar|Template Name|'''style'''{{=}}float:right; background: Beige; padding: 5px; border: 1px solid;}} || {{navbar|Navbar/doc|style=float:right; background: Beige; padding: 5px; border: 1px solid;}} ||
|}
|}


==Notes==
== Notes ==
Navbar is contained within a <code><nowiki>div</nowiki></code> tag in order to accommodate a horizontal unnumbered list. This means it cannot be placed inside a <code><nowiki>span</nowiki></code> tag or other inline element, because the [[HTML Tidy]] extension will 'fix' situations where it finds block elements inside inline elements.
Navbar is contained within a {{tag|div|o}} tag in order to accommodate a horizontal unnumbered list. This means it cannot be placed inside a {{tag|span|o}} tag or other inline element, because the [[Wikipedia:HTML Tidy]] extension will 'fix' situations where it finds block elements inside inline elements.


== TemplateData ==
== TemplateData ==
Line 107: Line 110:
</templatedata>
</templatedata>


<includeonly>
<includeonly>{{sandbox other||{{testcases other||
 
<!-- Categories below this line, please -->
<!-- Categories below this line, please -->
[[Category:Templates]]
[[Category:Utility templates]]
</includeonly>
}}}}</includeonly>

Latest revision as of 01:55, 20 August 2023

Light bulb.png }}
It contains usage information, categories and other content that is not part of the original template page.


{{Navbar}} provides a small "view · talk · edit" navigation bar. It is primarily used for content-heavy templates and other transcluded content blocks, so that the content inside the template or block is more easily editable in situations where it was found, without having track it down through examining transclusion code.

Usage

General

When one of the following examples is placed inside a given template (or block of content used for selective transclusion), it adds basic navbar navigational functionality:

{{navbar|{{subst:PAGENAME}}|mini=y}}
{{navbar|{{subst:PAGENAME}}|plain=y}}
{{navbar|{{subst:PAGENAME}}|fontstyle=color: green; font-style: italic;}}

The {{subst:PAGENAME}} will be substituted with the page name of the real location of the content when parsed by the servers. For example, {{navbar|Navbar/doc}} gives:

When used in content that is selectively transcluded but which is also used as-is in its original location, this template should be wrapped in <includeonly>...</includeonly> markup, so that it only appears when transcluded.

Font size and weight

Font-size is 88% when used in a topical navbar template or in plain text, and 100% when nested in a navbox or infobox (because those templates' text size is already reduced; the "100%" is relative to the surrounding template's own content, not that of the entire page). The |fontstyle= parameter can be used to adjust font size as needed (e.g. to reduce font size even more when the template is used inside a block element with a large font size). Do not abuse this to make excessively small text (i.e. less than 85% of the normal page text), since that causes accessibility problems for many readers.

In a topical navbar, the weight is "normal"; when nested in a navbox or infobox, it inherits the style of the surrounding content. The middot bullets are bold for better visibility.

Block level element

The template generates block-level markup with <div>...</div> tags, and therefore, any surrounding markup cannot include <span>...</span> tags, which would cause a lint error.

Examples

Required parameters

  • {{navbar|Template Name}} – the template name is required.

Optional parameters

Options Parameters Produces... "Shortcut" template
Basic {{navbar|Template Name}}
Different text {{navbar|Template Name|text=This template:}}
Without "This box:" text {{navbar|Template Name|plain=y}} {{view}}
Short version {{navbar|Template Name|mini=y}} {{v}}
With brackets {{navbar|Template Name|brackets=y}}
With font styling examples (span) {{navbar|Template Name|fontstyle=color: green; font-style: italic;}}
With whole-template styling examples (div) {{navbar|Template Name|style=float:right; background: Beige; padding: 5px; border: 1px solid;}}

Notes

Navbar is contained within a <div> tag in order to accommodate a horizontal unnumbered list. This means it cannot be placed inside a <span> tag or other inline element, because the Wikipedia:HTML Tidy extension will 'fix' situations where it finds block elements inside inline elements.

TemplateData

When placed inside a given template, it adds navbar navigational functionality

Template parameters

ParameterDescriptionTypeStatus
Template Name

The name of the template, so links work correctly

Default
Stringrequired
Different texttext

Allows custom text to replace the default 'this box'

Default
This box
Stringoptional
Without 'This box:' textplain

Removes 'This box'

Default
0
Numberoptional
Short Versionmini

Shortens text to V T E

Default
0
Numberoptional
with bracketsbrackets

adds brackets before and after the links

Default
0
Numberoptional
Font colorfontstyle

Allows you to change the color of the font (in the format color:green)

Default
Stringoptional
To float to the sidestyle

Allows the template to float to the side (format=float:right)

Default
float:left
Stringoptional