Module:CRTModel: Difference between revisions
Add embedded styles with night mode support (skin-theme-clientpref-night selector) (via update-page on MediaWiki MCP Server) |
Use frame:extensionTag for style output to avoid HTML escaping (via update-page on MediaWiki MCP Server) |
||
| Line 21: | Line 21: | ||
-- Generate the CSS for night mode support | -- Generate the CSS for night mode support | ||
local function | local function getStylesContent() | ||
return [[ | return [[ | ||
/* CRT Model Infobox - Base Styles (Light Mode) */ | /* CRT Model Infobox - Base Styles (Light Mode) */ | ||
.infobox-crt-model { | .infobox-crt-model { | ||
| Line 139: | Line 139: | ||
} | } | ||
} | } | ||
]] | |||
end | end | ||
| Line 203: | Line 203: | ||
local weight = trim(args.weight) | local weight = trim(args.weight) | ||
local standards_semantic = trim(args.standards_semantic) | local standards_semantic = trim(args.standards_semantic) | ||
-- Use frame:extensionTag to create a proper <style> tag that won't be escaped | |||
local styleTag = frame:extensionTag('templatestyles', '', {src = 'Template:CRT model/styles.css'}) | |||
local container = mw.html.create('div') | local container = mw.html.create('div') | ||
| Line 517: | Line 520: | ||
displayText = docTitle | displayText = docTitle | ||
elseif docType then | elseif docType then | ||
displayText = | displayText = docTitle | ||
end | end | ||
| Line 630: | Line 633: | ||
editDiv:wikitext('[' .. tostring(editUrl) .. ' <span class="infobox-button infobox-button-primary">Edit this data</span>]') | editDiv:wikitext('[' .. tostring(editUrl) .. ' <span class="infobox-button infobox-button-primary">Edit this data</span>]') | ||
-- Return | -- Return templatestyles tag + container HTML | ||
return | return styleTag .. tostring(container) | ||
end | end | ||
return p | return p | ||