From c16c6199c17917e6bd1817aa7c913faf567dd858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 21 Jun 2022 23:37:51 +0200 Subject: Resolve TODO about calendar styles. --- module/calp/html/vcomponent.scm | 21 +++++++++------------ module/calp/html/view/calendar.scm | 2 +- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/module/calp/html/vcomponent.scm b/module/calp/html/vcomponent.scm index 4f94cd94..1cee47a5 100644 --- a/module/calp/html/vcomponent.scm +++ b/module/calp/html/vcomponent.scm @@ -272,18 +272,15 @@ ;; Specific styles for each calendar. -;; TODO only emit the CSS here, requiring the caller to handle the context, -;; since that would allow us to use this in other contexts. -(define-public (calendar-styles calendars) - `(style - ,(lambda () (format #t "~:{ [data-calendar=\"~a\"] { --color: ~a; --complement: ~a }~%~}" - (map (lambda (c) - (let ((name (base64encode (prop c 'NAME))) - (bg-color (prop c 'COLOR)) - (fg-color (and=> (prop c 'COLOR) - calculate-fg-color))) - (list name (or bg-color 'white) (or fg-color 'black)))) - calendars))))) +(define*-public (calendar-styles calendars optional: (port #f)) + (format port "~:{ [data-calendar=\"~a\"] { --color: ~a; --complement: ~a }~%~}" + (map (lambda (c) + (let ((name (base64encode (prop c 'NAME))) + (bg-color (prop c 'COLOR)) + (fg-color (and=> (prop c 'COLOR) + calculate-fg-color))) + (list name (or bg-color 'white) (or fg-color 'black)))) + calendars))) ;; "Physical" block in calendar view (define*-public (make-block ev optional: (extra-attributes '())) diff --git a/module/calp/html/view/calendar.scm b/module/calp/html/view/calendar.scm index 705fa42a..8b7d8075 100644 --- a/module/calp/html/view/calendar.scm +++ b/module/calp/html/view/calendar.scm @@ -120,7 +120,7 @@ window.default_calendar='~a';" (script (@ (src "/static/script.out.js"))) (script (@ (src "/static/user/user-additions.js"))) - ,(calendar-styles calendars) + (style ,(lambda () (calendar-styles calendars #t))) ,@(when (debug) '((style ":root { --background-color: pink; }")))) -- cgit v1.2.3