added progress image
This commit is contained in:
parent
34d2054c21
commit
2f89da16ed
10
README.md
10
README.md
@ -4,12 +4,4 @@ This repo contains my attempt at this year's Advent of Code (2024)
|
||||
|
||||
I will try and do some problems (probably not all of them) using Typst
|
||||
|
||||
## Progress:
|
||||
#### Stars: 0 / 50
|
||||
| Mon | Tue | Wed | Thu | Fri | Sat | Sun |
|
||||
|:------------------:|:-----------------:|:------------------:|:------------------:|:------------------:|:------------------:|:------------------:|
|
||||
| | | | | | | 1<br>:star: |
|
||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|
||||
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
|
||||
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
|
||||
| 23 | 24 | 25 | | | | |
|
||||
![progress](progress.png)
|
BIN
progress.png
Normal file
BIN
progress.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 85 KiB |
13
progress.typ
Normal file
13
progress.typ
Normal file
@ -0,0 +1,13 @@
|
||||
#import "/src/utils.typ": make-progress, template, star-state
|
||||
|
||||
#show: template
|
||||
#set page(height: auto, margin: 1cm)
|
||||
#let progress = yaml("/progress.yaml")
|
||||
#star-state.update(s => {
|
||||
let p = progress
|
||||
for (k, v) in p.pairs() {
|
||||
p.at(k) = v.stars
|
||||
}
|
||||
return p
|
||||
})
|
||||
#make-progress(links: false)
|
2
progress.yaml
Normal file
2
progress.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
1:
|
||||
stars: 1
|
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
|
||||
|
Loading…
Reference in New Issue
Block a user