« Module:Charte » : différence entre les versions
Apparence
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| Ligne 3 : | Ligne 3 : | ||
local chartes = { | local chartes = { | ||
biographie = { | biographie = { | ||
titre = "#6eacdc9c", | titre = "#6eacdc9c", | ||
soustitre = "#a9c8e09c", | soustitre = "#a9c8e09c", | ||
hr = "#6eacdc9c", | hr = "#6eacdc9c", | ||
}, | }, | ||
empire = { | empire = { | ||
titre = "#993333b0", | titre = "#993333b0", | ||
soustitre = "#831f1fc7", | soustitre = "#831f1fc7", | ||
hr = "#993333b0", | hr = "#993333b0", | ||
}, | }, | ||
geographie = { | geographie = { | ||
titre = "#209a57d9", | titre = "#209a57d9", | ||
soustitre = "#209a57a8", | soustitre = "#209a57a8", | ||
hr = "#209a57d9", | hr = "#209a57d9", | ||
}, | }, | ||
darkgods = { | darkgods = { | ||
titre = "#000000cc", | titre = "#000000cc", | ||
soustitre = "#000000a3", | soustitre = "#000000a3", | ||
hr = "#000000a3", | soustitre_color = "#ffffff", -- couleur du texte du sous-titre | ||
color = "#ffffff" -- texte | hr = "#000000a3", | ||
color = "#ffffff", -- couleur du texte général | |||
}, | }, | ||
defaut = { | defaut = { | ||
titre = "#eaecf0", | titre = "#eaecf0", | ||
soustitre = "#a2a9b1", | soustitre = "#a2a9b1", | ||
hr = "#eaecf0", | hr = "#eaecf0", | ||
} | } | ||
} | } | ||
| Ligne 36 : | Ligne 37 : | ||
function p.couleur(frame) | function p.couleur(frame) | ||
local args = frame.args | local args = frame.args | ||
local charte = args["charte"] or "defaut" | local charte = args["charte"] or "defaut" | ||
local type = args["type"] or "titre" | local type = args["type"] or "titre" | ||
-- Cas spécial : couleur du texte | -- Cas spécial : couleur du texte principal | ||
if type == "texte" then | if type == "texte" then | ||
if chartes[charte] and chartes[charte].color then | if chartes[charte] and chartes[charte].color then | ||
| Ligne 49 : | Ligne 50 : | ||
end | end | ||
-- Cas où la couleur est fournie directement | -- Cas spécial : couleur du texte de sous-titre | ||
if type == "soustitre_color" then | |||
if chartes[charte] and chartes[charte].soustitre_color then | |||
return chartes[charte].soustitre_color | |||
else | |||
return "#000000" -- noir par défaut | |||
end | |||
end | |||
-- Cas où la couleur est fournie directement comme code HEX | |||
if isHexCode(charte) then | if isHexCode(charte) then | ||
return charte | return charte | ||
Version du 29 mai 2025 à 07:21
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 = "#993333b0",
soustitre = "#831f1fc7",
hr = "#993333b0",
},
geographie = {
titre = "#209a57d9",
soustitre = "#209a57a8",
hr = "#209a57d9",
},
darkgods = {
titre = "#000000cc",
soustitre = "#000000a3",
soustitre_color = "#ffffff", -- couleur du texte du sous-titre
hr = "#000000a3",
color = "#ffffff", -- couleur du texte général
},
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"
-- Cas spécial : couleur du texte principal
if type == "texte" then
if chartes[charte] and chartes[charte].color then
return chartes[charte].color
else
return "#000000" -- noir par défaut
end
end
-- Cas spécial : couleur du texte de sous-titre
if type == "soustitre_color" then
if chartes[charte] and chartes[charte].soustitre_color then
return chartes[charte].soustitre_color
else
return "#000000" -- noir par défaut
end
end
-- Cas où la couleur est fournie directement comme code HEX
if isHexCode(charte) then
return charte
elseif chartes[charte] and chartes[charte][type] then
return chartes[charte][type]
else
return chartes["defaut"][type] or "#dddddd"
end
end
return p