diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-06-21 23:37:51 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-06-21 23:37:51 +0200 |
commit | c16c6199c17917e6bd1817aa7c913faf567dd858 (patch) | |
tree | 79aa0b3ccfae6590d7731a8b0eda6a75031cae99 /module/c | |
parent | Minor cleanup in fmt-single-event. (diff) | |
download | calp-c16c6199c17917e6bd1817aa7c913faf567dd858.tar.gz calp-c16c6199c17917e6bd1817aa7c913faf567dd858.tar.xz |
Resolve TODO about calendar styles.
Diffstat (limited to '')
-rw-r--r-- | module/calp/html/vcomponent.scm | 21 | ||||
-rw-r--r-- | 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; }")))) |