Module:Sidebox
From Jules RNG Wiki
More actions
Documentation for this module may be created at Module:Sidebox/doc
local p = {}
function p.render(frame)
local args = frame:getParent().args
-- 1. CONFIGURATION (Default Values)
local robloxGameLink = args['roblox_game'] or 'https://www.roblox.com/games/16883974868/Jules-RNG'
local discordInvite = args['discord_invite'] or 'https://discord.gg/p728XznYPp'
local robloxIcon = args['roblox_icon'] or 'Roblox_Logo.svg.png'
local discordIcon = args['discord_icon'] or 'Discord_Logo.png'
-- 2. STYLES
local boxStyle = {
['float'] = 'right',
['width'] = '300px',
['max-width'] = '100%',
['margin'] = '0 0 1rem 1rem',
['display'] = 'flex',
['flex-direction'] = 'column',
['gap'] = '12px',
['clear'] = 'right',
['box-sizing'] = 'border-box'
}
local cardStyle = {
['background'] = 'var(--color-surface-1)',
['border'] = '1px solid var(--border-color-base)',
['border-radius'] = 'var(--border-radius-base, 8px)',
['box-shadow'] = 'var(--box-shadow-level-1)',
['box-sizing'] = 'border-box'
}
local headerStyle = {
['background'] = 'var(--color-surface-2)',
['padding'] = '12px',
['font-weight'] = 'bold',
['font-size'] = '0.95em',
['border-bottom'] = '1px solid var(--border-color-base)',
['text-transform'] = 'uppercase',
['letter-spacing'] = '0.05em',
['color'] = 'var(--color-subtle)',
['border-radius'] = '8px 8px 0 0'
}
-- 3. BUILD ROOT CONTAINER
local root = mw.html.create('div')
:addClass('citizen-sidebox')
:css(boxStyle)
-- ===========================
-- SECTION 1: JOIN COMMUNITY
-- ===========================
local commCard = root:tag('div'):css(cardStyle)
commCard:tag('div'):css(headerStyle):wikitext('Join the Community')
local commBody = commCard:tag('div')
:addClass('plainlinks')
:css({['padding'] = '12px', ['display'] = 'flex', ['flex-direction'] = 'column', ['gap'] = '8px'})
-- Roblox Button
commBody:tag('div')
:css({['background'] = '#000', ['border-radius'] = '6px', ['padding'] = '10px', ['text-align'] = 'center'})
:wikitext(string.format(
'<span style="vertical-align: middle; margin-right: 8px;">[[File:%s|40px|link=%s]]</span><span style="font-weight: bold; vertical-align: middle;">[%s <span style="color: #fff !important; text-decoration: none;">Play on Roblox</span>]</span>',
robloxIcon, robloxGameLink, robloxGameLink
))
-- Discord Button
commBody:tag('div')
:css({['background'] = '#5865F2', ['border-radius'] = '6px', ['padding'] = '10px', ['text-align'] = 'center'})
:wikitext(string.format(
'<span style="vertical-align: middle; margin-right: 8px;">[[File:%s|40px|link=%s]]</span><span style="font-weight: bold; vertical-align: middle;">[%s <span style="color: #fff !important; text-decoration: none;">Join Discord</span>]</span>',
discordIcon, discordInvite, discordInvite
))
-- ===========================
-- SECTION 2: DEVELOPERS
-- ===========================
-- We loop through dev1, dev2, dev3...
if args['dev1'] then
local devCard = root:tag('div'):css(cardStyle)
devCard:tag('div'):css(headerStyle):wikitext('Developers')
local devBody = devCard:tag('div'):addClass('plainlinks'):css({['padding'] = '8px 12px'})
local i = 1
while args['dev' .. i] do
local name = args['dev' .. i]
local id = args['dev_id' .. i]
local row = devBody:tag('div')
:css({['display'] = 'flex', ['align-items'] = 'center', ['justify-content'] = 'space-between', ['padding'] = '8px 0'})
if args['dev' .. (i+1)] then
row:css('border-bottom', '1px solid var(--border-color-subtle)')
end
local linkHtml = ''
if id then
linkHtml = string.format('<br><span style="font-size: 0.85em; opacity: 0.8;">[https://www.roblox.com/users/%s/profile Roblox Profile →]</span>', id)
end
row:tag('div'):wikitext(string.format('<span style="font-weight: bold;">%s</span>%s', name, linkHtml))
i = i + 1
end
end
-- ===========================
-- SECTION 3: CONTRIBUTORS
-- ===========================
local contribs = args['contributors'] or ''
if contribs ~= '' then
local contribCard = root:tag('div'):css(cardStyle)
contribCard:tag('div'):css(headerStyle):wikitext('Contributors')
contribCard:tag('div')
:css({['padding'] = '12px', ['font-size'] = '0.9em', ['line-height'] = '1.6'})
:wikitext(contribs)
end
return tostring(root)
end
return p