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

Module:LinkGrid: Difference between revisions

From Jules RNG Wiki
Created page with "local p = {} function p.render(frame) -- 1. DEFINE YOUR DATA HERE -- Just add new cards to this list. No HTML needed. local cards = { { link = "Auras", title = "Auras", image = "AurasIcon.png", body = "Over 500+ unique auras to collect! Ranging from event auras, to biome exclusive auras. There's tons of auras to discover!" }, { link = "Items", title = "Items",..."
 
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 2: Line 2:


function p.render(frame)
function p.render(frame)
     -- 1. DEFINE YOUR DATA HERE
     local args = frame:getParent().args
     -- Just add new cards to this list. No HTML needed.
     local cards = {}
     local cards = {
     local i = 1
        {
 
            link = "Auras",
    -- Loop to gather data
            title = "Auras",
    while args['title' .. i] do
            image = "AurasIcon.png",
         table.insert(cards, {
            body = "Over 500+ unique auras to collect! Ranging from event auras, to biome exclusive auras. There's tons of auras to discover!"
             link = args['link' .. i] or args['title' .. i],
         },
             title = args['title' .. i],
        {
             image = args['image' .. i] or 'Default.png',
             link = "Items",
             body = args['body' .. i] or ''
            title = "Items",
         })
            image = "ItemsIcon.png",
         i = i + 1
            body = "Increase your luck, roll speed, Gem multiplier, and more with potions, biome randomizers, night bells, and much much more."
     end
        },
        {
             link = "Minigames",
            title = "Minigames",
             image = "MinigamesIcon.png",
            body = "Grind for Potions and Gems in interactive games."
        },
        {
            link = "Achievements",
            title = "Achievements",
            image = "AchievementsIcon.png",
             body = "Complete Achievements to earn gems! Show off your dedication by finishing them all!"
        },
        {
            link = "Biomes",
            title = "Biomes",
            image = "BiomesIcon.png",
            body = "Discover rare and unique biomes! Collect exclusive Biome Specific Auras!"
         },
         {
            link = "Events",
            title = "Events",
            image = "EventsIcon.png",
            body = "Show your holiday spirit by collecting limited-themed auras! Collect them all before they're gone!"
        }
     }


     -- 2. CSS STYLES (Citizen Skin Compatible)
     -- CONTAINER STYLE
     local containerStyle = {
     local containerStyle = {
         ['display'] = 'flex',
         ['display'] = 'flex',
Line 51: Line 25:
     }
     }


    -- CARD STYLE
    -- Note: 'max-width' here is for Desktop. Mobile is handled by Common.css class .jule-grid-card
     local cardStyle = {
     local cardStyle = {
         ['flex'] = '1 1 300px',
         ['flex'] = '1 1 300px',
         ['max-width'] = '32%', -- Falls back to full width on mobile via CSS usually, but this keeps desktop tidy
         ['max-width'] = '30%',  
         ['border'] = '1px solid var(--border-color-base)',
         ['border'] = '1px solid var(--border-color-base)',
         ['border-radius'] = 'var(--border-radius-base, 12px)',
         ['border-radius'] = 'var(--border-radius-base, 12px)',
Line 63: Line 39:
     }
     }


    local imageAreaStyle = {
        ['background'] = 'var(--color-surface-2)',
        ['padding'] = '20px',
        ['text-align'] = 'center',
        ['border-bottom'] = '1px solid var(--border-color-base)'
    }
    local bodyStyle = {
        ['padding'] = '15px'
    }
    local titleStyle = {
        ['font-weight'] = 'bold',
        ['font-size'] = '1.2em',
        ['margin-bottom'] = '8px',
        ['color'] = 'var(--color-base)'
    }
    local textStyle = {
        ['color'] = 'var(--color-subtle)',
        ['font-size'] = '0.95em',
        ['line-height'] = '1.4'
    }
    -- 3. BUILD THE HTML
     local root = mw.html.create('div'):css(containerStyle)
     local root = mw.html.create('div'):css(containerStyle)


     for _, card in ipairs(cards) do
     for _, card in ipairs(cards) do
         local cardDiv = root:tag('div'):css(cardStyle)
         local cardDiv = root:tag('div')
            :addClass('jule-grid-card') -- CRITICAL: Uses Common.css for mobile width
            :css(cardStyle)
          
          
         -- Image Section
         -- Image Area (Icon Style)
         cardDiv:tag('div')
         cardDiv:tag('div')
             :css(imageAreaStyle)
             :css({
                ['background'] = 'var(--color-surface-2)',
                ['padding'] = '20px',
                ['text-align'] = 'center',
                ['border-bottom'] = '1px solid var(--border-color-base)'
            })
             :wikitext(string.format('[[File:%s|80px|link=%s]]', card.image, card.link))
             :wikitext(string.format('[[File:%s|80px|link=%s]]', card.image, card.link))
          
          
         -- Content Section
         -- Content Area
         local bodyDiv = cardDiv:tag('div'):css(bodyStyle)
         local bodyDiv = cardDiv:tag('div'):css({['padding'] = '15px'})
          
          
         -- Title
         -- Title
         bodyDiv:tag('div')
         bodyDiv:tag('div')
             :css(titleStyle)
             :css({
                ['font-weight'] = 'bold',
                ['font-size'] = '1.2em',
                ['margin-bottom'] = '8px',
                ['color'] = 'var(--color-base)'
            })
             :wikitext(string.format('[[%s|%s]]', card.link, card.title))
             :wikitext(string.format('[[%s|%s]]', card.link, card.title))
              
              
         -- Description
         -- Description
         bodyDiv:tag('div')
         bodyDiv:tag('div')
             :css(textStyle)
             :css({
                ['color'] = 'var(--color-subtle)',
                ['font-size'] = '0.95em',
                ['line-height'] = '1.4'
            })
             :wikitext(card.body)
             :wikitext(card.body)
     end
     end


    -- 4. Mobile Responsiveness Hack
     return tostring(root)
    -- This CSS ensures that on small screens, the 'max-width: 32%' is overridden to 100%
    local styles = mw.html.create('style')
    styles:wikitext('@media (max-width: 768px) { .citizen-card-grid > div { max-width: 100% !important; } }')
   
    root:addClass('citizen-card-grid') -- Add class for the media query above
 
     return tostring(styles) .. tostring(root)
end
end


return p
return p

Latest revision as of 19:37, 27 January 2026

Documentation for this module may be created at Module:LinkGrid/doc

local p = {}

function p.render(frame)
    local args = frame:getParent().args
    local cards = {}
    local i = 1

    -- Loop to gather data
    while args['title' .. i] do
        table.insert(cards, {
            link  = args['link' .. i] or args['title' .. i],
            title = args['title' .. i],
            image = args['image' .. i] or 'Default.png',
            body  = args['body' .. i] or ''
        })
        i = i + 1
    end

    -- CONTAINER STYLE
    local containerStyle = {
        ['display'] = 'flex',
        ['flex-wrap'] = 'wrap',
        ['gap'] = '1rem',
        ['justify-content'] = 'center'
    }

    -- CARD STYLE
    -- Note: 'max-width' here is for Desktop. Mobile is handled by Common.css class .jule-grid-card
    local cardStyle = {
        ['flex'] = '1 1 300px',
        ['max-width'] = '30%', 
        ['border'] = '1px solid var(--border-color-base)',
        ['border-radius'] = 'var(--border-radius-base, 12px)',
        ['box-shadow'] = 'var(--box-shadow-level-1)',
        ['overflow'] = 'hidden',
        ['background'] = 'var(--color-surface-1)',
        ['transition'] = 'transform 0.2s ease',
        ['box-sizing'] = 'border-box'
    }

    local root = mw.html.create('div'):css(containerStyle)

    for _, card in ipairs(cards) do
        local cardDiv = root:tag('div')
            :addClass('jule-grid-card') -- CRITICAL: Uses Common.css for mobile width
            :css(cardStyle)
        
        -- Image Area (Icon Style)
        cardDiv:tag('div')
            :css({
                ['background'] = 'var(--color-surface-2)',
                ['padding'] = '20px',
                ['text-align'] = 'center',
                ['border-bottom'] = '1px solid var(--border-color-base)'
            })
            :wikitext(string.format('[[File:%s|80px|link=%s]]', card.image, card.link))
        
        -- Content Area
        local bodyDiv = cardDiv:tag('div'):css({['padding'] = '15px'})
        
        -- Title
        bodyDiv:tag('div')
            :css({
                ['font-weight'] = 'bold',
                ['font-size'] = '1.2em',
                ['margin-bottom'] = '8px',
                ['color'] = 'var(--color-base)'
            })
            :wikitext(string.format('[[%s|%s]]', card.link, card.title))
            
        -- Description
        bodyDiv:tag('div')
            :css({
                ['color'] = 'var(--color-subtle)',
                ['font-size'] = '0.95em',
                ['line-height'] = '1.4'
            })
            :wikitext(card.body)
    end

    return tostring(root)
end

return p