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
 
(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
      
      
    -- 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'
      
      
     -- Construction de l'HTML
     -- Lien cliquable avec div dedans
     local html = mw.html.create('div')
     local html = mw.html.create('a')
         :addClass('wiki-nav-card')
         :attr('href', mw.uri.encode(lien, 'WIKI'))
        :css({
        :addClass('nav-card-link')
            ['background'] = 'linear-gradient(135deg, ' .. couleur .. ' 0%, rgba(59, 130, 246, 0.8) 100%)',
        :css('text-decoration', 'none')
            ['border-radius'] = '12px',
        :css('display', 'inline-block')
            ['padding'] = '20px',
       
            ['margin'] = '16px',
    local card = html:tag('div')
            ['max-width'] = '400px',
         :addClass('nav-card')
            ['position'] = 'relative',
        :css('background', couleur)
            ['overflow'] = 'hidden',
         :css('width', '280px')
            ['box-shadow'] = '0 8px 32px rgba(0, 0, 0, 0.3)',
        :css('height', '160px')
            ['transition'] = 'transform 0.3s ease, box-shadow 0.3s ease',
        :css('border-radius', '12px')
            ['cursor'] = 'pointer'
        :css('position', 'relative')
        })
        :css('overflow', 'hidden')
         :attr('onclick', 'window.location.href="/wiki/' .. mw.uri.encode(lien) .. '"')
        :css('margin', '10px')
   
 
    -- Zone image
     -- Image de fond si présente
    local imageDiv = html:tag('div')
     if image ~= '' then
         :css({
         card:tag('div')
            ['width'] = '100%',
            :addClass('nav-card-bg')
            ['height'] = '120px',
             :css('background-image', 'url(/images/' .. image .. ')')
            ['margin-bottom'] = '16px',
             :css('background-size', 'cover')
            ['border-radius'] = '8px',
            :css('position', 'absolute')
            ['overflow'] = 'hidden',
             :css('top', '0')
            ['background'] = 'rgba(255, 255, 255, 0.1)'
            :css('left', '0')
        })
            :css('width', '100%')
      
            :css('height', '100%')
     if image and image ~= '' then
             :css('opacity', '0.3')
         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
     end
   
 
     -- Contenu textuel
     -- Contenu texte
     local contentDiv = html:tag('div')
     local content = card:tag('div')
   
        :addClass('nav-card-content')
    contentDiv:tag('h3')
        :css('position', 'absolute')
         :css({
         :css('bottom', '0')
            ['margin'] = '0 0 8px 0',
        :css('left', '0')
            ['color'] = 'white',
        :css('right', '0')
            ['font-size'] = '1.25rem',
        :css('padding', '20px')
            ['font-weight'] = 'bold'
        :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)
   
       
     contentDiv:tag('p')
     content:tag('p')
         :css({
         :css('color', 'rgba(255,255,255,0.9)')
            ['margin'] = '0',
        :css('margin', '0')
            ['color'] = 'rgba(255, 255, 255, 0.9)',
            ['font-size'] = '0.9rem',
            ['line-height'] = '1.4'
        })
         :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)