Skip to content
Merged
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
Binary file modified lua/spec/snapshots/match2_matchlist_smoke_apexlegends.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -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'},
Expand Down
58 changes: 14 additions & 44 deletions lua/wikis/commons/Widget/Match/Summary/Ffa/MatchInformation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Comment thread
Rathoz marked this conversation as resolved.
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

Expand All @@ -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?
Expand Down