From dbdfce08a17d977d738db9e42e10bddcacdfe20a Mon Sep 17 00:00:00 2001 From: Ernesto Martinez Garcia Date: Fri, 5 Sep 2025 19:01:58 +0200 Subject: [PATCH] fix color hardcoding --- 1.0.0/src/lib.typ | 86 ++++++++++++++++++++++++++++++++++++++- 1.0.0/src/macros.typ | 81 ------------------------------------ 1.0.0/template/slides.typ | 3 ++ 3 files changed, 88 insertions(+), 82 deletions(-) delete mode 100644 1.0.0/src/macros.typ diff --git a/1.0.0/src/lib.typ b/1.0.0/src/lib.typ index 0157777..d30b994 100644 --- a/1.0.0/src/lib.typ +++ b/1.0.0/src/lib.typ @@ -4,13 +4,16 @@ #import "tugcolors.typ" #import "helper.typ": * #import "logos.typ": * -#import "macros.typ": * +// Core Imports #import "@preview/codly:1.3.0": * // For bindings #import "@preview/cetz:0.3.2" // For bindings #import "@preview/fletcher:0.5.5" as fletcher: edge, node // For bindings #import "@preview/tiaoma:0.3.0" // For auto QR generation +// Styling Macro Imports +#import "@preview/showybox:2.0.4": showybox + // Touying bindings for cetz #let cetz-canvas = touying-reducer.with( reduce: cetz.canvas, @@ -410,4 +413,85 @@ body } +// ----------------------------------------------------------------------------- +// Styling Macros +// ----------------------------------------------------------------------------- + +#let quote-block( + top-pad: 0.55cm, + color: tugcolors.tug, + spacing: 0.3cm, + body, +) = [ + #touying-fn-wrapper((self: none) => [ + // Grid with the design + #let g(s: 0cm, body) = [ + #grid( + columns: (0.195cm, auto), + column-gutter: 0.7cm, + row-gutter: 0cm, + [ + #rect( + fill: self.colors.primary, + height: s + top-pad, + ) + ], + align(horizon, body), + ) + ] + + // We compute its "auto" heigth and then print it with the correct height + #layout(size => { + let (height,) = measure(width: size.width, g(body)) + g(s: height, body) + }) + + #v(spacing) + ]) +] + +// https://tabler.io/icons + +#let color-block( + title, + icon: none, + spacing: 0.78em, + color: none, + color-body: tugcolors.lite, + body +) = [ + #import "@preview/tableau-icons:0.331.0": * + #touying-fn-wrapper((self: none) => [ + #show emph: it => { + text(weight: "medium", fill: self.colors.primary, it.body) + } + + #showybox( + title-style: ( + color: white, + sep-thickness: 0pt, + ), + frame: ( + //inset: 0.4em, + radius: 0pt, + thickness: 0pt, + border-color: if color == none { self.colors.primary } else { color }, + title-color: if color == none { self.colors.primary } else { color }, + body-color: color-body, + inset: (x: 0.55em, y: 0.65em), + ), + above: spacing, + below: spacing, + title: if icon == none { + align(horizon)[#strong(title)] + } else { + align(horizon)[ + #draw-icon(icon, height: 1.2em, baseline: 20%, fill: white) #h(0.2cm) #strong[#title] + ] + }, + body, + ) + ]) +] + //vim:tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab colorcolumn=81 diff --git a/1.0.0/src/macros.typ b/1.0.0/src/macros.typ deleted file mode 100644 index 0113435..0000000 --- a/1.0.0/src/macros.typ +++ /dev/null @@ -1,81 +0,0 @@ -#import "tugcolors.typ" - -#let quote-block( - top-pad: 0.65cm, - color: tugcolors.tug, - spacing: 0.3cm, - body, -) = context [ - - // Grid with the design - #let g(s: 0cm, body) = [ - #grid( - columns: (0.195cm, auto), - column-gutter: 0.7cm, - row-gutter: 0cm, - [ - #rect( - fill: tugcolors.tug, - height: s + top-pad, - ) - ], - align(horizon, body), - ) - ] - - // We compute its "auto" heigth and then print it with the correct height - #layout(size => { - let (height,) = measure(width: size.width, g(body)) - g(s: height, body) - }) - - #v(spacing) -] - -#import "@preview/showybox:2.0.4": showybox -#import "@preview/tableau-icons:0.331.0": * -#let color-block(title, icon: none, - spacing: 0.78em, color: tugcolors.tug, color-body: tugcolors.lite, body) = [ - - #show emph: it => { - text(weight: "medium", fill: self.colors.primary, it.body) - } - - #showybox( - title-style: ( - color: white, - sep-thickness: 0pt, - ), - frame: ( - //inset: 0.4em, - radius: 0pt, - thickness: 0pt, - border-color: color, - title-color: color, - body-color: color-body, - inset: (x: 0.55em, y: 0.65em), - ), - above: spacing, - below: spacing, - title: if icon == none { - align(horizon)[#strong(title)] - } else { - align(horizon)[ - #draw-icon(icon, height: 1.2em, baseline: 20%, fill: white) #h(0.2cm) #strong[#title] - ] - }, - body, - ) -] - -// https://tabler.io/icons - -#let icon-block(title, icon, body) = [ - #color-block([#v(-0.2cm) #draw-icon(icon, height: 1.2em, baseline: 20%, fill: white) #h(0.2cm) #strong[#title] #v(-0.25cm)])[ - #body - ] -] - - - -//vim:tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab colorcolumn=81 diff --git a/1.0.0/template/slides.typ b/1.0.0/template/slides.typ index b0208aa..390c151 100644 --- a/1.0.0/template/slides.typ +++ b/1.0.0/template/slides.typ @@ -15,6 +15,9 @@ config-common( handout: false, ), + config-colors( + primary: black, + ), ) // -------------------------------[[ CUT HERE ]]--------------------------------