diff --git a/lua/wikis/apexlegends/Infobox/Map/Custom.lua b/lua/wikis/apexlegends/Infobox/Map/Custom.lua index 4b22be38f13..6be5db779a7 100644 --- a/lua/wikis/apexlegends/Infobox/Map/Custom.lua +++ b/lua/wikis/apexlegends/Infobox/Map/Custom.lua @@ -16,11 +16,9 @@ local Injector = Lua.import('Module:Widget/Injector') local Map = Lua.import('Module:Infobox/Map') local Widgets = Lua.import('Module:Widget/All') +local WidgetTable = Lua.import('Module:Widget/Table2/All') local Cell = Widgets.Cell local Title = Widgets.Title -local TableCell = Widgets.TableCell -local TableRow = Widgets.TableRow -local WidgetTable = Widgets.TableOld ---@class ApexMapInfobox: MapInfobox local CustomMap = Class.new(Map) @@ -52,17 +50,19 @@ function CustomInjector:parse(id, widgets) if id == 'custom' then Array.appendWith(widgets, Cell{name = 'Game Mode(s)', children = {args.gamemode}}, - Cell{name = 'Played in ALGS', children = {self.caller:_createSpan(args)}} + Cell{name = 'Played in ALGS', children = {self.caller:_playedInAlgsDisplay(args)}} ) if String.isEmpty(args.ring) then return widgets end - local rows = {self.caller:_createRingTableHeader()} - Array.forEach(self.caller:getAllArgsForBase(args, 'ring'), function(ringData) - table.insert(rows, self.caller:_createRingTableRow(ringData)) - end) + local rows = Array.extend( + {self.caller:_createRingTableHeader()}, + Array.map(self.caller:getAllArgsForBase(args, 'ring'), function(ringData) + return self.caller:_createRingTableRow(ringData) + end) + ) - local ringTable = WidgetTable{ + local ringTable = WidgetTable.Table{ classes = {'fo-nttax-infobox' ,'wiki-bordercolor-light'}, --row alternating bg css = { ['text-align'] = 'center', @@ -83,30 +83,30 @@ function CustomInjector:parse(id, widgets) return widgets end ----@return WidgetTableRow +---@return Renderable function CustomMap:_createRingTableHeader() - return TableRow{css = {['font-weight'] = 'bold'}, children = { - TableCell{children = {'Ring'}}, - TableCell{children = {'Wait (s)'}}, - TableCell{children = {'Close Time (s)'}}, - TableCell{children = {'Damage per tick'}}, - TableCell{children = {'End Diameter (m)'}}, - }} -- bg needed + return WidgetTable.Row{children = { + WidgetTable.CellHeader{children = {'Ring'}}, + WidgetTable.CellHeader{children = {'Wait (s)'}}, + WidgetTable.CellHeader{children = {'Close Time (s)'}}, + WidgetTable.CellHeader{children = {'Damage per tick'}}, + WidgetTable.CellHeader{children = {'End Diameter (m)'}}, + }} end ---@param ringData string ----@return WidgetTableRow +---@return Renderable function CustomMap:_createRingTableRow(ringData) - local cells = {} - for _, item in ipairs(mw.text.split(ringData, ',')) do - table.insert(cells, TableCell{children = {item}}) - end - return TableRow{children = cells} + return WidgetTable.Row{ + children = Array.map(Array.parseCommaSeparatedString(ringData), function(item) + return WidgetTable.Cell{children = {item}} + end) + } end ---@param args table ---@return string -function CustomMap:_createSpan(args) +function CustomMap:_playedInAlgsDisplay(args) local sep = ' - ' local spanEnd = args.spanend if String.isEmpty(args.spanstart) then diff --git a/lua/wikis/commons/Widget/All.lua b/lua/wikis/commons/Widget/All.lua index f936c16b96e..11bbbf17f0a 100644 --- a/lua/wikis/commons/Widget/All.lua +++ b/lua/wikis/commons/Widget/All.lua @@ -28,11 +28,6 @@ Widgets.ShopMerch = Lua.import('Module:Widget/Infobox/ShopMerch') Widgets.Title = Lua.import('Module:Widget/Infobox/Title') Widgets.Venue = Lua.import('Module:Widget/Infobox/Venue') ---- Table Widgets (div-table) (will be removed) -Widgets.TableOld = Lua.import('Module:Widget/Table/Old') -Widgets.TableRow = Lua.import('Module:Widget/Table/Row') -Widgets.TableCell = Lua.import('Module:Widget/Table/Cell') - --- Data Table Widgets (html-table) Widgets.DataTable = Lua.import('Module:Widget/Basic/DataTable') diff --git a/lua/wikis/commons/Widget/Table/Cell.lua b/lua/wikis/commons/Widget/Table/Cell.lua deleted file mode 100644 index 7f35447e358..00000000000 --- a/lua/wikis/commons/Widget/Table/Cell.lua +++ /dev/null @@ -1,48 +0,0 @@ ---- --- @Liquipedia --- page=Module:Widget/Table/Cell --- --- Please see https://github.com/Liquipedia/Lua-Modules to contribute --- - -local Lua = require('Module:Lua') - -local Class = Lua.import('Module:Class') -local Table = Lua.import('Module:Table') - -local Widget = Lua.import('Module:Widget') -local WidgetUtil = Lua.import('Module:Widget/Util') -local HtmlWidgets = Lua.import('Module:Widget/Html/All') - ----@class WidgetCellInput ----@field children (string|number|table|Html)[]? ----@field classes string[]? ----@field css {[string]: string|number}? - ----@class WidgetTableCell:Widget ----@operator call(WidgetCellInput): WidgetTableCell ----@field classes string[] ----@field css {[string]: string|number} ----@field rowSpan integer? ----@field colSpan integer? -local TableCell = Class.new( - Widget, - function(self, input) - self.classes = input.classes or {} - self.css = input.css or {} - end -) - ----@return Widget -function TableCell:render() - local styles = Table.copy(self.css) - styles['grid-row'] = self.rowSpan and 'span ' .. self.rowSpan or nil - styles['grid-column'] = self.colSpan and 'span ' .. self.colSpan or nil - return HtmlWidgets.Div{ - classes = WidgetUtil.collect('csstable-widget-cell', unpack(self.classes)), - css = styles, - children = self.props.children - } -end - -return TableCell diff --git a/lua/wikis/commons/Widget/Table/Old.lua b/lua/wikis/commons/Widget/Table/Old.lua deleted file mode 100644 index e15613d2537..00000000000 --- a/lua/wikis/commons/Widget/Table/Old.lua +++ /dev/null @@ -1,57 +0,0 @@ ---- --- @Liquipedia --- page=Module:Widget/Table/Old --- --- Please see https://github.com/Liquipedia/Lua-Modules to contribute --- - -local Lua = require('Module:Lua') - -local Array = Lua.import('Module:Array') -local Class = Lua.import('Module:Class') -local Table = Lua.import('Module:Table') - -local Widget = Lua.import('Module:Widget') -local WidgetUtil = Lua.import('Module:Widget/Util') -local HtmlWidgets = Lua.import('Module:Widget/Html/All') - ----@class WidgetTableInput ----@field children WidgetTableRow[]? ----@field classes string[]? ----@field css {[string]: string|number|nil}? ----@field columns integer? - ----@class WidgetTableOld:Widget ----@operator call(WidgetTableInput):WidgetTableOld ----@field classes string[] ----@field css {[string]: string|number|nil} ----@field columns integer? -local TableOld = Class.new( - Widget, - function(self, input) - self.classes = input.classes or {} - self.css = input.css or {} - self.columns = input.columns - end -) - ----@return Widget -function TableOld:render() - local styles = Table.copy(self.css) - styles['grid-template-columns'] = 'repeat(' .. (self.columns or self:_getMaxCells()) .. ', auto)' - return HtmlWidgets.Div{ - classes = WidgetUtil.collect('csstable-widget', unpack(self.classes)), - css = styles, - children = self.props.children - } -end - ----@return integer? -function TableOld:_getMaxCells() - local getNumberCells = function(row) - return row:getCellCount() - end - return Array.reduce(Array.map(self.props.children, getNumberCells), math.max) -end - -return TableOld diff --git a/lua/wikis/commons/Widget/Table/Row.lua b/lua/wikis/commons/Widget/Table/Row.lua deleted file mode 100644 index 9060e54412a..00000000000 --- a/lua/wikis/commons/Widget/Table/Row.lua +++ /dev/null @@ -1,47 +0,0 @@ ---- --- @Liquipedia --- page=Module:Widget/Table/Row --- --- Please see https://github.com/Liquipedia/Lua-Modules to contribute --- - -local Lua = require('Module:Lua') - -local Class = Lua.import('Module:Class') - -local Widget = Lua.import('Module:Widget') -local WidgetUtil = Lua.import('Module:Widget/Util') -local HtmlWidgets = Lua.import('Module:Widget/Html/All') - ----@class WidgetTableRowInput ----@field children Widget[]? ----@field classes string[]? ----@field css {[string]: string|number|nil}? - ----@class WidgetTableRow:Widget ----@operator call(WidgetTableRowInput): WidgetTableRow ----@field classes string[] ----@field css {[string]: string|number|nil} -local TableRow = Class.new( - Widget, - function(self, input) - self.classes = input.classes or {} - self.css = input.css or {} - end -) - ----@return integer -function TableRow:getCellCount() - return #self.props.children -end - ----@return Widget -function TableRow:render() - return HtmlWidgets.Div{ - classes = WidgetUtil.collect('csstable-widget-row', unpack(self.classes)), - css = self.css, - children = self.props.children - } -end - -return TableRow diff --git a/stylesheets/commons/Prizepooltable.scss b/stylesheets/commons/Prizepooltable.scss index 7aebf9e98e4..04bd6f312e8 100644 --- a/stylesheets/commons/Prizepooltable.scss +++ b/stylesheets/commons/Prizepooltable.scss @@ -65,19 +65,6 @@ table.prizepooltable.collapsed .prizepooltablehide { background-color: var( --prize-pool-header-background-color, inherit ); } -.csstable-widget.prizepooltable { - border: 0.125rem solid var( --prize-pool-header-background-color ); - - .csstable-widget-row, - .csstable-widget-cell { - border: 0; - } - - .csstable-widget-row:nth-child( odd ):not( .prizepooltable-header ):not( .ppt-toggle-expand ) { - background-color: var( --prize-pool-alt-background-color ); - } -} - /* Background colours */ tr.bg-first, @@ -100,8 +87,7 @@ div.bg-first, tr.bg-p1, div.bg-p1, tr.background-color-first-place, -div.background-color-first-place, -div.csstable-widget-row.background-color-first-place > .csstable-widget-cell { +div.background-color-first-place { border-bottom: 0.125rem solid var( --prize-pool-gold, transparent ); } @@ -135,8 +121,7 @@ div.bg-second, tr.bg-p2, div.bg-p2, tr.background-color-second-place, -div.background-color-second-place, -div.csstable-widget-row.background-color-second-place > .csstable-widget-cell { +div.background-color-second-place { border-bottom: 0.125rem solid var( --prize-pool-silver, transparent ); } @@ -170,8 +155,7 @@ div.bg-third, tr.bg-p3, div.bg-p3, tr.background-color-third-place, -div.background-color-third-place, -div.csstable-widget-row.background-color-third-place > .csstable-widget-cell { +div.background-color-third-place { border-bottom: 0.125rem solid var( --prize-pool-bronze, transparent ); } @@ -205,8 +189,7 @@ div.bg-fourth, tr.bg-p4, div.bg-p4, tr.background-color-fourth-place, -div.background-color-fourth-place, -div.csstable-widget-row.background-color-fourth-place > .csstable-widget-cell { +div.background-color-fourth-place { border-bottom: 0.125rem solid var( --prize-pool-copper, transparent ); } @@ -220,29 +203,10 @@ div.background-color-fourth-place > *.prizepooltable-place { color: #ffffff; } -div.csstable-widget-row.bg-win { - div.prizepooltable > & { - /* need the `!important` due to bg-win ( sadly ) having an important in one of its definitions ... */ - background-color: inherit !important; - } - - > .csstable-widget-cell { - border-bottom: 0.125rem solid var( --clr-forest-background-color, transparent ); - } -} - div.bg-win > *.prizepooltable-place { background-color: var( --clr-forest-background-color, inherit ); } -div.csstable-widget-row.bg-lose { - background-color: inherit; - - > .csstable-widget-cell { - border-bottom: 0.125rem solid var( --clr-cinnabar-background-color, transparent ); - } -} - div.bg-lose > *.prizepooltable-place { background-color: var( --clr-cinnabar-background-color, inherit ); } @@ -285,27 +249,6 @@ Author: Rathoz display: none !important; } -.csstable-widget { - border-right: 1px solid var( --table-border-color, #bbbbbb ); - border-bottom: 1px solid var( --table-border-color, #bbbbbb ); - display: inline-grid; - - &-row:not( .ppt-toggle-expand ) { - display: contents; - } - - &-cell { - border-left: 1px solid var( --table-border-color, #bbbbbb ); - border-top: 1px solid var( --table-border-color, #bbbbbb ); - background: inherit; - padding: 4px; - display: flex; - align-items: center; - justify-content: center; - flex-wrap: wrap; - } -} - .ppt-toggle-expand { grid-column: 1 / -1;