Module:ElementHubNavigation: Difference between revisions
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| Line 4: | Line 4: | ||
* Description: Hub navigation module for Main Page with zero-CLS responsive design | * Description: Hub navigation module for Main Page with zero-CLS responsive design | ||
* Notes: Single SSR block with data-URI icons; mobile sticky bottom bar; desktop inline grid | * Notes: Single SSR block with data-URI icons; mobile sticky bottom bar; desktop inline grid | ||
* Uses | * Uses MediaWiki table syntax + string concatenation (like ElementNavigation pattern) | ||
]] | ]] | ||
| Line 27: | Line 27: | ||
} | } | ||
-- Generate a single hub link item | -- Generate a single hub link item as HTML string | ||
local function generateHubLink(hub) | local function generateHubLink(hub) | ||
return string.format( | |||
'<li class="cdx-hub__item"><a href="/wiki/%s" class="cdx-hub__link" data-hub="%s"><span class="cdx-hub__icon"><img src="%s" alt="" width="24" height="24" aria-hidden="true"></span><span class="cdx-hub__label">%s</span></a></li>', | |||
hub.url, | |||
hub.id, | |||
hub.icon, | |||
hub.label | |||
) | |||
end | end | ||
-- Main render function | -- Main render function | ||
function p.render(frame) | function p.render(frame) | ||
-- | -- Generate all hub links | ||
local | local hubLinks = {} | ||
for i, hub in ipairs(hubs) do | |||
hubLinks[i] = generateHubLink(hub) | |||
for | |||
end | end | ||
-- | -- Build complete output using MediaWiki table syntax + HTML | ||
local output = { | local output = { | ||
'{| class="hub-nav-table"', | '{| class="hub-nav-table"', | ||
'|- class="hub-nav-row"', | '|- class="hub-nav-row"', | ||
'| colspan="2" |', | '| colspan="2" |', | ||
'<div id="hub" class="cdx-hub" role="navigation" aria-label="Hub Navigation">', | |||
' <ul class="cdx-hub__list">', | |||
' ' .. table.concat(hubLinks, '\n '), | |||
' </ul>', | |||
' <div class="cdx-hub__panel" aria-hidden="true"></div>', | |||
'</div>', | |||
'<div id="hub-spacer" aria-hidden="true"></div>', | |||
'|}' | '|}' | ||
} | } | ||