« 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')... » |
(Aucune différence)
|
Version du 8 septembre 2025 à 10:14
La documentation pour ce module peut être créée à Module:NavCard/doc
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')
:addClass('wiki-nav-card')
:css({
['background'] = 'linear-gradient(135deg, ' .. couleur .. ' 0%, rgba(59, 130, 246, 0.8) 100%)',
['border-radius'] = '12px',
['padding'] = '20px',
['margin'] = '16px',
['max-width'] = '400px',
['position'] = 'relative',
['overflow'] = 'hidden',
['box-shadow'] = '0 8px 32px rgba(0, 0, 0, 0.3)',
['transition'] = 'transform 0.3s ease, box-shadow 0.3s ease',
['cursor'] = 'pointer'
})
:attr('onclick', 'window.location.href="/wiki/' .. mw.uri.encode(lien) .. '"')
-- Zone image
local imageDiv = html:tag('div')
:css({
['width'] = '100%',
['height'] = '120px',
['margin-bottom'] = '16px',
['border-radius'] = '8px',
['overflow'] = 'hidden',
['background'] = 'rgba(255, 255, 255, 0.1)'
})
if image and image ~= '' then
imageDiv:tag('img')
:attr('src', '[[File:' .. image .. '|120px]]')
:css({
['width'] = '100%',
['height'] = '100%',
['object-fit'] = 'cover'
})
:attr('alt', titre)
else
imageDiv:css({
['display'] = 'flex',
['align-items'] = 'center',
['justify-content'] = 'center',
['color'] = 'rgba(255, 255, 255, 0.6)',
['font-size'] = '48px'
})
:wikitext('📷')
end
-- Contenu textuel
local contentDiv = html:tag('div')
contentDiv:tag('h3')
:css({
['margin'] = '0 0 8px 0',
['color'] = 'white',
['font-size'] = '1.25rem',
['font-weight'] = 'bold'
})
:wikitext(titre)
contentDiv:tag('p')
:css({
['margin'] = '0',
['color'] = 'rgba(255, 255, 255, 0.9)',
['font-size'] = '0.9rem',
['line-height'] = '1.4'
})
:wikitext(description)
-- Effet de brillance
html:tag('div')
:css({
['position'] = 'absolute',
['top'] = '0',
['left'] = '-100%',
['width'] = '100%',
['height'] = '100%',
['background'] = 'linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent)',
['transition'] = 'left 0.5s ease'
})
:addClass('shine-effect')
return tostring(html)
end
return p