Module:Mbox: Difference between revisions
Appearance
imported>FANDOM No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
local p = {} | |||
local getArgs = require('Module:Arguments').getArgs | |||
local | |||
function p.main(frame) | |||
local args = getArgs(frame) | local args = getArgs(frame) | ||
local styles = {} | local styles = {} | ||
if args.bordercolor then | if args.bordercolor then | ||
styles['border-left | styles['border-left'] = '4px solid ' .. args.bordercolor | ||
elseif args.type then | elseif args.type == 'notice' then | ||
styles['border-left | 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 | end | ||
if args.bgcolor then | if args.bgcolor then | ||
styles['background-color'] = args.bgcolor | styles['background-color'] = args.bgcolor | ||
else | |||
styles['background-color'] = '#1a2a10' | |||
end | end | ||
local container = mw.html.create('div') | local container = mw.html.create('div') | ||
:addClass('mbox') | :addClass('mbox') | ||
:addClass(args.class) | :addClass(args.class or '') | ||
:css(styles) | :css(styles) | ||
:css( | :css({ | ||
:cssText(args.style) | ['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') | local content = container:tag('div') | ||
:css({ ['flex'] = '1' }) | |||
:css( | |||
if args.image then | if args.image then | ||
container:tag('div') | |||
: | :wikitext('[[File:' .. args.image .. '|' .. (args.imagewidth or '40px') .. ']]') | ||
end | end | ||
if args.header then | 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) | :wikitext(args.header) | ||
end | end | ||
if args.text then | if args.text then | ||
content:tag('div') | |||
:wikitext(args.text) | :wikitext(args.text) | ||
if args.comment then | if args.comment then | ||
content:tag('div') | |||
: | :css({ ['font-size'] = '0.85em', ['opacity'] = '0.7', ['margin-top'] = '4px' }) | ||
:wikitext(args.comment) | :wikitext(args.comment) | ||
end | end | ||
end | end | ||
| Line 123: | Line 72: | ||
end | end | ||
return p | |||
return | |||
Latest revision as of 00:28, 29 June 2026
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