diff --git a/site/lib/lib.typ b/site/lib/lib.typ new file mode 100644 index 0000000..0f462bd --- /dev/null +++ b/site/lib/lib.typ @@ -0,0 +1,51 @@ +// #import "@preview/calepin:0.1.0" as calepin +#import "@preview/hes-so-core:0.1.0" +#import "@preview/frackable:0.2.0": * + +// #import "@preview/cetz:0.5.2" +// +// #let drawing(..args) = { +// let canvas = cetz.canvas(..args) +// context if target() == "html" { +// html.frame(canvas) +// } else { +// canvas +// } +// } + +#let tag(body, fill: yellow, stroke: auto) = { + let stroke-color = if stroke == auto { + fill.darken(25%) + } else if type(stroke) == color { + stroke + } else if type(stroke) == stroke { + stroke.paint + } else { + fill.darken(25%) + } + + let stroke-rule = if stroke == auto { + 1pt + stroke-color + } else if type(stroke) == color { + 1pt + stroke + } else { + stroke + } + + context if target() == "html" { + let bg-hex = fill.to-hex() + let border-hex = stroke-color.to-hex() + html.elem("span", attrs: ( + style: "display: inline-block; background-color: " + bg-hex + + "; border: 1px solid " + border-hex + + "; color: #1f2933; border-radius: 1em; padding: 0.2em 0.6em; font-size: 0.85em; font-weight: 500; line-height: 1.2;" + ))[#body] + } else { + box( + fill: fill, + stroke: stroke-rule, + radius: 1em, + inset: (x: 0.5em, y: 0.5em) + )[#body] + } +}