-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtilecv.typ
More file actions
169 lines (153 loc) · 4.86 KB
/
tilecv.typ
File metadata and controls
169 lines (153 loc) · 4.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
* file contains all the functions and building blocks.
*/
// list-in-grid
// items as a list or bullet point of items
#let make-list-in-grid() = (content, list-or-items) => grid(
columns: auto,
rows: auto,
if list-or-items == "list" {
[#content.join[ -- ]]
} else if list-or-items == "items" {
for item in content [- #item]
}
)
#let styled-rect(body, color, height: auto) = rect(
fill: rgb(color),
height: height,
width: 100%,
body
)
// entry-with-date, entry can be a timeline-item
// normal entry with date, title and details
#let make-entry-with-date(config) = (date, entry, details, with-progress: false) => {
let entry-details = { if with-progress == true {
grid(rows: auto, gutter: config.timeline_entry_items_gutter, ..details)
} else {
par(details, justify:true)
}
}
grid(
columns: (config.date_column_width, auto),
rows: auto,
gutter: config.entry_gutter,
grid.cell(
rowspan: 2,
emph[#text(date, weight: "light", size: config.date_font_size)],
),
upper[#text(entry, weight: "bold", size: config.default_font_size)],
entry-details)
}
// progress timeline
#let make-timeline-item(config) = (date, entry, details) => grid(
columns: (auto, 1fr),
rows: (auto, auto),
gutter: config.timeline_entry_items_gutter,
align: (left, bottom),
[- #text(entry, weight: "bold")],
align(left)[#text(date, size: config.date_font_size)],
grid.cell(
colspan: 2,
list(marker: [],
indent: -2.3pt,
[#rect(stroke: (left: gray),
inset: 5pt,
fill: none
)[#par(text(details, size: config.default_font_size - 0.3pt), justify: true)]]
)
)
)
#let make-tilecv-block(config) = (title, content, highlight) => {
let fill = if highlight { config.highlight_bg_color } else { white }
grid(
gutter: 0pt,
styled-rect([#upper[#title]], config.title_bg_color),
styled-rect(pad(top: config.block_gap, bottom: config.block_gap, [#content]), fill, height: auto)
)
}
// the custumization of basic building block
#let make-snapshot-block(config) = (title, content, highlight) => {
let fill = if highlight { config.highlight_bg_color } else { white }
grid(
rows: (auto, 1fr),
styled-rect([#upper[#title]], config.title_bg_color),
styled-rect(pad(top: config.block_gap, bottom: config.block_gap, [#content]), fill, height: 1fr)
)
}
#let make-tilecv-layout(config) = (sections, doc,) => {
// Page layout
set text(font: config.default_font, weight: "regular", size: config.default_font_size)
set align(left)
let paper_size = config.page_size
set page(
paper: {paper_size},
margin: {
if paper_size == "us-letter" {
(left: 2cm, right: 1.4cm, top: 1.2cm, bottom: 1.2cm)
} else {
(left: 1.4cm, right: 1.4cm, top: 1cm, bottom: 1cm)
}
},
)
// a grid cell that span 2 columns
let two-column-cell(body) = grid.cell(
colspan:2,
body
)
// a grid cell that span 2 rows
let two-raws-cell(body) = grid.cell(
rowspan:2,
body
)
// definition of tilecv layout as grid
//let tilecv_layout = grid(
// columns: (1fr, 1fr, 1fr),
// rows: (1fr, auto, auto),
// gutter: 4pt,
// grid.cell(
// colspan: 3,
// grid(gutter: 4pt,
// columns: (1fr, 1fr, 1fr),
// sections.at(0),
// two-column-cell(sections.at(1))
// )
// ),
// two-column-cell(sections.at(2)),
// two-raws-cell(sections.at(3)),
// two-column-cell(two-raws-cell(..sections.slice(4,)))
//)
// TODO: enhance response
let tilecv_layout = {
// Required sections (0 and 1)
let required_sections = if sections.len() >= 2 {
(sections.at(0), two-column-cell(sections.at(1)))
} else if sections.len() >= 1 {
(sections.at(0), []) // Empty cell if section 1 missing
} else {
panic("At least section 0 is required")
}
// Optional sections
let section_2 = if sections.len() > 2 { two-column-cell(sections.at(2)) } else { [] }
let section_3 = if sections.len() > 3 { two-raws-cell(sections.at(3)) } else { [] }
let remaining_sections = if sections.len() > 4 {
two-column-cell(two-raws-cell(..sections.slice(4)))
} else { [] }
grid(
columns: (1fr, 1fr, 1fr),
rows: (1fr, auto, auto),
gutter: 4pt,
grid.cell(
colspan: 3,
grid(gutter: 4pt,
columns: (1fr, 1fr, 1fr),
..required_sections
)
),
section_2,
section_3,
remaining_sections
)
}
[#tilecv_layout]
doc
}