From c6a0c3783fcf8aad749dc5b3b2c2c12690dc1a6e Mon Sep 17 00:00:00 2001 From: hjpalpha Date: Mon, 18 May 2026 12:16:00 +0200 Subject: [PATCH 1/3] feat(Roles): add option for icon data in role datas --- lua/wikis/commons/Role/Util.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lua/wikis/commons/Role/Util.lua b/lua/wikis/commons/Role/Util.lua index 7cbafd93112..3866c1ff72d 100644 --- a/lua/wikis/commons/Role/Util.lua +++ b/lua/wikis/commons/Role/Util.lua @@ -12,6 +12,8 @@ local String = Lua.import('Module:StringUtils') local Roles = Lua.import('Module:Roles') +local IconFa = Lua.import('Module:Widget/Image/Icon/Fontawesome') + --- TODO: In the future this should be moved to role data entry local POSITION_ICON_DATA = Lua.requireIfExists('Module:PositionIcon/data', {loadData = true}) @@ -21,11 +23,13 @@ local RoleUtil = {} ---@field display string ---@field category string ---@field sortOrder integer? +---@field iconFa string? +---@field icon string? ---@class RoleData: RoleBaseData ---@field key string? ---@field type RoleTypes ----@field icon string? +---@field icon VNode|string? ---@enum RoleTypes RoleUtil.ROLE_TYPE = { @@ -86,7 +90,10 @@ function RoleUtil._createRoleData(roleKey) key = key, type = roleType(), sortOrder = roleData.sortOrder, - icon = POSITION_ICON_DATA and POSITION_ICON_DATA[key] or nil, + icon = roleData.iconFa and IconFa{iconName = roleData.iconFa, hover = roleData.display} + or roleData.icon + or POSITION_ICON_DATA and POSITION_ICON_DATA[key] + or nil, } end From a589926174d8071672567e0dbcbbf272168b21cd Mon Sep 17 00:00:00 2001 From: hjpalpha Date: Mon, 18 May 2026 16:46:03 +0200 Subject: [PATCH 2/3] as per review --- lua/wikis/commons/Role/Util.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/wikis/commons/Role/Util.lua b/lua/wikis/commons/Role/Util.lua index 3866c1ff72d..02d0efd7081 100644 --- a/lua/wikis/commons/Role/Util.lua +++ b/lua/wikis/commons/Role/Util.lua @@ -29,7 +29,7 @@ local RoleUtil = {} ---@class RoleData: RoleBaseData ---@field key string? ---@field type RoleTypes ----@field icon VNode|string? +---@field icon Renderable? ---@enum RoleTypes RoleUtil.ROLE_TYPE = { From 59f15ec202999123312510b115445599c604bb69 Mon Sep 17 00:00:00 2001 From: hjpalpha Date: Mon, 18 May 2026 16:53:25 +0200 Subject: [PATCH 3/3] use icon widget instead of plain string --- lua/wikis/commons/Role/Util.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lua/wikis/commons/Role/Util.lua b/lua/wikis/commons/Role/Util.lua index 02d0efd7081..c172dc2b272 100644 --- a/lua/wikis/commons/Role/Util.lua +++ b/lua/wikis/commons/Role/Util.lua @@ -13,6 +13,7 @@ local String = Lua.import('Module:StringUtils') local Roles = Lua.import('Module:Roles') local IconFa = Lua.import('Module:Widget/Image/Icon/Fontawesome') +local Icon = Lua.import('Module:Widget/Image/Icon/Image') --- TODO: In the future this should be moved to role data entry local POSITION_ICON_DATA = Lua.requireIfExists('Module:PositionIcon/data', {loadData = true}) @@ -25,6 +26,7 @@ local RoleUtil = {} ---@field sortOrder integer? ---@field iconFa string? ---@field icon string? +---@field iconDark string? ---@class RoleData: RoleBaseData ---@field key string? @@ -91,7 +93,12 @@ function RoleUtil._createRoleData(roleKey) type = roleType(), sortOrder = roleData.sortOrder, icon = roleData.iconFa and IconFa{iconName = roleData.iconFa, hover = roleData.display} - or roleData.icon + or roleData.icon and Icon{ + imageLight = roleData.icon, + imageDark = roleData.iconDark, + size = '16px', + alt = roleData.display, + } or POSITION_ICON_DATA and POSITION_ICON_DATA[key] or nil, }