hackens-epi/lib/libepi.typ

98 lines
2.5 KiB
Text
Raw Normal View History

2024-09-15 14:45:24 +02:00
#let dummy(truc) = [truc]
// Builds a card from arguments
2024-09-15 15:31:36 +02:00
#let card(name: none, protection_items: (), forbidden_items: (), referent:
none,
2024-09-15 15:27:23 +02:00
instructions: none, note: none, min_help: 0) = {
2024-09-15 14:45:24 +02:00
(
name: name,
protection_items: protection_items,
2024-09-15 15:27:23 +02:00
forbidden_items: forbidden_items,
2024-09-15 14:45:24 +02:00
referent: referent,
2024-09-15 15:27:23 +02:00
min_help: min_help,
2024-09-15 14:45:24 +02:00
instructions: instructions,
note: note
)
}
2024-09-15 15:27:23 +02:00
#let build_img(link, caption) = (
img: "../imgs/" + link,
caption: caption,
)
2024-09-15 14:45:24 +02:00
// Define bindings for al protection equipment items
2024-09-15 15:27:23 +02:00
#let Hearing = build_img("OBLIGATION/OBLIGATION-casque-antibruit.svg", "Casque anti-bruit")
#let Helmet = build_img("OBLIGATION/OBLIGATION-casque.svg", "Casque")
#let Glasses = build_img("OBLIGATION/OBLIGATION-lunettes.svg", "Lunettes")
#let Shield = build_img("OBLIGATION/OBLIGATION-visiere.svg", "Visière")
#let Gloves = build_img("OBLIGATION/OBLIGATION-gants.svg", "Gants")
#let Mask = build_img("OBLIGATION/OBLIGATION-protection-voies-respiratoires.svg", "Masque")
2024-09-15 14:45:24 +02:00
#let generate_single_card(card) = {
2024-09-15 15:27:23 +02:00
[
#set align(center)
#text(size: 40pt, weight: "bold")[#card.name]
]
[
2024-09-15 15:31:36 +02:00
#if card.referent != none [
#text(size: 20pt)[Référent·es: #card.referent]
] else [
#text(size: 20pt)[Référent·es: #text(style: "italic")[Demander à un·e respo]]
]
2024-09-15 15:27:23 +02:00
]
linebreak()
[
#let plural = if card.min_help > 0 [s] else []
2024-09-15 15:31:36 +02:00
#if card.min_help > 0 [
#text(size: 20pt)[Utilisation: au moins
#text(weight: "bold")[#str(card.min_help + 1)] personne#plural]
] else [
#text(size: 20pt)[Utilisation: peut s'utiliser seul·e]
]
2024-09-15 15:27:23 +02:00
]
linebreak()
linebreak()
[
#box([
#set align(center)
#{
for item in card.protection_items {
box([
#image(width: 30%, item.img)
2024-09-15 15:34:30 +02:00
#text(style: "italic", size: 18pt, [#item.caption])
2024-09-15 15:27:23 +02:00
])
}
for item in card.forbidden_items {
// TODO: Cross the image
box([
#image(width: 30%, item.img)
2024-09-15 15:34:30 +02:00
#text(style: "italic", size: 18pt, [#item.caption])
2024-09-15 15:27:23 +02:00
])
}
}
])
]
// TODO: Tidy this up
linebreak()
linebreak()
linebreak()
text(size: 30pt, weight: "bold")[Instructions]
linebreak()
text(size: 18pt)[#card.instructions]
2024-09-15 14:45:24 +02:00
}
#let generate_cards(cards) = {
let total_cards = cards.len()
let index = 0
for card in cards {
generate_single_card(card)
index += 1
if index != total_cards {
// Newpage
pagebreak()
}
}
}