Module:ItemGrid: Difference between revisions
From ARC Raiders Wiki
More actions
Content deleted Content added
added gradient background for items background by rarity |
m formatting |
||
| (6 intermediate revisions by 2 users not shown) | |||
| Line 11: | Line 11: | ||
local rarityGradientBkg = { |
local rarityGradientBkg = { |
||
Common = "linear-gradient(to right, rgb(153 159 165 / |
Common = "linear-gradient(to right, rgb(153 159 165 / 10%) 0%, rgb(5 13 36) 100%)", |
||
Uncommon = "linear-gradient(to right, rgb(86 203 134 / 20%) 0%, rgb(5 13 36) 100%) |
Uncommon = "linear-gradient(to right, rgb(86 203 134 / 20%) 0%, rgb(5 13 36) 100%)", |
||
Rare = "linear-gradient(to right, rgb(30 150 252 / 20%) 0%, rgb(5 13 36) 100%) |
Rare = "linear-gradient(to right, rgb(30 150 252 / 20%) 0%, rgb(5 13 36) 100%)", |
||
Epic = "linear-gradient(to right, rgb(216 41 155 / 20%) 0%, rgb(5 13 36) 100%) |
Epic = "linear-gradient(to right, rgb(216 41 155 / 20%) 0%, rgb(5 13 36) 100%)", |
||
Legendary = "linear-gradient(to right, rgb(251 199 0 / 20%) 0%, rgb(5 13 36) 100%) |
Legendary = "linear-gradient(to right, rgb(251 199 0 / 20%) 0%, rgb(5 13 36) 100%)" |
||
} |
} |
||
| Line 25: | Line 25: | ||
while args["image" .. i] and i < 100 do |
while args["image" .. i] and i < 100 do |
||
local isLimited = args["isLimited" .. i] or false |
local isLimited = args["isLimited" .. i] or false |
||
local rarity = args["rarity" .. i] or "" |
local rarity = args["rarity" .. i] or "Common" |
||
local border = rarityColors[rarity] or rarityColors["Common"] |
local border = rarityColors[rarity] or rarityColors["Common"] |
||
| Line 31: | Line 31: | ||
:addClass("item-cell") |
:addClass("item-cell") |
||
:css("border", "1px solid " .. border) |
:css("border", "1px solid " .. border) |
||
:css("background", "" .. rarityGradientBkg[ |
:css("background", "" .. rarityGradientBkg[rarity]) |
||
if (isLimited == ("true" or "True")) then |
if (isLimited == ("true" or "True")) then |
||
item:tag("div") |
item:tag("div") |
||
:addClass(" |
:addClass("icon_timereset") |
||
:wikitext("[[File:Icon_TimeReset.png|16px]]") |
:wikitext("[[File:Icon_TimeReset.png|16px]]") |
||
:css("position", "absolute") |
|||
:css("left", "calc(100% - 20px)") |
|||
:css("top", "0%") |
|||
end |
end |
||
Latest revision as of 11:13, 10 November 2025
Documentation for this module may be created at Module:ItemGrid/doc
local p = {}
-- Rarity border colors
local rarityColors = {
Common = "#717471cc",
Uncommon = "#41eb6acc",
Rare = "#1ecbfccc",
Epic = "#d8299bcc",
Legendary = "#fbc700cc"
}
local rarityGradientBkg = {
Common = "linear-gradient(to right, rgb(153 159 165 / 10%) 0%, rgb(5 13 36) 100%)",
Uncommon = "linear-gradient(to right, rgb(86 203 134 / 20%) 0%, rgb(5 13 36) 100%)",
Rare = "linear-gradient(to right, rgb(30 150 252 / 20%) 0%, rgb(5 13 36) 100%)",
Epic = "linear-gradient(to right, rgb(216 41 155 / 20%) 0%, rgb(5 13 36) 100%)",
Legendary = "linear-gradient(to right, rgb(251 199 0 / 20%) 0%, rgb(5 13 36) 100%)"
}
function p.render(frame)
local args = frame:getParent().args
local html = mw.html.create("div"):addClass("item-grid")
local i = 1
while args["image" .. i] and i < 100 do
local isLimited = args["isLimited" .. i] or false
local rarity = args["rarity" .. i] or "Common"
local border = rarityColors[rarity] or rarityColors["Common"]
local item = html:tag("div")
:addClass("item-cell")
:css("border", "1px solid " .. border)
:css("background", "" .. rarityGradientBkg[rarity])
if (isLimited == ("true" or "True")) then
item:tag("div")
:addClass("icon_timereset")
:wikitext("[[File:Icon_TimeReset.png|16px]]")
end
if rarity ~= "" then --reformat this repetitive block if you can
item:tag("div")
:addClass("item-image")
:wikitext(string.format("%s", args["image" .. i]))
:tag("div")
:addClass(string.format("curve-%s", rarity))
:done()
else
item:tag("div")
:addClass("item-image")
:wikitext(string.format("%s", args["image" .. i]))
end
item:tag("div")
:addClass("item-name")
:wikitext(args["name" .. i] or "")
item:tag("div")
:addClass("data-table")
:tag("div")
:addClass("category-icon")
:wikitext(args["category-icon" .. i] or "")
:done()
:tag("div")
:addClass("item-price")
:wikitext(args["price" .. i] or "")
:done()
i = i + 1
end
return tostring(html)
end
return p