diff --git a/lua/spec/snapshots/match2_matchlist_smoke_apexlegends.png b/lua/spec/snapshots/match2_matchlist_smoke_apexlegends.png index 89e1daa1021..cfd22ef5f92 100644 Binary files a/lua/spec/snapshots/match2_matchlist_smoke_apexlegends.png and b/lua/spec/snapshots/match2_matchlist_smoke_apexlegends.png differ diff --git a/lua/wikis/commons/Widget/Match/Summary/Ffa/ContentItemContainer.lua b/lua/wikis/commons/Widget/Match/Summary/Ffa/ContentItemContainer.lua index 31621c57f4c..52f5649fc87 100644 --- a/lua/wikis/commons/Widget/Match/Summary/Ffa/ContentItemContainer.lua +++ b/lua/wikis/commons/Widget/Match/Summary/Ffa/ContentItemContainer.lua @@ -27,8 +27,11 @@ local IconWidget = Lua.import('Module:Widget/Image/Icon/Fontawesome') ---@field items MatchSummaryFfaContentItem[] ---@param props MatchSummaryFfaContentItemContainerProps ----@return VNode +---@return VNode? local function MatchSummaryFfaContentItem(props) + if Logic.isEmpty(props.items) then + return + end local hasContentClass = props.contentClass ~= nil local contentContainer = Html.Div{ classes = {'panel-content__container'}, diff --git a/lua/wikis/commons/Widget/Match/Summary/Ffa/MatchInformation.lua b/lua/wikis/commons/Widget/Match/Summary/Ffa/MatchInformation.lua index 2a0523943a4..6f76093fdfe 100644 --- a/lua/wikis/commons/Widget/Match/Summary/Ffa/MatchInformation.lua +++ b/lua/wikis/commons/Widget/Match/Summary/Ffa/MatchInformation.lua @@ -16,26 +16,26 @@ local Component = Lua.import('Module:Widget/Component') local ContentItemContainer = Lua.import('Module:Widget/Match/Summary/Ffa/ContentItemContainer') local Html = Lua.import('Module:Widget/Html') local IconWidget = Lua.import('Module:Widget/Image/Icon/Fontawesome') -local Link = Lua.import('Module:Widget/Basic/Link') +local MatchSummaryFfaMvp = Lua.import('Module:Widget/Match/Summary/Ffa/Mvp') local WidgetUtil = Lua.import('Module:Widget/Util') local MatchSummaryFfaMatchInformation = {} ---@param props FFAMatchGroupUtilMatch ----@return VNode? +---@return VNode[] function MatchSummaryFfaMatchInformation.render(props) - local items = WidgetUtil.collect( - MatchSummaryFfaMatchInformation._getMvpItem(props.extradata.mvp), - MatchSummaryFfaMatchInformation._getCasterItem(props.extradata.casters), - MatchSummaryFfaMatchInformation._getCommentItem(props.comment) - ) - if #items == 0 then return end - return ContentItemContainer{ - collapsible = #items > 1, - collapsed = #items > 1, - contentClass = 'panel-content__game-schedule', - title = 'Match Information', - items = items + return { + ContentItemContainer{ + collapsible = true, + collapsed = true, + contentClass = 'panel-content__game-schedule', + title = 'Match Information', + items = WidgetUtil.collect( + MatchSummaryFfaMatchInformation._getCasterItem(props.extradata.casters), + MatchSummaryFfaMatchInformation._getCommentItem(props.comment) + ) + }, + MatchSummaryFfaMvp(props.extradata.mvp), } end @@ -50,36 +50,6 @@ function MatchSummaryFfaMatchInformation._getCommentItem(comment) } end ----@private ----@param mvp {players: MatchGroupMvpPlayer[], points: integer?}? ----@return MatchSummaryFfaContentItem? -function MatchSummaryFfaMatchInformation._getMvpItem(mvp) - if Logic.isEmpty(mvp) then - return - end - ---@cast mvp -nil - if Logic.isEmpty(mvp.players) then - return - end - local points = tonumber(mvp.points) - local players = Array.map(mvp.players, function(inputPlayer) - local player = type(inputPlayer) ~= 'table' and {name = inputPlayer, displayname = inputPlayer} or inputPlayer - - return Html.Fragment{children = { - Link{link = player.name, children = player.displayname}, - player.comment and ' (' .. player.comment .. ')' or nil - }} - end) - return { - icon = IconWidget{iconName = 'mvp', color = 'bright-sun-0-text', size = '0.875rem'}, - title = 'MVP:', - content = Html.Span{children = Array.extend( - players, - points and points > 1 and (' (' .. points .. ' pts)') or nil - )} - } -end - ---@private ---@param rawCasters {name:string, displayName: string, flag: string?}[]? ---@return MatchSummaryFfaContentItem?