Mudanças entre as edições de "Módulo:Gb"

De Wiki Gla
Ir para navegação Ir para pesquisar
Linha 10: Linha 10:
     local link  = args.link or "#"
     local link  = args.link or "#"


    -- Estilos inline
     local html = mw.html.create("div")
     local containerStyle = table.concat({
         :css("position", "relative")
         "position:relative;",
         :css("width", "216px")
         "width:216px;height:292px;",
        :css("height", "292px")
         "border-radius:14px;",
         :css("border-radius", "14px")
         "overflow:hidden;",
         :css("overflow", "hidden")
         "font-family:Inter,Segoe UI,Roboto,Arial,sans-serif;",
         :css("font-family", "Inter,Segoe UI,Roboto,Arial,sans-serif")
         "color:#fff;",
         :css("color", "#fff")
         "box-shadow:0 6px 18px rgba(0,0,0,.35);",
         :css("box-shadow", "0 6px 18px rgba(0,0,0,.35)")
         (imagem ~= "" and "background:#111 url(" .. mw.uri.encode(mw.title.makeTitle('File', imagem).fullUrl) .. ") center/cover no-repeat;" or "background:#111;")
         :css("background", imagem ~= "" and "url(" .. mw.uri.encode(mw.title.makeTitle('File', imagem).fullUrl) .. ") center/cover no-repeat #111" or "#111")
    })


     local gradientStyle = "position:absolute;inset:0;background:linear-gradient(180deg,rgba(0,0,0,0.05)0%,rgba(0,0,0,0.6)55%,rgba(0,0,0,0.85)100%);"
     html:tag("div")
    local textStyle = "position:absolute;left:12px;right:12px;bottom:70px;"
        :css("position", "absolute")
    local titleStyle = "font-size:16px;font-weight:800;"
        :css("inset", "0")
    local buttonStyle = "position:absolute;left:12px;right:12px;bottom:14px;display:block;text-align:center;padding:10px 12px;background:#1f8b4c;color:#eafff3;font-weight:800;font-size:14px;text-decoration:none;border-radius:10px;"
        :css("background", "linear-gradient(180deg,rgba(0,0,0,0.05)0%,rgba(0,0,0,0.6)55%,rgba(0,0,0,0.85)100%)")


     -- Monta HTML
     html:tag("div")
    local html = mw.html.create("div"):cssText(containerStyle)
        :css("position", "absolute")
    html:tag("div"):cssText(gradientStyle)
        :css("left", "12px")
 
        :css("right", "12px")
    -- Título
        :css("bottom", "70px")
    html:tag("div"):cssText(textStyle)
        :tag("div")
         :tag("div"):cssText(titleStyle)
        :css("font-size", "16px")
         :css("font-weight", "800")
         :wikitext(titulo)
         :wikitext(titulo)


    -- Botão (criado com mw.html, não texto puro)
     html:tag("a")
     html:tag("a")
         :attr("href", link)
         :attr("href", link)
         :cssText(buttonStyle)
         :css("position", "absolute")
         :wikitext(botao)
         :css("left", "12px")
        :css("right", "12px")
        :css("bottom", "14px")
        :css("display", "block")
        :css("text-align", "center")
        :css("padding", "10px 12px")
        :css("background", "#1f8b4c")
        :css("color", "#eafff3")
        :css("font-weight", "800")
        :css("font-size", "14px")
        :css("text-decoration", "none")
        :css("border-radius", "10px")
        :node(mw.html.create("span"):wikitext(botao))


     return tostring(html)
     return tostring(html)

Edição das 04h17min de 27 de agosto de 2025

A documentação para este módulo pode ser criada em Módulo:Gb/doc

local p = {}

function p.render(frame)
    local parent = frame:getParent()
    local args = parent and parent.args or frame.args

    local imagem = args.imagem or ""
    local titulo = args.titulo or "Título"
    local botao  = args.botao or "Ler agora"
    local link   = args.link or "#"

    local html = mw.html.create("div")
        :css("position", "relative")
        :css("width", "216px")
        :css("height", "292px")
        :css("border-radius", "14px")
        :css("overflow", "hidden")
        :css("font-family", "Inter,Segoe UI,Roboto,Arial,sans-serif")
        :css("color", "#fff")
        :css("box-shadow", "0 6px 18px rgba(0,0,0,.35)")
        :css("background", imagem ~= "" and "url(" .. mw.uri.encode(mw.title.makeTitle('File', imagem).fullUrl) .. ") center/cover no-repeat #111" or "#111")

    html:tag("div")
        :css("position", "absolute")
        :css("inset", "0")
        :css("background", "linear-gradient(180deg,rgba(0,0,0,0.05)0%,rgba(0,0,0,0.6)55%,rgba(0,0,0,0.85)100%)")

    html:tag("div")
        :css("position", "absolute")
        :css("left", "12px")
        :css("right", "12px")
        :css("bottom", "70px")
        :tag("div")
        :css("font-size", "16px")
        :css("font-weight", "800")
        :wikitext(titulo)

    html:tag("a")
        :attr("href", link)
        :css("position", "absolute")
        :css("left", "12px")
        :css("right", "12px")
        :css("bottom", "14px")
        :css("display", "block")
        :css("text-align", "center")
        :css("padding", "10px 12px")
        :css("background", "#1f8b4c")
        :css("color", "#eafff3")
        :css("font-weight", "800")
        :css("font-size", "14px")
        :css("text-decoration", "none")
        :css("border-radius", "10px")
        :node(mw.html.create("span"):wikitext(botao))

    return tostring(html)
end

return p