Module:Mainpage/Progress: Difference between revisions
From Paracosm
More actions
mNo edit summary |
|||
| Line 2: | Line 2: | ||
local cfg = require('Module:Mainpage/Config') | local cfg = require('Module:Mainpage/Config') | ||
local badge = require('Module:BadgeLua') | |||
local p = {} | local p = {} | ||
| Line 24: | Line 26: | ||
:addClass('home-pad') | :addClass('home-pad') | ||
:addClass('home-progress__inner') | :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') | pad:tag('div') | ||
Revision as of 16:37, 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 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')
return tostring(card)
end
return p