Module:Infobox costume: Difference between revisions

From Sekaipedia
Content added Content deleted
(created costume infobox)
 
m (add colors)
Line 28: Line 28:
}
}
:setArgs(args)
:setArgs(args)
:setHeaderColors({
['background-color'] = '#00cdba',
['color'] = '#000'
})


infobox
infobox

Revision as of 02:04, 7 September 2021

To generate {{Infobox costume}}, invoke using the main function.


--------------------------
-- Module for [[Template:Infobox Costume]]
------------------------
local getArgs   = require('Module:Arguments').getArgs
local builder   = require('Module:InfoboxBuilder')

local p = {}
local categories = ""

local function formatImage(image_name)
	return string.format("[[File:%s|128px]]", image_name)
end


function p.main(frame)
	local args = getArgs(frame)
	local infobox = builder.new()
	
	infobox:setName('Infobox Costume')
		:setWidth("330px")
		:setParams{
			{ name = 'costume id' },
			{ name = 'costume name', default = mw.title.getCurrentTitle().text },
			{ name = 'image', func = formatImage },
			{ name = 'japanese' },
			{ name = 'romaji' },
			{ name = 'designer' },
		}
		:setArgs(args)
		:setHeaderColors({
			['background-color'] = '#00cdba',
			['color'] = '#000'
		})

	infobox
		:addHeader({ tag = 'argth', content = 'costume name' })
		:addImage({
			{ tag = 'argtd', content = 'image' },
		})
		:addRow({
			{ tag = 'th', content = 'Japanese', colspan = 12 },
			{ tag = 'argtd', content = 'japanese', colspan = 18 }
		})
		:addRow({
			{ tag = 'th', content = 'Romaji', colspan = 12 },
			{ tag = 'argtd', content = 'romaji', colspan = 18 }
		})
		:addHeader({ tag = 'th', content = 'Costume Information' }, { subheader = true })
		:addRow(
			{
				{ tag = 'th', content = 'Designer', colspan = 12 },
				{ tag = 'argtd', content = 'designer', colspan = 18 }
			},
			{ hideIfEmpty = { 'designer' } }
		)
	
	if mw.title.getCurrentTitle().namespace == 0 then
		categories = "[[Category:Costumes]]" .. categories
	end

	return infobox:tostring() .. categories
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.