« Module:Fonctions » : différence entre les versions
Apparence
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| Ligne 25 : | Ligne 25 : | ||
local couleurHR = charteModule.couleur{ args = { charte = charte, type = "hr" } } | local couleurHR = charteModule.couleur{ args = { charte = charte, type = "hr" } } | ||
local bloc = '<div style="margin: 0.5em 0 | local bloc = '<div style="margin: 0.5em 0; overflow: hidden; font-size: 90%;">' .. | ||
'<div style="background-color: ' .. couleurFond .. '; color: ' .. couleurTexte .. '; text-align: center; padding: 0.5em; font-weight: bold;">' .. | '<div style="background-color: ' .. couleurFond .. '; color: ' .. couleurTexte .. '; text-align: center; padding: 0.5em; font-weight: bold;">' .. | ||
mw.text.encode(titre) .. mandatBlock .. | mw.text.encode(titre) .. mandatBlock .. | ||
Version du 29 mai 2025 à 15:03
La documentation pour ce module peut être créée à Module:Fonctions/doc
local p = {}
local charteModule = require("Module:Charte") -- appel direct à ton module Charte
function p.multipleSuccession(frame)
local args = frame.args
local result = {}
for i = 1, 5 do
local titre = args["Titre"..i]
local mandat = args["Mandat"..i]
local charte = args["Charte"..i] or args["Charte"] or "defaut"
local predecesseur = args["Prédécesseur"..i]
local successeur = args["Successeur"..i]
if titre then -- on affiche si titre est défini (pas besoin que predecesseur et successeur soient obligatoires)
local mandatBlock = ""
if mandat and mandat ~= "" then
mandatBlock = '<div style="font-weight: normal; font-size: 90%;">' .. mw.text.encode(mandat) .. '</div>'
end
-- Appel à ton module Charte pour couleurs
local couleurFond = charteModule.couleur{ args = { charte = charte, type = "titre" } }
local couleurTexte = charteModule.couleur{ args = { charte = charte, type = "texte" } }
local couleurHR = charteModule.couleur{ args = { charte = charte, type = "hr" } }
local bloc = '<div style="margin: 0.5em 0; overflow: hidden; font-size: 90%;">' ..
'<div style="background-color: ' .. couleurFond .. '; color: ' .. couleurTexte .. '; text-align: center; padding: 0.5em; font-weight: bold;">' ..
mw.text.encode(titre) .. mandatBlock ..
'</div>' ..
'<div style="display: flex; justify-content: space-between; align-items: center; padding: 0.5em;">'
if predecesseur and predecesseur ~= "" then
bloc = bloc .. '<div style="text-align: left; flex: 1;">← [[' .. predecesseur .. ']]</div>'
else
bloc = bloc .. '<div style="text-align: left; flex: 1;"></div>'
end
bloc = bloc .. '<div style="flex: 0 0 auto; padding: 0 1em;">·</div>'
if successeur and successeur ~= "" then
bloc = bloc .. '<div style="text-align: right; flex: 1;">[[' .. successeur .. ']] →</div>'
else
bloc = bloc .. '<div style="text-align: right; flex: 1;"></div>'
end
bloc = bloc .. '</div></div>'
-- Ligne horizontale personnalisée avec couleur du module Charte
bloc = bloc .. '<hr style="border: none; height: 1px; background-color: ' .. couleurHR .. ';">'
table.insert(result, bloc)
end
end
return table.concat(result, "\n")
end
return p