-- <nowiki> local Mbox = {} local getArgs = require('Dev:Arguments').getArgs function Mbox.main(frame) local args = getArgs(frame) -- styles local styles = {} if args.bordercolor then styles['border-left-color'] = args.bordercolor elseif args.type then -- Sly: no longer supported: styles['border-left-color'] = 'var(--type-' .. args.type .. ')' -- instead of CSS vars, handle types in here if args.type == 'important' then styles['border-left-color'] = 'rgba(200, 0, 0, 0.8)' elseif args.type == 'moderate' then styles['border-left-color'] = 'rgba(233, 124, 47, 0.8)' elseif args.type == 'info' then styles['border-left-color'] = 'rgba(2, 98, 190, 0.8)' end end if args.bgcolor then styles['background-color'] = args.bgcolor end -- icons local icon = args.icon or '' -- images local image = args.image or '' local imagewidth = args.imagewidth or '80px' local imagelink = '' if args.imagelink then imagelink = '|link=' .. args.imagelink end local imagewikitext = '[[File:' .. image .. '|' .. imagewidth .. imagelink .. ']]' -- id for closure local id = args.id or 'mbox' local container = mw.html.create('div') :addClass('mbox') :addClass(args.class) :css(styles) :cssText(args.style) local content = container:tag('div') :addClass('mbox__content') if args.image then content:tag('div') :addClass('mbox__content__image') :addClass('mw-collapsible') :attr('id', 'mw-customcollapsible-' .. id) :wikitext(imagewikitext) end if args.icon then content:tag('div') :addClass('mbox__content__image') :addClass('fandom-icons') :addClass('mw-collapsible') :attr('id', 'mw-customcollapsible-' .. id) :wikitext(icon) end local contentwrapper = content:tag('div') :addClass('mbox__content__wrapper') if args.header then contentwrapper:tag('div') :addClass('mbox__content__header') :wikitext(args.header) end if args.text then local text = contentwrapper:tag('div') :addClass('mbox__content__text') :addClass('mw-collapsible') :attr('id', 'mw-customcollapsible-' .. id) :wikitext(args.text) if args.comment then text:tag('div') :addClass('mbox__content__text__comment') :wikitext(args.comment) end end contentwrapper:tag('span') :addClass('mbox__close') :addClass('mw-customtoggle-' .. id) :attr('title', 'Dismiss') if args.aside then content:tag('div') :addClass('mbox__content__aside') :addClass('mw-collapsible') :attr('id', 'mw-customcollapsible-' .. id) :wikitext(args.aside) end return container end return Mbox
Community content is available under CC-BY-SA
unless otherwise noted.