Mudanças entre as edições de "Módulo:Gb"
Ir para navegação
Ir para pesquisar
| Linha 2: | Linha 2: | ||
function p.render(frame) | function p.render(frame) | ||
local parent = frame:getParent() | local parent = frame:getParent() | ||
local args = parent and parent.args or frame.args | local args = parent and parent.args or frame.args | ||
| Linha 30: | Linha 29: | ||
-- Monta HTML | -- Monta HTML | ||
local html = mw.html.create("div"):cssText(containerStyle) | local html = mw.html.create("div"):cssText(containerStyle) | ||
html:tag("div"):cssText(gradientStyle) | html:tag("div"):cssText(gradientStyle) | ||
-- Título | |||
html:tag("div"):cssText(textStyle) | |||
:tag("div"):cssText(titleStyle) | |||
:wikitext(titulo) | |||
-- Botão (criado com mw.html, não texto puro) | |||
html:tag("a") | html:tag("a") | ||
:attr("href", link) | :attr("href", link) | ||
Edição das 04h14min 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 "#"
-- Estilos inline
local containerStyle = table.concat({
"position:relative;",
"width:216px;height:292px;",
"border-radius:14px;",
"overflow:hidden;",
"font-family:Inter,Segoe UI,Roboto,Arial,sans-serif;",
"color:#fff;",
"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;")
})
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%);"
local textStyle = "position:absolute;left:12px;right:12px;bottom:70px;"
local titleStyle = "font-size:16px;font-weight:800;"
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;"
-- Monta HTML
local html = mw.html.create("div"):cssText(containerStyle)
html:tag("div"):cssText(gradientStyle)
-- Título
html:tag("div"):cssText(textStyle)
:tag("div"):cssText(titleStyle)
:wikitext(titulo)
-- Botão (criado com mw.html, não texto puro)
html:tag("a")
:attr("href", link)
:cssText(buttonStyle)
:wikitext(botao)
return tostring(html)
end
return p