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)
mAucun résumé des modifications
Hiob (discussion | contributions)
mAucun résumé des modifications
Ligne 4 : Ligne 4 :
     local args = frame:getParent().args
     local args = frame:getParent().args
      
      
    -- Récupération des paramètres
     local titre = args['titre'] or 'Titre'
     local titre = args['titre'] or args[1] or 'Titre'
     local description = args['description'] or 'Description'  
     local description = args['description'] or args[2] or 'Description'
     local lien = args['lien'] or titre
     local lien = args['lien'] or args[3] or titre
     local image = args['image'] or ''
     local image = args['image'] or args[4] or ''
     local couleur = args['couleur'] or '#3b82f6'
     local couleur = args['couleur'] or '#3b82f6'
      
      
     -- Création du lien cliquable
     -- Construction simple avec onclick
     local lienUrl = mw.uri.encode(lien, 'WIKI')
     local result = '<div class="nav-card-wrapper" onclick="window.location.href=\'/wiki/' .. lien .. '\'">'
    result = result .. '<div class="nav-card" style="background-color: ' .. couleur .. ';">'
      
      
     -- Construction de l'HTML avec un vrai lien
     -- Image de fond si présente
    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
     if image and image ~= '' then
         local imageHtml = '[[File:' .. image .. '|80px|link=]]'
         result = result .. '<div class="nav-card-bg" style="background-image: url(/wiki/images/thumb/' .. image .. '/300px-' .. image .. ');"></div>'
        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
     end
      
      
     -- Titre
     -- Overlay pour le texte
     card:tag('h3')
     result = result .. '<div class="nav-card-overlay">'
        :css({
    result = result .. '<h3 class="nav-card-title">' .. titre .. '</h3>'
            ['margin'] = '0 0 12px 0',
     result = result .. '<p class="nav-card-desc">' .. description .. '</p>'
            ['color'] = 'white',
    result = result .. '</div></div></div>'
            ['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)
     return result
end
end


return p
return p