Editing Module:MovementTabsGive feedback
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
| Latest revision | Your text | ||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function p.render(frame) | function p.render(frame) | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
local root = args[2] and args[1] or nil | |||
local tabsStr = args[2] and args[2] or args[1] or "" | local tabsStr = args[2] and args[2] or args[1] or "" | ||
local tabs = mw.text.split(tabsStr, "%s*,%s*") | local tabs = mw.text.split(tabsStr, "%s*,%s*") | ||
local current = mw.title.getCurrentTitle().fullText | local current = mw.title.getCurrentTitle().fullText | ||
local | local baseRoot = root or mw.title.getCurrentTitle().rootText | ||
-- | local html = mw.html.create("div") | ||
:css{ | |||
["border-radius"]="8px", | |||
["background-image"]="linear-gradient(#987556, #483728)", | |||
["color"]="#FFF5E8", | |||
["display"]="flex", | |||
["flex-wrap"]="wrap", | |||
["justify-content"]="center", | |||
["gap"]="1em", | |||
["font-family"]="Retail Demo, Radiance, sans-serif", | |||
["text-transform"]="uppercase", | |||
["font-weight"]="bold", | |||
["font-size"]="15px", | |||
["padding"]="4px" | |||
} | |||
for _, tab in ipairs(tabs) do | for _, tab in ipairs(tabs) do | ||
local | local page = tab == "Overview" and baseRoot or (baseRoot .. "/" .. tab) | ||
local active = current == page | |||
local active = current == | |||
html:tag("div") | |||
:css{ | |||
["padding"]="4px 8px", | |||
["cursor"]="pointer", | |||
["border-radius"]=active and "4px 4px 0 0" or nil, | |||
["background-color"]=active and "#FFF0D6" or nil, | |||
["color"]=active and "#483728" or "#FFF0D6", | |||
["text-shadow"]=not active and "0px 2px 2px black, 0px 0px 2px black" or nil | |||
} | |||
:wikitext(string.format( | |||
"[[%s|%s]]", | |||
page, | |||
tab | |||
)) | |||
end | end | ||