Module:Notice

local p = {}

function p.getStyleForColor(color) result = { ["green"] = "rgb(170, 220, 0)", ["teal"] = "rgb(47, 172, 172)", ["blue"] = "rgb(0, 153, 255)", ["orange"] = "rgb(255, 128, 0)", ["yellow"] = "rgb(235, 238, 61)", ["red"] = "rgb(217, 0, 0)", ["pink"] = "rgb(240, 60, 120)", ["maroon"] = "rgb(174, 21, 102)", ["gray"] = "rgb(201, 201, 201)", }

return result[color] or color end

-- Entry point for the module function p.main(frame) local args = frame:getParent.args local color = args.color or 'green' local align = args.align or '' local textAlign = args['text-align'] or 'left' local width = args.width or '' local file = args.file or '' local fileSize = args.filesize or '48px' local header = args.header or '' local content = args.content or ''

local root = mw.html.create('div') :addClass('notice') :attr('align', align) :css('text-align', textAlign) :css('border-color', p.getStyleForColor(color)) :css('border-radius', "5px 5px 5px 5px") :css('border-style', "solid") :css('border-width', "1px 5px 1px 5px") :css('column-gap', "1em") :css('display', "flex") :css('flex-direction', "row") :css('margin', ".5em 0") :css('padding', ".5em")

if width ~= '' then root:css('width', width) end

if file ~= '' then root:tag('div') :addClass('notice-image') :css('position', "relative") :css('top', "50%") :wikitext(string.format('', file, fileSize)) end

local contentDiv = root:tag('div') :addClass('notice-content') :css('flex-grow', 1)

if header ~= '' then contentDiv:tag('div') :addClass('notice-header') :css('font-weight', 600) :wikitext(header) end

contentDiv:tag('div') :addClass('notice-description') :css('font-size', "9pt") :wikitext(content)

return tostring(root) end

return p