« Module:TableColors » : différence entre les versions
De Nefald
Autres actions
Parsed frame:preprocess() |
Aucun résumé des modifications |
||
Ligne 35 : | Ligne 35 : | ||
-- Fonction principale pour styliser une cellule | -- Fonction principale pour styliser une cellule | ||
function p. | function p.cell(frame) | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
local colorName = mw.text.trim(args[1] or ""):lower() | local colorName = mw.text.trim(args[1] or ""):lower() | ||
local content = args[2] | local content = args[2] or "" | ||
-- Gestion des alias | -- Gestion des alias | ||
Ligne 53 : | Ligne 53 : | ||
local color = colors[colorName] or colors.light | local color = colors[colorName] or colors.light | ||
-- Construction | -- Construction de la balise span colorée | ||
return frame:preprocess(string.format( | |||
'style="background-color: %s; color: %s"', | '<span style="background-color: %s; color: %s; padding: 2px 8px; border-radius: 3px; display: inline-block;">%s</span>', | ||
color.bg, | color.bg, | ||
color.fg | color.fg, | ||
content ~= "" and content or " " | |||
)) | |||
end | end | ||
Ligne 88 : | Ligne 76 : | ||
for _, name in ipairs(sorted) do | for _, name in ipairs(sorted) do | ||
local color = colors[name] | local color = colors[name] | ||
table.insert(rows, string.format( | |||
'|-\n| %s || style="background:%s; color:%s; padding:8px 15px; font-weight:500;" | %s || <code>{{Couleur|%s}}</code>', | '|-\n| %s || style="background-color:%s; color:%s; padding:8px 15px; font-weight:500;" | %s || <code>{{Couleur|%s}}</code>', | ||
color.label, | color.label, | ||
color.bg, | color.bg, | ||
Ligne 95 : | Ligne 83 : | ||
color.label, | color.label, | ||
name | name | ||
) | )) | ||
end | end | ||
Ligne 104 : | Ligne 91 : | ||
.. '\n|}' | .. '\n|}' | ||
return frame:preprocess(wikitext) | return frame:preprocess(wikitext) | ||
end | end | ||
return p | return p |