Skip to content
Closed
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
19 changes: 13 additions & 6 deletions lua/wikis/commons/Widget/Infobox/TeamHistory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ local Info = Lua.import('Module:Info', {loadData = true})
local Logic = Lua.import('Module:Logic')
local TeamHistoryAuto = Lua.import('Module:Infobox/Extension/TeamHistory/Auto')

local GeneralCollapsible = Lua.import('Module:Widget/GeneralCollapsible/Default')
local Html = Lua.import('Module:Widget/Html')
local Widget = Lua.import('Module:Widget')
local Widgets = Lua.import('Module:Widget/All')
Expand All @@ -35,21 +36,27 @@ local DEFAULT_MODE = 'manual'
---@field props {player: string, manualInput: string?}
local TeamHistory = Class.new(Widget)

---@return Widget[]
---@return VNode?
function TeamHistory:render()
local teamHistory = self:_getHistory()

if Logic.isEmpty(teamHistory) then
return {}
return
end

return {
Widgets.Title{children = 'History'},
Widgets.Center{children = {teamHistory}},
return GeneralCollapsible{
shouldCollapse = true,
titleWidget = Widgets.Title{
isCollapsibleToggle = true,
children = {
'Team History',
},
},
children = Widgets.Center{children = {teamHistory}},
}
end

---@return Widget|string?
---@return Renderable?
function TeamHistory:_getHistory()
local config = (Info.config.infoboxPlayer or {}).automatedHistory or {}
local manualInput = self.props.manualInput
Expand Down
31 changes: 26 additions & 5 deletions lua/wikis/commons/Widget/Infobox/Title.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,37 @@

local Lua = require('Module:Lua')

local ChevronToggle = Lua.import('Module:Widget/GeneralCollapsible/ChevronToggle')
local Component = Lua.import('Module:Widget/Component')
local Html = Lua.import('Module:Widget/Html')
local WidgetUtil = Lua.import('Module:Widget/Util')

---@param props {children: Renderable|Renderable[]?}
---@class InfoboxTitleProps
---@field isCollapsibleToggle boolean?
---@field children Renderable|Renderable[]?

---@param props InfoboxTitleProps
---@return VNode
local function Title(props)
return Html.Div{children = {Html.Div{
children = props.children,
classes = {'infobox-header', 'wiki-backgroundcolor-light', 'infobox-header-2'}
}}}
if props.isCollapsibleToggle then
return Html.Div{
attributes = {
['data-collapsible-click-region'] = 'true'
},
children = WidgetUtil.collect(
props.children,
ChevronToggle{}
),
classes = {'infobox-header', 'wiki-backgroundcolor-light', 'infobox-header-2'}
}
end

return Html.Div{
children = Html.Div{
children = props.children,
classes = {'infobox-header', 'wiki-backgroundcolor-light', 'infobox-header-2'}
}
}
end

return Component.component(Title)
Loading