« 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 |
||
Ligne 11 : | Ligne 11 : | ||
local couleur = args['couleur'] or '#3b82f6' | local couleur = args['couleur'] or '#3b82f6' | ||
-- Construction de l'HTML | -- Création du lien cliquable | ||
local html = mw.html.create('div') | local lienUrl = mw.uri.encode(lien, 'WIKI') | ||
-- Construction de l'HTML avec un vrai lien | |||
local html = mw.html.create('a') | |||
:attr('href', mw.title.new(lien):fullUrl()) | |||
:addClass('wiki-nav-card-link') | |||
:css({ | |||
['display'] = 'block', | |||
['text-decoration'] = 'none', | |||
['color'] = 'inherit' | |||
}) | |||
local card = html:tag('div') | |||
:addClass('wiki-nav-card') | :addClass('wiki-nav-card') | ||
:css({ | :css({ | ||
['background'] = 'linear-gradient(135deg, ' .. couleur .. ' 0%, rgba(59, 130, 246, 0.8) 100%)', | ['background'] = 'linear-gradient(135deg, ' .. couleur .. ' 0%, rgba(59, 130, 246, 0.8) 100%)', | ||
['border-radius'] = ' | ['border-radius'] = '16px', | ||
['padding'] = ' | ['padding'] = '24px', | ||
['margin'] = ' | ['margin'] = '8px', | ||
['max-width'] = ' | ['max-width'] = '320px', | ||
['min-height'] = '200px', | |||
['position'] = 'relative', | ['position'] = 'relative', | ||
['overflow'] = 'hidden', | ['overflow'] = 'hidden', | ||
['box-shadow'] = '0 | ['box-shadow'] = '0 4px 12px rgba(0, 0, 0, 0.2)', | ||
['transition'] = ' | ['transition'] = 'all 0.3s ease', | ||
['cursor'] = 'pointer | ['cursor'] = 'pointer', | ||
['color'] = 'white' | |||
[' | |||
}) | }) | ||
-- Image en haut | |||
if image and image ~= '' then | if image and image ~= '' then | ||
local imageHtml = '[[File:' .. image .. '|80px|link=]]' | |||
card:tag('div') | |||
:css({ | :css({ | ||
[' | ['text-align'] = 'center', | ||
['margin-bottom'] = '16px' | |||
[' | |||
}) | }) | ||
: | :wikitext(imageHtml) | ||
else | else | ||
card:tag('div') | |||
[' | :css({ | ||
[' | ['text-align'] = 'center', | ||
[' | ['font-size'] = '48px', | ||
[' | ['margin-bottom'] = '16px', | ||
['opacity'] = '0.7' | |||
}) | }) | ||
:wikitext(' | :wikitext('📄') | ||
end | end | ||
-- | -- Titre | ||
card:tag('h3') | |||
:css({ | :css({ | ||
['margin'] = '0 0 | ['margin'] = '0 0 12px 0', | ||
['color'] = 'white', | ['color'] = 'white', | ||
['font-size'] = '1. | ['font-size'] = '1.4rem', | ||
['font-weight'] = 'bold' | ['font-weight'] = 'bold', | ||
['text-align'] = 'center' | |||
}) | }) | ||
:wikitext(titre) | :wikitext(titre) | ||
-- Description | |||
card:tag('p') | |||
:css({ | :css({ | ||
['margin'] = '0', | ['margin'] = '0', | ||
['color'] = 'rgba(255, 255, 255, 0.9)', | ['color'] = 'rgba(255, 255, 255, 0.9)', | ||
['font-size'] = '0.9rem', | ['font-size'] = '0.9rem', | ||
['line-height'] = '1.4' | ['line-height'] = '1.4', | ||
['text-align'] = 'center' | |||
}) | }) | ||
:wikitext(description) | :wikitext(description) | ||
return tostring(html) | return tostring(html) |
Version du 8 septembre 2025 à 16:32
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'
-- Création du lien cliquable
local lienUrl = mw.uri.encode(lien, 'WIKI')
-- Construction de l'HTML avec un vrai lien
local html = mw.html.create('a')
:attr('href', mw.title.new(lien):fullUrl())
:addClass('wiki-nav-card-link')
:css({
['display'] = 'block',
['text-decoration'] = 'none',
['color'] = 'inherit'
})
local card = html:tag('div')
:addClass('wiki-nav-card')
:css({
['background'] = 'linear-gradient(135deg, ' .. couleur .. ' 0%, rgba(59, 130, 246, 0.8) 100%)',
['border-radius'] = '16px',
['padding'] = '24px',
['margin'] = '8px',
['max-width'] = '320px',
['min-height'] = '200px',
['position'] = 'relative',
['overflow'] = 'hidden',
['box-shadow'] = '0 4px 12px rgba(0, 0, 0, 0.2)',
['transition'] = 'all 0.3s ease',
['cursor'] = 'pointer',
['color'] = 'white'
})
-- Image en haut
if image and image ~= '' then
local imageHtml = '[[File:' .. image .. '|80px|link=]]'
card:tag('div')
:css({
['text-align'] = 'center',
['margin-bottom'] = '16px'
})
:wikitext(imageHtml)
else
card:tag('div')
:css({
['text-align'] = 'center',
['font-size'] = '48px',
['margin-bottom'] = '16px',
['opacity'] = '0.7'
})
:wikitext('📄')
end
-- Titre
card:tag('h3')
:css({
['margin'] = '0 0 12px 0',
['color'] = 'white',
['font-size'] = '1.4rem',
['font-weight'] = 'bold',
['text-align'] = 'center'
})
:wikitext(titre)
-- Description
card:tag('p')
:css({
['margin'] = '0',
['color'] = 'rgba(255, 255, 255, 0.9)',
['font-size'] = '0.9rem',
['line-height'] = '1.4',
['text-align'] = 'center'
})
:wikitext(description)
return tostring(html)
end
return p