« Module:Fonctions » : différence entre les versions
Apparence
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| Ligne 22 : | Ligne 22 : | ||
table.insert(html, '<div style="margin: 0.5em 0; overflow: hidden; font-size: 90%;">') | table.insert(html, '<div style="margin: 0.5em 0; overflow: hidden; font-size: 90%;">') | ||
table.insert(html, '<div style="background-color: ' .. couleurFond .. '; color: ' .. couleurTexte .. '; text-align: center; padding: 0.5em; font-weight: bold;">') | table.insert(html, '<div style="background-color: ' .. couleurFond .. '; color: ' .. couleurTexte .. '; text-align: center; padding: 0.5em; font-weight: bold;">') | ||
table.insert(html, titre or "") | table.insert(html, titre or "") | ||
| Ligne 30 : | Ligne 29 : | ||
table.insert(html, '</div>') | table.insert(html, '</div>') | ||
table.insert(html, '<div style="display: flex; justify-content: space-between; align-items: center; padding: 0.5em;">') | table.insert(html, '<div style="display: flex; justify-content: space-between; align-items: center; padding: 0.5em;">') | ||
table.insert(html, '<div style="text-align: left; flex: 1;">') | table.insert(html, '<div style="text-align: left; flex: 1;">') | ||
if predecesseur then | if predecesseur then | ||
| Ligne 45 : | Ligne 42 : | ||
table.insert(html, '[[' .. successeur .. ']] →') | table.insert(html, '[[' .. successeur .. ']] →') | ||
end | end | ||
table.insert(html, '</div>') | |||
table.insert(html, '</div>') | table.insert(html, '</div>') | ||
table.insert(html, '<hr style="background-color: ' .. couleurHr .. ';">') | table.insert(html, '<hr style="background-color: ' .. couleurHr .. ';">') | ||
table.insert(html, '</div>') | table.insert(html, '</div>') | ||
return table.concat(html) | return table.concat(html) | ||
| Ligne 57 : | Ligne 54 : | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
local result = {} | local result = {} | ||
for i = 1, 5 do | for i = 1, 5 do | ||
table.insert(result, genererBloc(args, i)) | table.insert(result, genererBloc(args, i)) | ||
end | end | ||
return table.concat(result) | return table.concat(result) | ||
end | end | ||
return p | return p | ||
Version du 1 juin 2025 à 06:22
La documentation pour ce module peut être créée à Module:Fonctions/doc
local p = {}
local charteModule = require('Module:Charte')
local function genererBloc(args, index)
local suffix = index == 1 and "" or tostring(index)
local titre = args["Titre" .. suffix]
local mandat = args["Mandat" .. suffix]
local predecesseur = args["Prédécesseur" .. suffix]
local successeur = args["Successeur" .. suffix]
local charte = args["Charte"] or "defaut"
if not (titre or predecesseur or successeur) then
return ""
end
local couleurFond = charteModule.couleur{charte = charte, type = "titre"}
local couleurTexte = charteModule.couleur{charte = charte, type = "texte"}
local couleurHr = charteModule.couleur{charte = charte, type = "hr"}
local html = {}
table.insert(html, '<div style="margin: 0.5em 0; overflow: hidden; font-size: 90%;">')
table.insert(html, '<div style="background-color: ' .. couleurFond .. '; color: ' .. couleurTexte .. '; text-align: center; padding: 0.5em; font-weight: bold;">')
table.insert(html, titre or "")
if mandat then
table.insert(html, '<div style="font-weight: normal; font-size: 90%;">' .. mandat .. '</div>')
end
table.insert(html, '</div>')
table.insert(html, '<div style="display: flex; justify-content: space-between; align-items: center; padding: 0.5em;">')
table.insert(html, '<div style="text-align: left; flex: 1;">')
if predecesseur then
table.insert(html, '← [[' .. predecesseur .. ']]')
end
table.insert(html, '</div>')
table.insert(html, '<div style="flex: 0 0 auto; padding: 0 1em;">·</div>')
table.insert(html, '<div style="text-align: right; flex: 1;">')
if successeur then
table.insert(html, '[[' .. successeur .. ']] →')
end
table.insert(html, '</div>')
table.insert(html, '</div>')
table.insert(html, '<hr style="background-color: ' .. couleurHr .. ';">')
table.insert(html, '</div>')
return table.concat(html)
end
function p.main(frame)
local args = frame:getParent().args
local result = {}
for i = 1, 5 do
table.insert(result, genererBloc(args, i))
end
return table.concat(result)
end
return p