Editing Module:MovementTabs

Warning: You are not logged in. Once you make an edit, a temporary account will be created for you. Learn more. Log in or create an account to continue receiving notifications after this account expires, and to access other features.
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 = {}
local lang_module = require("Module:Lang")


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 rootPage = args[1] or current
    local lang_code = lang_module.get_lang_code()
    local lang_suffix = (lang_code ~= "en") and ("/" .. lang_code) or ""


     -- Remove lang suffix from root if present
     local baseRoot
     if lang_suffix ~= "" and rootPage:sub(-#lang_suffix) == lang_suffix then
    if root then
         rootPage = rootPage:sub(1, -#lang_suffix - 1)
        baseRoot = root
     else
        local fullTitle = mw.title.getCurrentTitle().fullText
         local segments = mw.text.split(fullTitle, "/")
        if #segments > 1 then
            table.remove(segments)
            baseRoot = table.concat(segments, "/")
        else
            baseRoot = fullTitle
        end
     end
     end


    -- Create outer container using your new CSS class
     local html = mw.html.create("div")
     local html = mw.html.create("div"):addClass("hero-tabs")
        :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 pageTarget
         local page = tab == "Overview" and baseRoot or (baseRoot .. "/" .. tab)
        if tab == "Overview" then
         local active = current == page
            pageTarget = rootPage .. lang_suffix
        else
            pageTarget = rootPage .. "/" .. tab .. lang_suffix
         end


         local pagePlain = tab == "Overview" and rootPage or (rootPage .. "/" .. tab)
         html:tag("div")
        local active = current == pagePlain or current == pagePlain .. lang_suffix
            :css{
 
                ["padding"]="4px 8px",
        local div = html:tag("div"):addClass("hero-tab")
                ["cursor"]="pointer",
 
                ["border-radius"]=active and "4px 4px 0 0" or nil,
        if active then
                ["background-color"]=active and "#FFF0D6" or nil,
            div:addClass("hero-tab-active")
                ["color"]=active and "#483728" or "#FFF0D6",
            div:wikitext(string.format('[[:%s|%s]]', pageTarget, tab))
                ["text-shadow"]=not active and "0px 2px 2px black, 0px 0px 2px black" or nil
        else
            }
             div:wikitext(string.format('[[:%s|<span class="hero-tab-inactive">%s</span>]]', pageTarget, tab))
             :wikitext(string.format(
        end
                "[[%s|%s]]",
                page,
                tab
            ))
     end
     end


Please note that all contributions to The Deadlock Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see Deadlock:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)
Preview page with this template

Page included on this page: