Module:Notice: Difference between revisions

m 1 revision imported: PS to FS migration
remove align and update the margin to auto
 
(One intermediate revision by one other user not shown)
Line 16: Line 16:
     return result[color] or color
     return result[color] or color
end
end
function p.getStyleForColorBack(colorBack)
    result = {
        ["green"] = "rgba(170, 220, 0, 0.2)",
        ["teal"] = "rgba(47, 172, 172, 0.2)",
        ["blue"] = "rgba(0, 153, 255, 0.2)",
        ["orange"] = "rgba(255, 128, 0, 0.2)",
        ["yellow"] = "rgba(235, 238, 61, 0.2)",
        ["red"] = "rgba(217, 0, 0, 0.2)",
        ["pink"] = "rgba(240, 60, 120, 0.2)",
        ["maroon"] = "rgba(174, 21, 102, 0.2)",
        ["gray"] = "rgba(201, 201, 201, 0.2)",
    }
    return result[colorBack] or colorBack
end


-- Entry point for the module
-- Entry point for the module
Line 21: Line 37:
     local args = frame:getParent().args
     local args = frame:getParent().args
     local color = args.color or 'green'
     local color = args.color or 'green'
    local colorBack = args.colorBack or ''
     local align = args.align or ''
     local align = args.align or ''
     local textAlign = args['text-align'] or 'left'
     local textAlign = args['text-align'] or 'left'
Line 31: Line 48:
     local root = mw.html.create('div')
     local root = mw.html.create('div')
         :addClass('notice')
         :addClass('notice')
        :attr('align', align)
         :css('text-align', textAlign)
         :css('text-align', textAlign)
         :css('border-color', p.getStyleForColor(color))
         :css('border-color', p.getStyleForColor(color))
Line 40: Line 56:
         :css('display', "flex")
         :css('display', "flex")
         :css('flex-direction', "row")
         :css('flex-direction', "row")
         :css('margin', ".5em 0")
         :css('margin', "auto")
         :css('padding', ".5em")
         :css('padding', ".5em")
       
    if colorBack ~= '' then
    root:css('background-color', p.getStyleForColorBack(colorBack))
    end




Line 47: Line 67:
         root:css('width', width)
         root:css('width', width)
     end
     end


     if file ~= '' then
     if file ~= '' then
Line 52: Line 73:
             :addClass('notice-image')
             :addClass('notice-image')
             :css('position', "relative")
             :css('position', "relative")
             :css('top', "50%")
             --:css('top', "50%")
            :css("margin", "auto")
             :wikitext(string.format('[[File:%s|%s|link=]]', file, fileSize))
             :wikitext(string.format('[[File:%s|%s|link=]]', file, fileSize))
     end
     end