Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(infobox): hero infobox for dota2game #4310

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions components/infobox/commons/infobox_character.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ function Character:createInfobox()
size = args.imagesize,
},
Center{content = {args.caption}},
Title{name = (args.informationType or 'Character') .. ' Information'},
Customizable{
id = 'title',
children = {
Title{name = (args.informationType or 'Character') .. ' Information'}
},
},
Cell{name = 'Real Name', content = {args.realname}},
Customizable{
id = 'country',
Expand Down Expand Up @@ -103,7 +108,7 @@ end
---@param location string?
---@return string
function Character:_createLocation(location)
if location == nil then
if not location then
return ''
end

Expand Down
16 changes: 11 additions & 5 deletions components/infobox/commons/infobox_widget_breakdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,41 @@ local Lua = require('Module:Lua')
local Widget = Lua.import('Module:Infobox/Widget')

---@class BreakdownWidget: Widget
---@operator call({content:(string|number)[],classes:string[],contentClasses:table<integer,string[]>}):BreakdownWidget
---@operator call({content:(string|number)[],classes:string[],contentClasses:table<string,string[]>}):BreakdownWidget
---@field contents (string|number)[]
---@field classes string[]
---@field contentClasses table<integer, string[]> --can have gaps in the outer table
---@field rowClasses string[]
---@field contentClasses table<string, string[]> --can have gaps in the outer table
local Breakdown = Class.new(
Widget,
function(self, input)
self.contents = input.content
self.classes = input.classes
self.rowClasses = input.rowClasses
self.contentClasses = input.contentClasses or {}
end
)

---@param injector WidgetInjector?
---@return {[1]: Html?}
function Breakdown:make(injector)
return {Breakdown:_breakdown(self.contents, self.classes, self.contentClasses)}
return {Breakdown._breakdown(self.contents, self.classes, self.rowClasses, self.contentClasses)}
end

---@param contents (string|number)[]
---@param classes string[]
---@param contentClasses table<integer, string[]> --can have gaps in the outer table
---@param rowClasses string[]
---@param contentClasses table<string, string[]> --can have gaps in the outer table
---@return Html?
function Breakdown:_breakdown(contents, classes, contentClasses)
function Breakdown._breakdown(contents, classes, rowClasses, contentClasses)
if type(contents) ~= 'table' or contents == {} then
return nil
end

local div = mw.html.create('div')
for _, class in pairs(rowClasses or {}) do
div:addClass(class)
end
local number = #contents
for contentIndex, content in ipairs(contents) do
local infoboxCustomCell = mw.html.create('div'):addClass('infobox-cell-' .. number)
Expand Down
2 changes: 1 addition & 1 deletion components/infobox/commons/infobox_widget_title.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function Title:_create(infoDescription)
local header = mw.html.create('div')
header :addClass('infobox-header')
:addClass('wiki-backgroundcolor-light')
:addClass('infobox-header-2')
:addClass('infobox-header-3')
:wikitext(infoDescription)
return mw.html.create('div'):node(header)
end
Expand Down
Loading
Loading