hackens-epi/lib/libepi.typ

113 lines
3.1 KiB
Text

#import "@preview/gentle-clues:1.0.0": *
#let dummy(truc) = [truc]
// Builds a card from arguments
#let card(name: none, protection_items: (), forbidden_items: (), referent:
none,
instructions: none, note: none, warning: none, min_help: 0) = {
(
name: name,
protection_items: protection_items,
forbidden_items: forbidden_items,
referent: referent,
min_help: min_help,
instructions: instructions,
note: note,
warning: warning
)
}
#let build_img(link, caption) = (
img: "../imgs/" + link,
caption: caption,
)
// Define bindings for al protection equipment items
#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")
#let NoGloves = build_img("OBLIGATION/INTERDICTION-gants.svg", "Gants")
#let generate_single_card(version, card) = {
set page(header: [Fiche EPI HackENS v#version])
set page(footer: [HackENS, CC-BY-SA-NC 2.0])
[
#set align(center)
#text(size: 40pt, weight: "bold")[#card.name]
]
[
#if card.referent != none [
#text(size: 20pt)[#text(weight: "bold")[Référent·es:] #card.referent.join(", ")]
] else [
#text(size: 20pt)[#text(weight: "bold")[Référent·es:] #text(style: "italic")[Demander à un·e respo]]
]
]
linebreak()
[
#let plural = if card.min_help > 0 [s] else []
#if card.min_help > 0 [
#text(size: 20pt)[#text(weight: "bold")[Utilisation:] au moins
#text(weight: "bold")[#str(card.min_help + 1)] personne#plural]
] else [
#text(size: 20pt)[#text(weight: "bold")[Utilisation:] peut s'utiliser seul·e]
]
]
linebreak()
linebreak()
[
#box([
#set align(center)
#{
for item in card.protection_items {
box([
#image(width: 30%, item.img)
#text(weight: "bold", size: 18pt, [#item.caption])
])
}
for item in card.forbidden_items {
// TODO: Cross the image
box([
#image(width: 30%, item.img)
#text(weight: "bold", size: 18pt, [#item.caption])
])
}
}
])
]
linebreak()
linebreak()
if card.warning != none {
// TODO: Tidy this up
//text(size: 30pt, weight: "bold")[Avertissement]
//linebreak()
//text(size: 18pt)[#card.warning]
warning(title: [#text(size:30pt)[Avertissement]])[#text(size:
18pt)[#card.warning]]
}
//text(size: 30pt, weight: "bold")[Instructions]
//linebreak()
//text(size: 18pt)[#card.instructions]
info(title: [#text(size:30pt)[Instructions]])[#text(size:18pt)[#card.instructions]]
}
#let generate_cards(version, cards) = {
let total_cards = cards.len()
let index = 0
for card in cards {
generate_single_card(version, card)
index += 1
if index != total_cards {
// Newpage
pagebreak()
}
}
}