Difference between revisions of "Template:Warning"

From PINE64
Jump to navigation Jump to search
(Created page with "<languages/> <onlyinclude>{{#switch:<translate></translate> | = {{#if: {{{msg|{{{1|}}}}}}|<table cellspacing="0" cellpadding="0" border="0" style="box-sizing:border-box; borde...")
 
(Try fix the new line problem)
(20 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<languages/>
<noinclude>
<onlyinclude>{{#switch:<translate></translate>
{{Template}}
| =
{{#if: {{{msg|{{{1|}}}}}}|<table cellspacing="0" cellpadding="0" border="0" style="box-sizing:border-box; border:1px #d33 solid; background: transparent; margin-top:0.5em;padding:0.5em;background-color: #fee7e6"><tr><td nowrap="nowrap" valign="top">}}<span style="position: relative; top: -2px;">[[File:OOjs_UI_icon_notice-destructive.svg|18px|<translate><!--T:1--> Warning</translate>|link=]]</span> '''<translate><!--T:2--> Warning:</translate>''' {{#if: {{{msg|{{{1|}}}}}}|</td><td valign="top" style="padding-{{dir|{{pagelang}}|right|left}}:0.5em;">{{{msg|{{{1|}}}}}}</td></tr></table>}}
| #default=
  {{#invoke:Template translation|renderTranslatedTemplate|template=Template:Warning|noshift=1}}
}}</onlyinclude>
{{Documentation|content=
<translate>
== Usage == <!--T:3-->


<!--T:4-->
A waring box for highlighting dangerous actions and security warnings. It starts with "'''Warning:'''" by default.
This template has two possible usages:


<!--T:5-->
== Usage ==
# Will have the text flow below when the warning text is too long</translate>
<translate>
<!--T:6-->
# Uses a table to indent the text.


=== Method 1 === <!--T:7-->
<nowiki>{{Warning|warning content}}</nowiki>


<!--T:8-->
== Example ==
The following displays the warning icon and the word "Warning:".</translate>
<translate>
<!--T:17-->
You can follow this with whatever text/images/markup you like.


<!--T:9-->
<nowiki>{{Warning|This is a warning.}}</nowiki>
Wiki Code:
</translate>


<nowiki>{{warning}}</nowiki> <translate><!--T:10--> Don't do that!</translate>
{{Warning|This is a warning.}}


{{warning}} <translate><!--T:11--> Don't do that!</translate>
== Technical notes ==


<translate>
The boxes use <code>display: table</code> to support both adaptive width and floating siblings, all other alternatives can't archive them as perfect as this solution within just one HTML element. However, it has its own flaw, if you put it into another table, its padding will gone. Avoid putting hints, notes and warnings into any tables until solution was found, or we give up and use two elements for just one box.
=== Method 2 === <!--T:12-->


<!--T:13-->
This template uses class <code>.template-box</code> and <code>.template-warning</code>.
The following includes the text passed to the template, and uses a table to stop the text flowing round the icon.
In the future, if the [https://www.mediawiki.org/wiki/Extension:TemplateStyles TemplateStyles Extension] is installed on this MediaWiki instance,
one may move the embedded inline styles to Template Style files.


<!--T:14-->
== See also ==
Wiki Code:
</translate>


<nowiki>{{warning|1=</nowiki><translate><!--T:15--> Here is a long warning, which is sufficiently wordy to run onto a second line (unless you have a really large screen!), which would normally cause it to wrap round the icon, but because we passed it as a parameter it keeps its left alignment straight.</translate><nowiki>}}</nowiki>  
* [https://wiki.archlinux.org/title/Template:Warning ArchWiki: Template:Warning]: the template on which this one is based on
 
* [[Template:Hint]]
{{warning|1=<translate><!--T:16--> Here is a long warning, which is sufficiently wordy to run onto a second line (unless you have a really large screen!), which would normally cause it to wrap round the icon, but because we passed it as a parameter it keeps its left alignment straight.</translate>}}
* [[Template:Note]]
}}
</noinclude><includeonly><div role="note" class="template-box" style="
[[Category:Warning templates{{#translation:}}|{{PAGENAME}}]]
display: table;
min-width: 16em;
min-height: 1.6em;
margin: .5em 0 1em;
padding: .5em 1em;
border: 1px solid #d33;
color: black;
background-color: #fee7e6;
"><strong>Warning:</strong> {{{1|}}}</div></includeonly>

Revision as of 22:47, 7 October 2021

This page is a template. Check out all pages using this template.
For more information, read Template:Template.

A waring box for highlighting dangerous actions and security warnings. It starts with "Warning:" by default.

Usage

{{Warning|warning content}}

Example

{{Warning|This is a warning.}}
Warning: This is a warning.

Technical notes

The boxes use display: table to support both adaptive width and floating siblings, all other alternatives can't archive them as perfect as this solution within just one HTML element. However, it has its own flaw, if you put it into another table, its padding will gone. Avoid putting hints, notes and warnings into any tables until solution was found, or we give up and use two elements for just one box.

This template uses class .template-box and .template-warning. In the future, if the TemplateStyles Extension is installed on this MediaWiki instance, one may move the embedded inline styles to Template Style files.

See also