Jump to content
Toggle menu
  • 36 articles
  • 9 files
  • 1 users
  • 375 edits
Paracosm
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Mainpage/Progress: Difference between revisions

From Paracosm
Created page with "function p.render() local card = mw.html.create('div'):addClass('t-card'):addClass('home-card--aside') -- The scroll fade's frame; the attribute names its scroller. See -- Module:Mainpage/cards.css for why the two are different elements. local pad = card:tag('div') :addClass('home-pad') :addClass('home-patch') :addClass('home-scrollfade') :attr('data-gadget-mainpage-scrollfade', '.home-patch__list') pad:tag('div'):addClass('home-kicker'):wikitext('Progre..."
 
mNo edit summary
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
require('strict')
local cfg = require('Module:Mainpage/Config')
local badge = require('Module:BadgeLua')
local buttonLua = require('Module:ButtonLua')
local p = {}
local function statistic(parent, value, label)
    local item = parent:tag('div'):addClass('home-progress__stat')
    item:tag('div')
        :addClass('home-progress__value')
        :wikitext(tostring(value or '—'))
    item:tag('div')
        :addClass('home-progress__label')
        :wikitext(label)
end
function p.render()
function p.render()
local card = mw.html.create('div'):addClass('t-card'):addClass('home-card--aside')
    local progress = cfg.section('progress')
    local card = mw.html.create('div')
-- The scroll fade's frame; the attribute names its scroller. See
        :addClass('t-card')
-- Module:Mainpage/cards.css for why the two are different elements.
        :addClass('home-card--aside')
local pad = card:tag('div')
        :addClass('home-progress')
:addClass('home-pad')
:addClass('home-patch')
:addClass('home-scrollfade')
:attr('data-gadget-mainpage-scrollfade', '.home-patch__list')


    local pad = card:tag('div')
        :addClass('home-pad')
        :addClass('home-progress__inner')


pad:tag('div'):addClass('home-kicker'):wikitext('Progress for ' .. require('Module:Mainpage/Config').section('progress').book)
    local heading = pad:tag('div'):addClass('home-progress__heading')
    heading:tag('div')
return tostring(card)
        :addClass('home-kicker')
        :wikitext('Book Progress')
    heading:tag('span')
        :addClass('home-feat__badge-row')
        :wikitext(badge.render({ text = 'Drafting', class = 'home-feat__badge' }))
 
    pad:tag('div')
        :addClass('home-feat__title')
        :addClass('home-progress__title')
        :wikitext(progress.book or 'Untitled')
 
    local stats = pad:tag('div'):addClass('home-progress__stats')
    statistic(stats, progress.chapter, 'Current chapter')
    statistic(stats, progress.wordCount, 'Words written')
   
    pad:tag('div'):addClass('home-btn--wide'):wikitext(buttonLua.render({
label = "Read",
url = progress.url,
size = 'large',
}))
   
    local frame = mw.getCurrentFrame()
local styles = frame:extensionTag({
name = 'templatestyles',
args = { src = 'Module:Mainpage/Progress/styles.css' },
})
 
    return styles .. tostring(card)
end
end
return p

Latest revision as of 16:48, 11 November 2026

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

require('strict')

local cfg = require('Module:Mainpage/Config')
local badge = require('Module:BadgeLua')
local buttonLua = require('Module:ButtonLua')

local p = {}

local function statistic(parent, value, label)
    local item = parent:tag('div'):addClass('home-progress__stat')
    item:tag('div')
        :addClass('home-progress__value')
        :wikitext(tostring(value or '—'))
    item:tag('div')
        :addClass('home-progress__label')
        :wikitext(label)
end

function p.render()
    local progress = cfg.section('progress')
    local card = mw.html.create('div')
        :addClass('t-card')
        :addClass('home-card--aside')
        :addClass('home-progress')

    local pad = card:tag('div')
        :addClass('home-pad')
        :addClass('home-progress__inner')

    local heading = pad:tag('div'):addClass('home-progress__heading')
    heading:tag('div')
        :addClass('home-kicker')
        :wikitext('Book Progress')
    heading:tag('span')
        :addClass('home-feat__badge-row')
        :wikitext(badge.render({ text = 'Drafting', class = 'home-feat__badge' }))

    pad:tag('div')
        :addClass('home-feat__title')
        :addClass('home-progress__title')
        :wikitext(progress.book or 'Untitled')

    local stats = pad:tag('div'):addClass('home-progress__stats')
    statistic(stats, progress.chapter, 'Current chapter')
    statistic(stats, progress.wordCount, 'Words written')
    
    pad:tag('div'):addClass('home-btn--wide'):wikitext(buttonLua.render({
		label = "Read",
		url = progress.url,
		size = 'large',
	}))
    
    local frame = mw.getCurrentFrame()
	local styles = frame:extensionTag({
		name = 'templatestyles',
		args = { src = 'Module:Mainpage/Progress/styles.css' },
	})

    return styles .. tostring(card)
end

return p
Last modified