« Module:NavCard » : différence entre les versions
De Nefald Wiki
Autres actions
Page créée avec « local p = {} function p.main(frame) local args = frame:getParent().args -- Récupération des paramètres local titre = args['titre'] or args[1] or 'Titre' local description = args['description'] or args[2] or 'Description' local lien = args['lien'] or args[3] or titre local image = args['image'] or args[4] or '' local couleur = args['couleur'] or '#3b82f6' -- Construction de l'HTML local html = mw.html.create('div')... » |
mAucun résumé des modifications |
||
(3 versions intermédiaires par le même utilisateur non affichées) | |||
Ligne 4 : | Ligne 4 : | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
local titre = args['titre'] or 'Titre' | |||
local titre = args['titre' | local description = args['description'] or 'Description' | ||
local description = args['description' | local lien = args['lien'] or titre | ||
local lien = args['lien' | local image = args['image'] or '' | ||
local image = args['image' | |||
local couleur = args['couleur'] or '#3b82f6' | local couleur = args['couleur'] or '#3b82f6' | ||
-- | -- Lien cliquable avec div dedans | ||
local html = mw.html.create(' | local html = mw.html.create('a') | ||
: | :attr('href', mw.uri.encode(lien, 'WIKI')) | ||
:addClass('nav-card-link') | |||
:css('text-decoration', 'none') | |||
:css('display', 'inline-block') | |||
local card = html:tag('div') | |||
:addClass('nav-card') | |||
:css('background', couleur) | |||
:css('width', '280px') | |||
:css('height', '160px') | |||
:css('border-radius', '12px') | |||
:css('position', 'relative') | |||
:css('overflow', 'hidden') | |||
: | :css('margin', '10px') | ||
-- Image de fond si présente | |||
if image ~= '' then | |||
:css( | card:tag('div') | ||
:addClass('nav-card-bg') | |||
:css('background-image', 'url(/images/' .. image .. ')') | |||
:css('background-size', 'cover') | |||
:css('position', 'absolute') | |||
:css('top', '0') | |||
:css('left', '0') | |||
:css('width', '100%') | |||
:css('height', '100%') | |||
if | :css('opacity', '0.3') | ||
: | |||
:css( | |||
: | |||
: | |||
end | end | ||
-- Contenu | -- Contenu texte | ||
local | local content = card:tag('div') | ||
:addClass('nav-card-content') | |||
:css('position', 'absolute') | |||
:css( | :css('bottom', '0') | ||
:css('left', '0') | |||
:css('right', '0') | |||
:css('padding', '20px') | |||
:css('background', 'linear-gradient(transparent, rgba(0,0,0,0.7))') | |||
content:tag('h3') | |||
:css('color', 'white') | |||
:css('margin', '0 0 8px 0') | |||
:wikitext(titre) | :wikitext(titre) | ||
content:tag('p') | |||
:css( | :css('color', 'rgba(255,255,255,0.9)') | ||
:css('margin', '0') | |||
:wikitext(description) | :wikitext(description) | ||
return tostring(html) | return tostring(html) |