Basculer le menu
Changer de menu des préférences
Basculer le menu personnel
Non connecté(e)
Votre adresse IP sera visible au public si vous faites des modifications.

« Module:NavCard » : différence entre les versions

De Nefald Wiki
Hiob (discussion | contributions)
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')... »
 
Hiob (discussion | contributions)
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'] = '12px',
             ['border-radius'] = '16px',
             ['padding'] = '20px',
             ['padding'] = '24px',
             ['margin'] = '16px',
             ['margin'] = '8px',
             ['max-width'] = '400px',
             ['max-width'] = '320px',
            ['min-height'] = '200px',
             ['position'] = 'relative',
             ['position'] = 'relative',
             ['overflow'] = 'hidden',
             ['overflow'] = 'hidden',
             ['box-shadow'] = '0 8px 32px rgba(0, 0, 0, 0.3)',
             ['box-shadow'] = '0 4px 12px rgba(0, 0, 0, 0.2)',
             ['transition'] = 'transform 0.3s ease, box-shadow 0.3s ease',
             ['transition'] = 'all 0.3s ease',
             ['cursor'] = 'pointer'
             ['cursor'] = 'pointer',
        })
             ['color'] = 'white'
        :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)'
         })
         })
      
      
    -- Image en haut
     if image and image ~= '' then
     if image and image ~= '' then
         imageDiv:tag('img')
         local imageHtml = '[[File:' .. image .. '|80px|link=]]'
            :attr('src', '[[File:' .. image .. '|120px]]')
        card:tag('div')
             :css({
             :css({
                 ['width'] = '100%',
                 ['text-align'] = 'center',
                ['height'] = '100%',
                 ['margin-bottom'] = '16px'
                 ['object-fit'] = 'cover'
             })
             })
             :attr('alt', titre)
             :wikitext(imageHtml)
     else
     else
         imageDiv:css({
         card:tag('div')
                 ['display'] = 'flex',
            :css({
                 ['align-items'] = 'center',
                 ['text-align'] = 'center',
                 ['justify-content'] = 'center',
                 ['font-size'] = '48px',
                 ['color'] = 'rgba(255, 255, 255, 0.6)',
                 ['margin-bottom'] = '16px',
                ['font-size'] = '48px'
                 ['opacity'] = '0.7'
             })
             })
             :wikitext('📷')
             :wikitext('📄')
     end
     end
      
      
     -- Contenu textuel
     -- Titre
     local contentDiv = html:tag('div')
     card:tag('h3')
   
    contentDiv:tag('h3')
         :css({
         :css({
             ['margin'] = '0 0 8px 0',
             ['margin'] = '0 0 12px 0',
             ['color'] = 'white',
             ['color'] = 'white',
             ['font-size'] = '1.25rem',
             ['font-size'] = '1.4rem',
             ['font-weight'] = 'bold'
             ['font-weight'] = 'bold',
            ['text-align'] = 'center'
         })
         })
         :wikitext(titre)
         :wikitext(titre)
      
      
     contentDiv:tag('p')
     -- 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)
   
    -- 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)
     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