added progress image
This commit is contained in:
45
src/main.typ
45
src/main.typ
@ -55,41 +55,7 @@
|
||||
|
||||
#v(1fr)
|
||||
|
||||
#context {
|
||||
let stars = star-state.final()
|
||||
let star-cnt = stars.values().sum(default: 0)
|
||||
let first-weekday = datetime(
|
||||
year: 2024,
|
||||
month: 12,
|
||||
day: 1
|
||||
).weekday()
|
||||
let cells = ([],) * (first-weekday - 1)
|
||||
|
||||
for i in range(1, 26) {
|
||||
let cell = [#i]
|
||||
if str(i) in stars.keys() {
|
||||
cell = stack(
|
||||
dir: ttb,
|
||||
spacing: 0.2em,
|
||||
cell,
|
||||
h(3pt) + ((emoji.star,)* stars.at(str(i))).join()
|
||||
)
|
||||
cell = link(label("day-" + str(i)), cell)
|
||||
}
|
||||
|
||||
cells.push(cell)
|
||||
}
|
||||
|
||||
[*Stars: #star-cnt / 50*]
|
||||
table(
|
||||
columns: (1fr,)*7,
|
||||
inset: 0.8em,
|
||||
align: center + horizon,
|
||||
fill: (_, y) => if y > 0 and calc.rem(y, 2) == 0 {gray.lighten(70%)},
|
||||
table.header([*Mon*], [*Tue*], [*Wed*], [*Thu*], [*Fri*], [*Sat*], [*Sun*]),
|
||||
..cells
|
||||
)
|
||||
}
|
||||
#make-progress()
|
||||
|
||||
#pagebreak()
|
||||
|
||||
@ -105,4 +71,11 @@
|
||||
)
|
||||
)
|
||||
|
||||
#make-day(1, stars: 1)
|
||||
#let progress = yaml("/progress.yaml")
|
||||
|
||||
#for i in range(1, 26) {
|
||||
if str(i) in progress.keys() {
|
||||
let day = progress.at(str(i))
|
||||
make-day(i, stars: day.stars)
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
#let star-cnt = counter("stars")
|
||||
#let star-state = state("stars", (:))
|
||||
|
||||
#let get-input-path(day) = {
|
||||
@ -73,7 +72,6 @@
|
||||
|
||||
#let make-day(day, stars: 0) = {
|
||||
star-state.update(s => s + (str(day): stars))
|
||||
star-cnt.update(v => v + stars)
|
||||
day-template(
|
||||
stars: stars,
|
||||
day,
|
||||
@ -82,6 +80,44 @@
|
||||
)
|
||||
}
|
||||
|
||||
#let make-progress(links: true) = context {
|
||||
let stars = star-state.final()
|
||||
let star-cnt = stars.values().sum(default: 0)
|
||||
let first-weekday = datetime(
|
||||
year: 2024,
|
||||
month: 12,
|
||||
day: 1
|
||||
).weekday()
|
||||
let cells = ([],) * (first-weekday - 1)
|
||||
|
||||
for i in range(1, 26) {
|
||||
let cell = [#i]
|
||||
if str(i) in stars.keys() {
|
||||
cell = stack(
|
||||
dir: ttb,
|
||||
spacing: 0.2em,
|
||||
cell,
|
||||
h(3pt) + ((emoji.star,)* stars.at(str(i))).join()
|
||||
)
|
||||
if links {
|
||||
cell = link(label("day-" + str(i)), cell)
|
||||
}
|
||||
}
|
||||
|
||||
cells.push(cell)
|
||||
}
|
||||
|
||||
[*Stars: #star-cnt / 50*]
|
||||
table(
|
||||
columns: (1fr,)*7,
|
||||
inset: 0.8em,
|
||||
align: center + horizon,
|
||||
fill: (_, y) => if y > 0 and calc.rem(y, 2) == 0 {gray.lighten(70%)},
|
||||
table.header([*Mon*], [*Tue*], [*Wed*], [*Thu*], [*Fri*], [*Sat*], [*Sun*]),
|
||||
..cells
|
||||
)
|
||||
}
|
||||
|
||||
#let template(body) = {
|
||||
set text(font: "Source Sans 3")
|
||||
body
|
||||
|
Reference in New Issue
Block a user