Module:Mbox
Appearance
This module is used by most of the basic Notice templates and is invoked by {{MessageBox}}.
local p = {}
local getArgs = require('Module:Arguments').getArgs
function p.main(frame)
local args = getArgs(frame)
local styles = {}
if args.bordercolor then
styles['border-left'] = '4px solid ' .. args.bordercolor
elseif args.type == 'notice' then
styles['border-left'] = '4px solid #3a86c8'
elseif args.type == 'warning' then
styles['border-left'] = '4px solid #c8a83a'
elseif args.type == 'danger' then
styles['border-left'] = '4px solid #c83a3a'
else
styles['border-left'] = '4px solid #5a8a3a'
end
if args.bgcolor then
styles['background-color'] = args.bgcolor
else
styles['background-color'] = '#1a2a10'
end
local container = mw.html.create('div')
:addClass('mbox')
:addClass(args.class or '')
:css(styles)
:css({
['padding'] = '10px 14px',
['margin'] = '8px 0',
['display'] = 'flex',
['align-items'] = 'flex-start',
['gap'] = '12px',
['border-radius'] = '2px',
})
:cssText(args.style or '')
local content = container:tag('div')
:css({ ['flex'] = '1' })
if args.image then
container:tag('div')
:wikitext('[[File:' .. args.image .. '|' .. (args.imagewidth or '40px') .. ']]')
end
if args.header then
content:tag('div')
:css({
['font-weight'] = 'bold',
['margin-bottom'] = '4px',
['color'] = '#c09040',
['text-transform'] = 'uppercase',
['letter-spacing'] = '0.05em',
})
:wikitext(args.header)
end
if args.text then
content:tag('div')
:wikitext(args.text)
if args.comment then
content:tag('div')
:css({ ['font-size'] = '0.85em', ['opacity'] = '0.7', ['margin-top'] = '4px' })
:wikitext(args.comment)
end
end
return container
end
return p