Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Join the Playtest on Steam Now: SpiritVale

Module:Definitions: Difference between revisions

From SpiritVale Wiki
Created page with "-- Module:Definitions -- Core resolver + renderer for {{def|Domain|Key}} (Definitions v1). -- -- Data source (static): -- Module:Definitions/Definitions.json -- -- JSON shape (dynamic): -- { -- "Schema": 1, -- "UpdatedAt": "YYYY-MM-DD", -- "Stat": { "Vit": { "Name":"...", "Definition":"...", "Icon":"", "Link":"" }, ... }, -- "Target": { ... }, -- ... -- } -- -- Notes: -- - Domains + keys are discovered from JSON (no hardcoded domain lists). -- - CSS namespa..."
 
No edit summary
Line 16: Line 16:
-- Notes:
-- Notes:
-- - Domains + keys are discovered from JSON (no hardcoded domain lists).
-- - Domains + keys are discovered from JSON (no hardcoded domain lists).
-- - CSS namespace: ONLY "sv-def" (plus sv-def--* modifiers). No other CSS prefixes.
-- - CSS namespace: ONLY "sv-def" (plus sv-def--* modifiers).
-- - For TemplateStyles compatibility: use simple classes (sv-def-icon / sv-def-text)
--  instead of attribute selectors.


local p = {}
local p = {}
Line 105: Line 107:
for k, v in pairs(db) do
for k, v in pairs(db) do
if type(v) == "table" and lc(k) == want then
if type(v) == "table" and lc(k) == want then
-- ignore meta containers if any ever appear
if k ~= "Schema" and k ~= "UpdatedAt" then
if k ~= "Schema" and k ~= "UpdatedAt" then
return k
return k
Line 122: Line 123:


-- =============================================================================
-- =============================================================================
-- Icon rendering (missing/file-not-found => "?")
-- Icon rendering
-- - Blank icon: show "i" (generic info icon for v1)
-- - Missing file: show "?" (missing asset)
-- =============================================================================
-- =============================================================================


Line 129: Line 132:


if icon == "" then
if icon == "" then
return '<span data-sv-def-part="icon" aria-hidden="true">?</span>'
return '<span class="sv-def-icon" aria-hidden="true">i</span>'
end
end


Line 139: Line 142:
local t = mw.title.new(fileTitle)
local t = mw.title.new(fileTitle)
if not t or not t.exists then
if not t or not t.exists then
return '<span data-sv-def-part="icon" aria-hidden="true">?</span>'
return '<span class="sv-def-icon" aria-hidden="true">?</span>'
end
end


-- No extra CSS classes; styling should target .sv-def and descendants.
return '<span class="sv-def-icon">[[' .. fileTitle .. '|16px|link=]]</span>'
return '<span data-sv-def-part="icon">[[' .. fileTitle .. '|16px|link=]]</span>'
end
end


Line 193: Line 195:
'<span ' .. table.concat(attrs, " ") .. title_attr .. '>' ..
'<span ' .. table.concat(attrs, " ") .. title_attr .. '>' ..
icon_html(icon) ..
icon_html(icon) ..
'<span data-sv-def-part="text">' .. mw.text.nowiki(name) .. '</span>' ..
'<span class="sv-def-text">' .. mw.text.nowiki(name) .. '</span>' ..
'</span>'
'</span>'


if rec == nil then
if rec == nil then
-- Missing record: visible placeholder hint (still styled as sv-def)
html =
html =
'<span class="sv-def sv-def--missing" data-sv-def-domain="' .. enc_attr(domain) ..
'<span class="sv-def sv-def--missing" data-sv-def-domain="' .. enc_attr(domain) ..