« Module:Icône » : différence entre les versions
Création du module Icône qui remplacera le contenu du modèle Icône |
mAucun résumé des modifications |
||
Ligne 4 : | Ligne 4 : | ||
local DEFAULT_ICON_NAME = '_DEFAULT' | local DEFAULT_ICON_NAME = '_DEFAULT' | ||
local DEFAULT_SIZE = 'normal' | |||
local STANDARD_SIZE = { | local STANDARD_SIZE = { | ||
normal = '14', | normal = '14', | ||
Ligne 18 : | Ligne 19 : | ||
local tooltip = args['infobulle'] or args['tooltip'] or icon.tooltip | local tooltip = args['infobulle'] or args['tooltip'] or icon.tooltip | ||
local size = args[2] or | local size = args[2] or DEFAULT_SIZE | ||
size = STANDARD_SIZE[size] or string.gsub(size, 'px', '') | size = STANDARD_SIZE[size] or string.gsub(size, 'px', '') | ||
Version du 13 juin 2021 à 00:35
Ce module contient le paramétrage du modèle {{Icône}}.
local p = {}
local icons = require('Module:Icône/Données')
local DEFAULT_ICON_NAME = '_DEFAULT'
local DEFAULT_SIZE = 'normal'
local STANDARD_SIZE = {
normal = '14',
grand = '20',
big = '20'
}
function buildIcon(args)
local name = args[1] or DEFAULT_ICON_NAME
local link = args['lien'] or args['link'] or ''
local icon = icons[name:lower()] or icons[DEFAULT_ICON_NAME]
local filename = icon.filename
local tooltip = args['infobulle'] or args['tooltip'] or icon.tooltip
local size = args[2] or DEFAULT_SIZE
size = STANDARD_SIZE[size] or string.gsub(size, 'px', '')
return tostring(mw.html.create('span')
:css('cursor', 'help')
:attr('title', tooltip)
:wikitext('[[Fichier:'..filename..'|x'..size..'px|link='..link..']]')
:allDone())
end
function p.build(frame)
return buildIcon(require('Module:Outils').extractArgs(frame))
end
return p