Global Lua Modules/Mbox

Mbox is a module for creating message boxes.
== Features ==
* Highly customizable with classes, inline styles, and provided CSS selectors.
* Optional features such as an image, left border, right-side text (for e.g. shortcuts), and a dismiss function.
== ==
=== Module ===
First thing is the module itself. You don't need to copy the code. Just create a module titled Module:Mbox (or any other—just remember to adjust #invoke calls) and put this in the code.
return require('Dev:Mbox')
=== CSS ===
Next, add the following to your Common.css.
There are two types of CSS rules for Mbox. The first type is the structural/functionality CSS which should not be changed, lest it break the Mbox. The second type is the design of the Mbox, which should be modified to fit your community's needs. For the design-related selectors you should use, see #Design.
The following CSS represents the base, and can be found at MediaWiki:Global Lua Modules/Mbox.css.
.mbox {
 --type-important: rgba(200, 0, 0, 0.8);
 --type-moderate: rgba(233, 124, 47, 0.8);
 --type-minor: rgba(241, 197, 37, 0.8);
 display: flex;
 position: relative;
 background-color: rgba(255, 255, 255, 0.7);
 border: 1px solid #d6d6d6;
 border-left-width: 8px;
 border-left-color: #d6d6d6;
 border-radius: 3px;
 margin-bottom: 5px;
 min-height: 32px;
}
.mbox.mbox-type-important {
 border-left-color: var(--type-important);
}
.mbox.mbox-type-moderate {
 border-left-color: var(--type-moderate);
}
.mbox.mbox-type-minor {
 border-left-color: var(--type-minor);
}
.mbox__content {
 display: table;
 box-sizing: border-box;
 width: 100%;
 padding: 8px 15px;
}
.mbox__content__image {
 display: table-cell;
 width: 40px;
 height: 100%;
 text-align: center;
 vertical-align: middle;
 padding-right: 15px;
}
.mbox__content__wrapper {
 display: table-cell;
 vertical-align: middle;
}
.mbox__content__header {
 display: block;
 font-weight: bold;
}
.mbox__content__text {
 display: block;
}
.mbox__content__text__comment {
 font-size: small;
}
.mbox__content__aside {
 display: table-cell;
 width: 100px;
 vertical-align: middle;
 text-align: center;
 padding-left: 15px;
 border-left: 1px solid #d6d6d6;
}
.mbox__close {
 position: absolute;
 right: 0;
 top: 0;
 padding: 2px 7px;
 font-weight: bold;
 font-size: 16px;
 color: #bbb;
 cursor: pointer;
 transition: all .15s ease-in;
}
.mbox__close:hover {
 color: #777;
}
.mbox__close:after {
 content: '×';
}
.mw-collapsed + .mbox__close {
 transform: rotate(45deg);
 padding: 4px 7px 5px 2px;
}
/* Ensure text is readable in the FandomDesktop dark theme. */
.theme-fandomdesktop-dark .mbox {
 background-color: var(--theme-page-background-color--secondary);
 border-color: var(--theme-border-color);
}
=== Template ===
The module is designed to be used as a regular template. To do that just create a template (ex: Template:Mbox) with following content:
{{#invoke:Mbox|main}}
Now the template you created will accept parameters documented below.
These parameters can also be passed directly to the #invoke and will act as defaults. Their values will be overridden by same ones passed to the template.
== ==
For examples of how to use these parameters, see #Examples.
Parameter name	Description 	Required?	Default value
class 	Additional classes to the root .mbox element. 	 	—
bordercolor 	The color of the thick left-most border. 	 	
type 	Type of mbox as declared as in CSS with variables. Affects color of the thick left-most border. 	 	—
bgcolor 	The color of the mbox's background. 	 	
style 	Additional inline styles to the root .mbox element. 	 	—
image 	An image to be added to the left of all text content. 	 	—
imagewidth 	The width of the image (height automatically adjusts). 	 	80px
imageadjust 	For center/left/right/thumb 	 	—
imagelink 	The link to which the image points (could link to the relevant maintenance category, per example). If not included, the image will be un-clickable. 	 	—
header 	The header (bold text placed at the top). This is typically used to very briefly explain the subject of the mbox itself, as when the mbox is closed, only the header will show. 	 	—
text 	Non-bold text placed below the header, typically used to explain the subject of the mbox in further or additional detail. When the mbox is closed, this text will be hidden. 	 	—
comment 	Smaller non-bold text placed below the main text, typically used to add additional links or context about the notice. When the mbox is closed, this text will be hidden. 	 	—
aside 	Text placed within a small allocation on the right side separated by a light gray border. Most commonly used to show shortcuts to the page in question (such as on policy pages). When the mbox is closed, this text will be hidden.	 	—
id 	id=cleanup). 	 	—
collapsed 	collapsed=true would set the mbox to be collapsed by default). 	 	—
== Design ==
Some communities may wish to customize the appearance of the mboxes. The most common styling options are provided below:
; Technical notes
* The mbox module uses the BEM selector convention for readability and to make future additions to the HTML structure easier.
* Additional inline styles to the root .mbox element can be achieved via the style parameter in the template.
== Examples ==
=== Different parameters ===
==== Basic mbox ====
==== Using types ====
To use types, CSS variables and helper classes must be added, such as:
If added:
==== Image ====
==== Aside ====
==== Bit of everything ====
=== Restyled mboxes ===
==== Standard/default style ====
==== Wookieepedia style ====
Reproducing w:c:starwars:Template:Citation.
; CSS:
.mbox {
 background-color: #7bb0d8;
 border: none;
 border-radius: 10px;
}
 
.mbox__close {
 color: #0c8787;
 font-weight: normal;
 font-size: 13px;
}
 
.mbox__close:after {
 content: '[hide]';
}
 
.mw-collapsed + .mbox__close {
 transform: none;
 padding: 2px 7px;
}
 
.mw-collapsed + .mbox__close:after {
 content: '[show]';
}
==== Final Fantasy Wiki style ====
Reproducing w:c:finalfantasy:Template:Rename.
; CSS:
.theme-fandomdesktop-light .mbox {
 border-top: 1px solid #afaa84;
 border-radius: 10px;
 background: linear-gradient(180deg,rgba(255,255,246,1) 0,rgba(247,219,185,1) 40px);
}
.theme-fandomdesktop-dark .mbox {
 border-top: 3px solid #1e9de3 !important;
 border: 0;
 background: linear-gradient(180deg,rgba(5,37,78,.5) 0,rgba(5,37,78,.5) 75%,rgba(5,37,78,0));
}
== Technical and miscellaneous ==
* There is no category parameter. In order to inject a category onto an article using a certain mbox implementation, simply add <includeonly>[[Category:{{{category}}}]]</includeonly>. If you wish to make the injection of the category optional, add <includeonly>{{#ifeq: {{{1|}}} | nocat | | [[Category:{{{category}}}]] }}</includeonly>.
== ==
* Global Lua Modules/Cbox - Rounded corner and different layout