hackens-epi/lib/libepi.typ

114 lines
3.1 KiB
Text
Raw Normal View History

2024-09-15 15:44:31 +02:00
#import "@preview/gentle-clues:1.0.0": *
2024-09-15 19:33:31 +02:00
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:44:31 +02:00
instructions: none, note: none, warning: 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,
2024-09-15 15:44:31 +02:00
note: note,
warning: warning
2024-09-15 14:45:24 +02:00
)
}
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
2024-09-15 19:40:53 +02:00
#let NoGloves = build_img("OBLIGATION/INTERDICTION-gants.svg", "Gants")
2024-09-15 19:57:15 +02:00
#let generate_single_card(version, card) = {
set page(header: [Fiche EPI HackENS v#version])
set page(footer: [HackENS, CC-BY-SA-NC 2.0])
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)[#text(weight: "bold")[Référent·es:] #card.referent.join(", ")]
2024-09-15 15:31:36 +02:00
] else [
#text(size: 20pt)[#text(weight: "bold")[Référent·es:] #text(style: "italic")[Demander à un·e respo]]
2024-09-15 15:31:36 +02:00
]
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)[#text(weight: "bold")[Utilisation:] au moins
2024-09-15 15:31:36 +02:00
#text(weight: "bold")[#str(card.min_help + 1)] personne#plural]
] else [
#text(size: 20pt)[#text(weight: "bold")[Utilisation:] peut s'utiliser seul·e]
2024-09-15 15:31:36 +02:00
]
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 19:57:15 +02:00
#text(weight: "bold", 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 19:57:15 +02:00
#text(weight: "bold", size: 18pt, [#item.caption])
2024-09-15 15:27:23 +02:00
])
}
}
])
]
2024-09-15 19:40:53 +02:00
linebreak()
linebreak()
2024-09-15 15:44:31 +02:00
if card.warning != none {
// TODO: Tidy this up
2024-09-15 19:40:53 +02:00
//text(size: 30pt, weight: "bold")[Avertissement]
//linebreak()
//text(size: 18pt)[#card.warning]
warning(title: [#text(size:30pt)[Avertissement]])[#text(size:
18pt)[#card.warning]]
2024-09-15 15:44:31 +02:00
}
2024-09-15 15:27:23 +02:00
2024-09-15 19:40:53 +02:00
//text(size: 30pt, weight: "bold")[Instructions]
//linebreak()
//text(size: 18pt)[#card.instructions]
2024-09-15 15:44:31 +02:00
info(title: [#text(size:30pt)[Instructions]])[#text(size:18pt)[#card.instructions]]
2024-09-15 14:45:24 +02:00
}
2024-09-15 19:57:15 +02:00
#let generate_cards(version, cards) = {
2024-09-15 14:45:24 +02:00
let total_cards = cards.len()
let index = 0
for card in cards {
2024-09-15 19:57:15 +02:00
generate_single_card(version, card)
2024-09-15 14:45:24 +02:00
index += 1
if index != total_cards {
// Newpage
pagebreak()
}
}
}