Module:GameInfo: Difference between revisions
From SpiritVale Wiki
More actions
No edit summary Tags: Mobile edit Mobile web edit |
No edit summary Tags: Mobile edit Mobile web edit |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
-- Sitewide color/system ownership now lives in Common.css + Citizen.css. | |||
-- This module still loads its scoped TemplateStyles entrypoint, but that | |||
-- stylesheet should defer to shared sitewide tokens/components whenever possible. | |||
local DEFAULT_STYLE_SRC = "Module:GameInfo/styles.css" | local DEFAULT_STYLE_SRC = "Module:GameInfo/styles.css" | ||
| Line 26: | Line 29: | ||
and type(x.tag) == "function" | and type(x.tag) == "function" | ||
and type(x.wikitext) == "function" | and type(x.wikitext) == "function" | ||
end | |||
local function _append_content(node, value) | |||
if value == nil then return end | |||
if _is_html_node(value) then | |||
node:node(value) | |||
else | |||
node:wikitext(tostring(value)) | |||
end | |||
end | end | ||
| Line 31: | Line 43: | ||
return tostring( | return tostring( | ||
mw.html.create("div") | mw.html.create("div") | ||
:addClass("sv-card") | |||
:addClass("sv-gi-error") | :addClass("sv-gi-error") | ||
:wikitext(tostring(msg)) | :wikitext(tostring(msg)) | ||
| Line 77: | Line 90: | ||
local root = mw.html.create("div") | local root = mw.html.create("div") | ||
:addClass("sv-card") | |||
:addClass("sv-gi-card") | :addClass("sv-gi-card") | ||
:attr("data-gi", "1") | :attr("data-gi", "1") | ||
:attr("data-sv-card", "1") | |||
:attr("data-gi-phase", "4.1") | :attr("data-gi-phase", "4.1") | ||
:attr("data-level", tostring(level)) | :attr("data-level", tostring(level)) | ||
| Line 89: | Line 104: | ||
if opts.variant and tostring(opts.variant) ~= "" then | if opts.variant and tostring(opts.variant) ~= "" then | ||
root:addClass("sv-gi--" .. tostring(opts.variant)) | root:addClass("sv-gi--" .. tostring(opts.variant)) | ||
root:attr("data-sv-card-variant", tostring(opts.variant)) | |||
end | end | ||
local top = root:tag("div"):addClass("sv-gi-top") | local top = root:tag("div"):addClass("sv-gi-top") | ||
local bottom = root:tag("div"):addClass("sv-gi-bottom") | local bottom = root:tag("div") | ||
:addClass("sv-gi-bottom") | |||
:attr("data-sv-level-scope", "1") | |||
return { root = root, top = top, bottom = bottom } | return { root = root, top = top, bottom = bottom } | ||
| Line 101: | Line 119: | ||
function p.render_box(opts) | function p.render_box(opts) | ||
local box = p.box(opts) | local box = p.box(opts) | ||
if opts | if opts then | ||
_append_content(box.top, opts.top) | |||
_append_content(box.bottom, opts.bottom) | |||
end | end | ||
return tostring(box.root) | return tostring(box.root) | ||
| Line 176: | Line 192: | ||
max_level = max_level, | max_level = max_level, | ||
variant = variant, | variant = variant, | ||
top = | top = top, | ||
bottom = | bottom = bottom, | ||
}) | }) | ||
end | end | ||
return p | return p | ||