模块:Message box

WikiBot留言 | 贡献2026年6月19日 (五) 23:49的版本 (精简版 Module:Message box(仅 ombox,供 Documentation 沙盒通知))
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

-- Module:Message box
-- 精简版,仅实现 ombox(橙色消息框),用于沙盒提示

local messageBox = {}

function messageBox.main(boxType, args)
	if boxType ~= 'ombox' then
		return ''
	end
	local image = args.image or ''
	local text = args.text or ''
	local extraClass = args.class or ''
	local root = mw.html.create('div')
		:addClass('ombox')
		:addClass(extraClass)
		:css({
			['border'] = '1px solid #a2a9b1',
			['border-left'] = '10px solid #f28500',
			['background-color'] = '#fdf2d5',
			['color'] = '#000',
			['margin'] = '0.5em 0',
			['padding'] = '0.5em 1em',
		})
	if image ~= '' then
		root:tag('div')
			:css('float', 'left')
			:css('margin', '0 0.5em 0 0')
			:css('width', '60px')
			:css('text-align', 'center')
			:wikitext(image)
	end
	root:tag('div')
		:css('overflow', 'hidden')
		:wikitext(text)
	return tostring(root)
end

return messageBox