aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-06-21 23:37:51 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-06-21 23:37:51 +0200
commitc16c6199c17917e6bd1817aa7c913faf567dd858 (patch)
tree79aa0b3ccfae6590d7731a8b0eda6a75031cae99
parentMinor cleanup in fmt-single-event. (diff)
downloadcalp-c16c6199c17917e6bd1817aa7c913faf567dd858.tar.gz
calp-c16c6199c17917e6bd1817aa7c913faf567dd858.tar.xz
Resolve TODO about calendar styles.
-rw-r--r--module/calp/html/vcomponent.scm21
-rw-r--r--module/calp/html/view/calendar.scm2
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; }"))))