Skip to content

Commit 3ee2a09

Browse files
committed
✨ Finished most components
1 parent 6daabdc commit 3ee2a09

File tree

5 files changed

+237
-13
lines changed

5 files changed

+237
-13
lines changed

themes/hereford/colors.typ

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
// TODO: these names are terrible, fix them
12
#let dark-red = rgb("#e05c4a")
23
#let light-dark-red = rgb("#f86f5d")
4+
5+
36
#let red = rgb("#e06666")
47
#let light-red = rgb("#ea9999")
58
#let orange = rgb("#f6b26b")
@@ -19,6 +22,9 @@
1922
#let gray = rgb("#999999")
2023
#let light-gray = rgb("#b7b7b7")
2124

25+
#let pro-green = rgb("#a5f1a3")
26+
#let con-red = rgb("#ff9999")
27+
2228
#let surface-0 = rgb("#d9d9d9")
2329
#let surface-1 = rgb("#cccccc")
2430
#let surface-3 = rgb("#eeeeee")
+140-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,140 @@
1-
#let decision-matrix(properties: none, ..choices) = {}
1+
#import "/utils.typ"
2+
#import "../colors.typ": *
3+
4+
#let decision-matrix(
5+
properties: none,
6+
..choices,
7+
) = {
8+
let data = utils.calc-decision-matrix(
9+
properties: properties,
10+
..choices,
11+
)
12+
13+
//repr(data)
14+
15+
let winning-column
16+
for (
17+
index,
18+
result,
19+
) in data.enumerate() {
20+
if result.values.total.highest == true {
21+
winning-column = index + 2
22+
break
23+
}
24+
}
25+
26+
let table-height = properties.len() + 2
27+
let table-length = choices.pos().len() + 2
28+
29+
import table: hline, vline, cell
30+
show cell: it => {
31+
set align(center + horizon)
32+
box(
33+
height: 30pt,
34+
it,
35+
)
36+
}
37+
table(
38+
columns: for _ in range(choices.pos().len() + 2) {
39+
(
40+
1fr,
41+
)
42+
},
43+
stroke: none,
44+
fill: (
45+
x,
46+
y,
47+
) => {
48+
if y == 0 or (
49+
x == 0 and not y == properties.len() + 1
50+
) {
51+
yellow.lighten(50%)
52+
}
53+
54+
if x == winning-column and not y == 0 {yellow.lighten(50%)}
55+
},
56+
57+
// we make lines
58+
59+
vline(stroke: yellow, end: table-height - 1),
60+
hline(stroke: yellow),
61+
62+
..for num in range(0, table-height) {
63+
let stroke = if num < 2 {yellow} else {gray}
64+
(hline(y: num, stroke: stroke, start: 2),)
65+
},
66+
67+
hline(stroke: gray, y: table-height, start: 1),
68+
69+
..for num in range(1, table-height + 2) {
70+
(
71+
vline(x: num, stroke: yellow, start: 0, end: 1),
72+
vline(x: num, stroke: gray, start: 1),
73+
)
74+
},
75+
76+
// outline the properties
77+
..for num in range(0, table-height) {
78+
(hline(y: num, stroke: yellow, start: 0, end: 1),)
79+
},
80+
81+
82+
83+
// outline the weights
84+
hline(stroke: pro-green, start: 1, end: 2),
85+
hline(y: table-height - 1, stroke: pro-green, start: 1, end: 2),
86+
vline(x: 1, stroke: pro-green, end: table-height - 1),
87+
vline(x: 2, stroke: pro-green, end: table-height - 1),
88+
89+
..for num in range(0, table-height) {
90+
(hline(y: num, stroke: pro-green, start: 1, end: 2),)
91+
},
92+
93+
94+
// outline the best choice
95+
hline(start: winning-column, end: winning-column + 1, stroke: yellow),
96+
vline(x: winning-column, stroke: yellow),
97+
vline(x: winning-column + 1, stroke: yellow),
98+
hline(y: table-height, start: winning-column, end: winning-column + 1, stroke: yellow),
99+
100+
..for num in range(0, table-height + 1) {
101+
(hline(y: num, stroke: yellow, start: winning-column, end: winning-column + 1),)
102+
},
103+
104+
105+
// ok we're done making lines
106+
107+
108+
[],
109+
cell(fill: pro-green.lighten(50%))[*Weights*],
110+
..for choice in choices.pos() {
111+
(
112+
[*#choice.at(0)*],
113+
)
114+
},
115+
..for (
116+
index,
117+
property,
118+
) in properties.enumerate() {
119+
(
120+
[*#property.name*],
121+
table.cell(fill: pro-green.lighten(50%))[#property.weight],
122+
..for result in data {
123+
(
124+
[#result.values.values().at(index).value],
125+
)
126+
},
127+
)
128+
},
129+
[],
130+
[*Totals:*],
131+
..for (
132+
index,
133+
result,
134+
) in data.enumerate() {
135+
(
136+
[#result.values.at("total").value],
137+
)
138+
},
139+
)
140+
}
+59-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,59 @@
1-
#let pro-con(pros: [], cons: []) = {}
1+
#import "../colors.typ": *
2+
3+
#let pro-con(
4+
pros: [],
5+
cons: [],
6+
) = {
7+
show grid.cell.where(
8+
y: 0,
9+
x: 0,
10+
): it => rect(
11+
radius: 5pt,
12+
width: 100%,
13+
fill: pro-green,
14+
it,
15+
)
16+
show grid.cell.where(
17+
y: 0,
18+
x: 1,
19+
): it => rect(
20+
radius: 5pt,
21+
width: 100%,
22+
fill: con-red,
23+
it,
24+
)
25+
26+
grid(
27+
columns: (
28+
1fr,
29+
1fr,
30+
),
31+
gutter: 5pt,
32+
inset: (
33+
x,
34+
y,
35+
) => if y == 0 {
36+
2pt
37+
} else {
38+
(
39+
top: 10pt,
40+
rest: 5pt,
41+
)
42+
},
43+
row-gutter: -5pt,
44+
fill: (
45+
x,
46+
y,
47+
) => if y == 0 {
48+
return
49+
} else if x == 0 {
50+
pro-green.lighten(50%)
51+
} else if x == 1 {
52+
con-red.lighten(50%)
53+
},
54+
align(center)[*Pros*],
55+
align(center)[*Cons*],
56+
pros,
57+
cons,
58+
)
59+
}

themes/hereford/components/toc.typ

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
#import "/utils.typ"
22

3-
#let toc() = utils.print-toc((_, body, _) => {
3+
#let toc() = utils.print-toc((
4+
_,
5+
body,
6+
_,
7+
) => {
48
set align(center)
59
let line = table.vline(stroke: gray)
610
table(
711
stroke: none,
8-
columns: (1fr, 1fr, 2fr, 1fr), [*Page \#*],
12+
columns: (
13+
1fr,
14+
1fr,
15+
2fr,
16+
1fr,
17+
),
18+
[*Page \#*],
919
line,
1020
[*EDP Step*],
1121
line,

themes/hereford/format.typ

+20-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#import "./colors.typ": *
22

3-
#let format-heading(it, color) = {
4-
//repr(it)
5-
3+
#let format-heading(
4+
it,
5+
color,
6+
) = {
67
if it.level == 1 {
78
set text(size: 13pt)
89
set block(spacing: 1em)
@@ -11,19 +12,29 @@
1112
outset: 7pt,
1213
width: 100%,
1314
fill: color,
14-
it.body
15+
it.body,
1516
)
1617
} else {
1718
set text(size: 12pt)
1819
it
1920
}
20-
2121
}
2222

23-
#let rules(doc) = {
24-
set page("us-letter", margin: (top: 2cm, x: 1.5cm, bottom: 1.5cm))
25-
set text(font: "Roboto", size: 11pt)
26-
//show heading: format-heading
23+
#let rules(
24+
doc,
25+
) = {
26+
set page(
27+
"us-letter",
28+
margin: (
29+
top: 2cm,
30+
x: 1.5cm,
31+
bottom: 1.5cm,
32+
),
33+
)
34+
set text(
35+
font: "Roboto",
36+
size: 11pt,
37+
)
2738

2839
doc
2940
}

0 commit comments

Comments
 (0)