Skip to content

Commit

Permalink
refactor(widget): children rework - party 7&8 for breakdown widget
Browse files Browse the repository at this point in the history
  • Loading branch information
Rathoz committed Sep 17, 2024
1 parent cbebb22 commit 48d655b
Show file tree
Hide file tree
Showing 20 changed files with 24 additions and 25 deletions.
4 changes: 2 additions & 2 deletions components/infobox/commons/infobox_campaign_mission.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ function Mission:createInfobox()
Center{content = {args.caption}},
Title{name = 'Mission Information'},
Breakdown{
content = {'Mission Objective'},
children = {'Mission Objective'},
classes = {'infobox-header', 'wiki-backgroundcolor-light', 'infobox-header-3'}
},
Breakdown{content = { args.objective }},
Breakdown{children = { args.objective }},
Customizable{id = 'custom', children = {}},
Center{content = {args.footnotes}},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function UnofficialWorldChampion:createInfobox()
builder = function()
return Array.map(
self:getAllArgsForBase(args, 'most defences against '),
function (value) return Breakdown{content = {value}} end
function (value) return Breakdown{children = {value}} end
)
end
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function CustomBuildingUnit.attackDisplay(args)
if Array.all(data, Logic.isEmpty) then
return nil
end
return BreakDown{contentClasses = {content1 = {'infobox-description'}}, content = {desc, unpack(data)}}
return BreakDown{contentClasses = {content1 = {'infobox-description'}}, children = {desc, unpack(data)}}
end

return Array.append({Title{name = 'Combat'}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function CustomInjector:parse(id, widgets)
toBreakDownCell('secondaryrole', 'Secondary Role', 'ClassIcon')
)
return {
Breakdown{classes = {'infobox-center'}, content = breakDownContents},
Breakdown{classes = {'infobox-center'}, children = breakDownContents},
Cell{name = 'Real Name', content = {args.realname}},
}
elseif id == 'cost' then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function CustomInjector:parse(id, widgets)
if id == 'header' then
if String.isNotEmpty(args.itemcost) then
table.insert(widgets, Breakdown{
content = caller:_getCostDisplay(),
children = caller:_getCostDisplay(),
classes = {
'infobox-header',
'wiki-backgroundcolor-light',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function CustomInjector:parse(id, widgets)
toBreakDownCell('secondaryrole', 'Secondary Role')
)
return {
Breakdown{classes = {'infobox-center'}, content = breakDownContents},
Breakdown{classes = {'infobox-center'}, children = breakDownContents},
}
elseif id == 'cost' then
local cost = Array.append({},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function CustomInjector:parse(id, widgets)
for regionKey, region in Table.iter.pairsByPrefix(args, 'region') do
Array.appendWith(widgets,
Cell{name = (args[regionKey .. ' no'] or '') .. ' champions', content = {region}},
Breakdown{content = {args[regionKey .. ' champions']}}
Breakdown{children = {args[regionKey .. ' champions']}}
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion components/infobox/wikis/smite/infobox_unit_god_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function CustomInjector:parse(id, widgets)
toBreakDownCell('powertype', 'Power Type', 'PowerTypeIcon')
)
return {
Breakdown{classes = {'infobox-center'}, content = breakDownContents},
Breakdown{classes = {'infobox-center'}, children = breakDownContents},
Cell{name = 'Real Name', content = {args.realname}},
}
elseif id == 'cost' then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function CustomInjector:parse(id, widgets)
Title{name = 'Participants'},
Cell{name = 'Number of Players', content = {self.caller.data.raceBreakDown.total}},
Cell{name = 'Number of Teams', content = {args.team_number}},
Breakdown{content = self.caller.data.raceBreakDown.display or {}, classes = { 'infobox-center' }}
Breakdown{children = self.caller.data.raceBreakDown.display or {}, classes = { 'infobox-center' }}
)
end

Expand Down
2 changes: 1 addition & 1 deletion components/infobox/wikis/starcraft/infobox_team_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function CustomInjector:parse(id, widgets)
Array.appendWith(widgets,
Title{name = 'Player Breakdown'},
Cell{name = 'Number of Players', content = {raceBreakdown.total}},
Breakdown{content = raceBreakdown.display, classes = { 'infobox-center' }}
Breakdown{children = raceBreakdown.display, classes = { 'infobox-center' }}
)
end
elseif id == 'history' then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ function CustomInjector:parse(id, widgets)
Title{name = 'Participants'},
Cell{name = 'Number of Players', content = {args.raceBreakDown.total}},
Cell{name = 'Number of Teams', content = {args.team_number}},
Breakdown{content = args.raceBreakDown.display or {}, classes = { 'infobox-center' }}
Breakdown{children = args.raceBreakDown.display or {}, classes = { 'infobox-center' }}
)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function CustomInjector:parse(id, widgets)
Array.appendWith(widgets,
Title{name = 'Player Breakdown'},
Cell{name = 'Number of Players', content = {raceBreakdown.total}},
Breakdown{content = raceBreakdown.display, classes = {'infobox-center'}}
Breakdown{children = raceBreakdown.display, classes = {'infobox-center'}}
)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function CustomInjector:parse(id, widgets)
Array.extendWith(widgets,
{
raceBreakdown and Title{name = 'Racial Distribution of Champions'} or nil,
raceBreakdown and Breakdown{content = raceBreakdown.display, classes = { 'infobox-center' }} or nil,
raceBreakdown and Breakdown{children = raceBreakdown.display, classes = { 'infobox-center' }} or nil,
},
self.caller:_buildCellsFromBase('countries with multiple champions', 'Countries with Multiple Champions'),
self.caller:_buildCellsFromBase('teams with multiple champions', 'Teams with Multiple Champions')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function CustomInjector:parse(id, widgets)
Array.appendWith(widgets,
Title{name = 'Player Breakdown'},
Cell{name = 'Number of Players', content = {args.raceBreakDown.total}},
Breakdown{content = args.raceBreakDown.display, classes = { 'infobox-center' }}
Breakdown{children = args.raceBreakDown.display, classes = { 'infobox-center' }}
)
end

Expand Down
2 changes: 1 addition & 1 deletion components/infobox/wikis/stormgate/infobox_team_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function CustomInjector:parse(id, widgets)
Array.appendWith(widgets,
Title{name = 'Player Breakdown'},
Cell{name = 'Number of Players', content = {raceBreakdown.total}},
Breakdown{content = raceBreakdown.display, classes = { 'infobox-center' }}
Breakdown{children = raceBreakdown.display, classes = { 'infobox-center' }}
)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ function CustomInjector:parse(id, widgets)
if id == 'custom' then
return Array.append(widgets,
Title{name = 'Attributes'},
BreakDown{content = {
BreakDown{children = {
self.caller:_basicAttribute('str'),
self.caller:_basicAttribute('agi'),
self.caller:_basicAttribute('int'),
}, classes = {'infobox-center'}},
BreakDown{content = {
BreakDown{children = {
self.caller:_getDamageAttribute(),
self.caller:_getArmorAttribute(),
self.caller:_getPrimaryAttribute(),
Expand All @@ -97,7 +97,7 @@ function CustomInjector:parse(id, widgets)
args.icon and Title{name = 'Icon'} or nil,
Center{content = {self.caller:_displayIcon()}},
Title{name = 'Level Changes'},
BreakDown{content = {'[[Experience|Level]]:', 1, 5, 10}, contentClasses = LEVEL_CHANGE_CLASSES},
BreakDown{children = {'[[Experience|Level]]:', 1, 5, 10}, contentClasses = LEVEL_CHANGE_CLASSES},
BreakDown(CustomCharacter._toLevelChangesRow(
function(gainFactor) return self.caller:_calculateHitPoints(gainFactor) end, '[[Hit Points]]:')),
BreakDown(CustomCharacter._toLevelChangesRow(function(gainFactor)
Expand Down Expand Up @@ -345,7 +345,7 @@ end
---@param title string
---@return {content: table, contentClasses: table}}
function CustomCharacter._toLevelChangesRow(funct, title)
return {content = {title, funct(0), funct(4), funct(9)}, contentClasses = LEVEL_CHANGE_CLASSES}
return {children = {title, funct(0), funct(4), funct(9)}, contentClasses = LEVEL_CHANGE_CLASSES}
end

return CustomCharacter
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ function CustomInjector:parse(id, widgets)
if playerNumber then
Array.appendWith(widgets,
Cell{name = 'Number of Players', content = {playerNumber}},
Breakdown{content = caller.data.raceBreakDown.display or {}, classes = { 'infobox-center' }}
Breakdown{children = caller.data.raceBreakDown.display or {}, classes = { 'infobox-center' }}
)
end

Expand Down
4 changes: 2 additions & 2 deletions components/infobox/wikis/wildrift/infobox_item_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function CustomInjector:parse(id, widgets)
if id == 'header' then
if String.isNotEmpty(args.itemcost) then
table.insert(widgets, Breakdown{
content = caller:_getCostDisplay(),
children = caller:_getCostDisplay(),
classes = {
'infobox-header',
'wiki-backgroundcolor-light',
Expand All @@ -78,7 +78,7 @@ function CustomInjector:parse(id, widgets)
if not CustomItem._hasAttributes(args) then return {} end

if not (String.isEmpty(args.str) and String.isEmpty(args.agi) and String.isEmpty(args.int)) then
table.insert(widgets, Breakdown{classes = {'infobox-center'}, content = {
table.insert(widgets, Breakdown{classes = {'infobox-center'}, children = {
caller:_attributeIcons('str'),
caller:_attributeIcons('agi'),
caller:_attributeIcons('int'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function CustomInjector:parse(id, widgets)
toBreakDownCell('secondaryrole', 'Secondary Role', 'ClassIcon')
)
return {
Breakdown{classes = {'infobox-center'}, content = breakDownContents},
Breakdown{classes = {'infobox-center'}, children = breakDownContents},
Cell{name = 'Real Name', content = {args.realname}},
}
elseif id == 'cost' then
Expand Down
1 change: 0 additions & 1 deletion components/widget/widget_breakdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ local Widget = Lua.import('Module:Widget')
local Breakdown = Class.new(
Widget,
function(self, input)
self.children = input.children or input.content
self.classes = input.classes
self.contentClasses = input.contentClasses or {}
end
Expand Down

0 comments on commit 48d655b

Please sign in to comment.