From 4bd1dc4afc4e2f2c84c9c1601cdf74ea51fd16e7 Mon Sep 17 00:00:00 2001 From: Rikard Blixt Date: Mon, 23 Mar 2026 13:28:42 +0100 Subject: [PATCH] feat(TeamParticipants): add image/imagedark override for team cards Allow manually setting team logos on participant cards via |image= and |imagedark= parameters, overriding the TeamTemplate-fetched logos. Co-Authored-By: Claude Opus 4.6 (1M context) --- lua/wikis/commons/OpponentDisplay.lua | 9 ++++++++- lua/wikis/commons/TeamParticipants/Parse/Wiki.lua | 5 ++++- lua/wikis/commons/Widget/Participants/Team/Header.lua | 4 ++++ lua/wikis/commons/Widget/TeamDisplay/Block.lua | 6 ++++-- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lua/wikis/commons/OpponentDisplay.lua b/lua/wikis/commons/OpponentDisplay.lua index db48c0a6a0b..b3cb4e7dace 100644 --- a/lua/wikis/commons/OpponentDisplay.lua +++ b/lua/wikis/commons/OpponentDisplay.lua @@ -196,6 +196,8 @@ end ---@field showFaction boolean? ---@field showTbd boolean? ---@field additionalClasses string[]? +---@field image string? +---@field imagedark string? --[[ Displays an opponent as a block element. The width of the component is @@ -221,6 +223,8 @@ function OpponentDisplay.BlockOpponent(props) template = opponent.template or 'tbd', additionalClasses = props.additionalClasses, note = props.note, + image = props.image, + imagedark = props.imagedark, }) elseif opponent.type == Opponent.literal then return OpponentDisplay.BlockLiteral({ @@ -277,7 +281,8 @@ Displays a team as a block element. The width of the component is determined by its layout context, and not of the team name. The team is specified by template. ]] ---@param props {flip: boolean?, overflow: OverflowModes?, showLink: boolean?, ----style: teamStyle?, template: string, additionalClasses: string[]?, note: string|number?} +---style: teamStyle?, template: string, additionalClasses: string[]?, note: string|number?, +---image: string?, imagedark: string?} ---@return Widget function OpponentDisplay.BlockTeamContainer(props) local style = props.style or 'standard' @@ -290,6 +295,8 @@ function OpponentDisplay.BlockTeamContainer(props) noLink = not props.showLink, additionalClasses = props.additionalClasses, note = props.note, + image = props.image, + imagedark = props.imagedark, } end diff --git a/lua/wikis/commons/TeamParticipants/Parse/Wiki.lua b/lua/wikis/commons/TeamParticipants/Parse/Wiki.lua index 9d2d7f94859..e8f8a92dba0 100644 --- a/lua/wikis/commons/TeamParticipants/Parse/Wiki.lua +++ b/lua/wikis/commons/TeamParticipants/Parse/Wiki.lua @@ -21,7 +21,8 @@ local Tournament = Lua.import('Module:Tournament') local TeamParticipantsWikiParser = {} ----@alias TeamParticipant {opponent: standardOpponent, notes: {text: string, highlighted: boolean}[], aliases: string[], +---@alias TeamParticipant {opponent: standardOpponent, image: string?, imagedark: string?, +---notes: {text: string, highlighted: boolean}[], aliases: string[], ---qualification: QualificationStructure?, shouldImportFromDb: boolean, date: integer, ---potentialQualifiers: standardOpponent[]?, warnings: string[]?} @@ -176,6 +177,8 @@ function TeamParticipantsWikiParser.parseParticipant(input, defaultDate) return { opponent = opponent, + image = input.image, + imagedark = input.imagedark, qualification = qualification, aliases = Array.flatMap(aliases, function(alias) return TeamTemplate.queryHistoricalNames(alias) diff --git a/lua/wikis/commons/Widget/Participants/Team/Header.lua b/lua/wikis/commons/Widget/Participants/Team/Header.lua index 15b54ec8350..295b9e01e93 100644 --- a/lua/wikis/commons/Widget/Participants/Team/Header.lua +++ b/lua/wikis/commons/Widget/Participants/Team/Header.lua @@ -61,6 +61,8 @@ function ParticipantsTeamHeader:render() opponent = participant.opponent, teamStyle = 'bracket', additionalClasses = opponentClasses, + image = participant.image, + imagedark = participant.imagedark, } } }, @@ -71,6 +73,8 @@ function ParticipantsTeamHeader:render() opponent = participant.opponent, teamStyle = 'standard', additionalClasses = opponentClasses, + image = participant.image, + imagedark = participant.imagedark, } } } diff --git a/lua/wikis/commons/Widget/TeamDisplay/Block.lua b/lua/wikis/commons/Widget/TeamDisplay/Block.lua index 442ffa44e4f..a7cf58f86c4 100644 --- a/lua/wikis/commons/Widget/TeamDisplay/Block.lua +++ b/lua/wikis/commons/Widget/TeamDisplay/Block.lua @@ -30,6 +30,8 @@ local WidgetUtil = Lua.import('Module:Widget/Util') ---@field style teamStyle ---@field dq boolean? ---@field note string|number? +---@field image string? +---@field imagedark string? ---@class BlockTeamWidget: Widget ---@operator call(BlockTeamParameters): BlockTeamWidget @@ -61,8 +63,8 @@ function BlockTeamWidget:render() end local flip = self.flip - local imageLight = Logic.emptyOr(teamTemplate.image, teamTemplate.legacyimage) - local imageDark = Logic.emptyOr(teamTemplate.imagedark, teamTemplate.legacyimagedark) + local imageLight = Logic.emptyOr(self.props.image, teamTemplate.image, teamTemplate.legacyimage) + local imageDark = Logic.emptyOr(self.props.imagedark, teamTemplate.imagedark, teamTemplate.legacyimagedark) return Div{ classes = Array.extend('block-team', self.props.additionalClasses, flip and 'flipped' or nil),