Jump to content

Module:Page tabs and Module:Page tabs/sandbox: Difference between pages

(Difference between pages)
Page 1
Page 2
Content deleted Content added
fix text color in dark mode; this generally works but may cause problems, in which case revert or try specifying a different CSS value
 
add back custom tab coloring
 
Line 15: Line 15:
local root = mw.html.create()
local root = mw.html.create()
root:wikitext(yesno(args.NOTOC) and '__NOTOC__' or nil)
root:wikitext(yesno(args.NOTOC) and '__NOTOC__' or nil)

local row = root:tag('div')
local row = root:tag('div')
:css('background', args.Background or '#f8fcff')
:css('background', args.Background or nil)
:css('color', 'black')
:cssText(args.style or nil)
:addClass('template-page-tabs')
:addClass('template-page-tabs')
:addClass(args.class or nil)
if not args[1] then
if not args[1] then
args[1] = '{{{1}}}'
args[1] = '{{{1}}}'
end
end

for i, link in ipairs(args) do
for i, link in ipairs(args) do
makeTab(row, link, args, i, args["class" .. i] or nil, args["style" .. i] or nil)
makeTab(row, link, tonumber(args.This) == i,
(tonumber(args.This) == i and args['tab-bg']) or args['tab1-bg'])
end
end
Line 31: Line 31:
end
end


function p.makeTab(root, link, args, i, class, css)
function p.makeTab(root, link, selected, tabColor)
local thisPage = (args.This == 'auto' and link:find('[[' .. mw.title.getCurrentTitle().prefixedText .. '|', 1, true)) or tonumber(args.This) == i
root:tag('span')
root:tag('span')
:addClass(class)
:addClass('template-page-tabs-tab')
:addClass(selected and 'template-page-tabs-tab--selected' or nil)
:css('background-color', thisPage and (args['tab-bg'] or 'white') or (args['tab1-bg'] or '#e0edf6'))
:css('color', 'black')
:css('background-color', tabColor)
:cssText(thisPage and 'border-bottom:0;font-weight:bold' or 'font-size:95%')
:cssText(css)
:wikitext(link)
:wikitext(link)
:done()
:wikitext('<span class="spacer ' .. (class or "") .. '">&#32;</span>')
end
end