From 7500a36594cafc3b7bdc86a65ee4bf64f2b40c6c Mon Sep 17 00:00:00 2001 From: Popa <115492561+Popa-42@users.noreply.github.com> Date: Mon, 2 Nov 2026 11:39:07 +0100 Subject: [PATCH] feat: add task bonus and challenge labels --- src/templates/modern.typ | 48 +++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/src/templates/modern.typ b/src/templates/modern.typ index 38d1f30..bb0f2d3 100644 --- a/src/templates/modern.typ +++ b/src/templates/modern.typ @@ -2,7 +2,6 @@ #let default-theme = ( primary: rgb("#0E7C7B"), - secondary: rgb("#D4F4ED"), accent: rgb("#FFC857"), warning: rgb("#E9724C"), error: rgb("#C5283D"), @@ -24,14 +23,26 @@ #let doc-id = sys.inputs.at("doc-id", default: none) -#let task(points: none, title, body, col: none, label: none) = context { + +#let task( + points: none, + title, + body, + col: none, + label: none, + bonus: false, + challenge: false, +) = context { subtask-indent.update((0,)) let theme = theme-state.get() - let text-color = theme.primary + + let col = if col == none { theme.primary } else { col } + + let text-color = col let header-font = theme.sans-font - let border-color = theme.primary - let background-color = theme.primary.transparentize(95%) + let border-color = col + let background-color = col.transparentize(95%) let task-label = if label == none { task-label-state.get() } else { label } let subtask-points = query( @@ -43,6 +54,10 @@ let calculated-points = subtask-points.map(e => e.value.points).sum(default: 0) let shown-points = if points != none { points } else if subtask-points.len() > 0 { calculated-points } + let tag = content => box(stroke: (paint: text-color, thickness: 0.6pt), radius: 0.3em, inset: (x: 0.45em, y: 0.17em))[ + #text(fill: text-color, size: 0.75em, weight: "bold")[#content] + ] + v(1.5em) task-active.update(true) @@ -70,6 +85,8 @@ #if title != none and title != [] { [ — #title] } + #if bonus { [ (Bonus)] } + #if challenge { [ (Herausforderung)] } ] } @@ -78,8 +95,26 @@ [*#task-label #task-counter.display()*] if title != none and title != [] { [ --- #title] } + + if bonus { + h(1.2em) + tag([BONUS]) + } + + if challenge { + h(1.2em) + tag([HERAUSFORDERUNG]) + } + h(1fr) - if shown-points != none and shown-points > 0 { [#shown-points P.] } + + if shown-points != none and shown-points > 0 { + if bonus { + [+#shown-points P.] + } else { + [#shown-points P.] + } + } }, ) @@ -98,6 +133,7 @@ task-counter.step() } + // deprecated, use #task instead #let exercise = task