« Module:Charte » : différence entre les versions
Apparence
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| Ligne 2 : | Ligne 2 : | ||
local chartes = { | local chartes = { | ||
biographie = { | biographie = { | ||
titre = "#6eacdc9c", | titre = "#6eacdc9c", | ||
| Ligne 18 : | Ligne 17 : | ||
hr = "#000000a3" | hr = "#000000a3" | ||
}, | }, | ||
defaut = { | defaut = { | ||
titre = "#eaecf0", | titre = "#eaecf0", | ||
| Ligne 25 : | Ligne 23 : | ||
} | } | ||
} | } | ||
-- Fonction pour vérifier si la valeur est un code HEX (#rrggbb ou #rrggbbaa) | |||
local function isHexCode(value) | |||
return type(value) == "string" and mw.ustring.match(value, "^#%x%x%x%x%x%x%x?$") ~= nil | |||
end | |||
function p.couleur(frame) | function p.couleur(frame) | ||
| Ligne 31 : | Ligne 34 : | ||
local type = args["type"] or "titre" | local type = args["type"] or "titre" | ||
if chartes[charte] and chartes[charte][type] then | if isHexCode(charte) then | ||
return charte -- retourne directement le code couleur passé | |||
elseif chartes[charte] and chartes[charte][type] then | |||
return chartes[charte][type] | return chartes[charte][type] | ||
else | else | ||
Version du 24 mai 2025 à 07:06
La documentation pour ce module peut être créée à Module:Charte/doc
local p = {}
local chartes = {
biographie = {
titre = "#6eacdc9c",
soustitre = "#a9c8e09c",
hr = "#6eacdc9c"
},
empire = {
titre = "#993333",
soustitre = "#ffcccc",
hr = "#cc6666"
},
darkgods = {
titre = "#000000cc",
soustitre = "#000000a3",
hr = "#000000a3"
},
defaut = {
titre = "#eaecf0",
soustitre = "#a2a9b1",
hr = "#eaecf0"
}
}
-- Fonction pour vérifier si la valeur est un code HEX (#rrggbb ou #rrggbbaa)
local function isHexCode(value)
return type(value) == "string" and mw.ustring.match(value, "^#%x%x%x%x%x%x%x?$") ~= nil
end
function p.couleur(frame)
local args = frame.args
local charte = args["charte"] or "defaut"
local type = args["type"] or "titre"
if isHexCode(charte) then
return charte -- retourne directement le code couleur passé
elseif chartes[charte] and chartes[charte][type] then
return chartes[charte][type]
else
return chartes["defaut"][type] or "#dddddd"
end
end
return p