diff options
author | Hugo Hörnquist <hugo@hornquist.se> | 2019-04-22 21:00:53 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@hornquist.se> | 2019-04-22 21:00:53 +0200 |
commit | a31f308e723d9d7b18a5fe71acea6d7e599600e4 (patch) | |
tree | 7ed5367bbe7874502b96076460a440608bce15d1 | |
parent | Update CSS gradients. (diff) | |
download | calp-a31f308e723d9d7b18a5fe71acea6d7e599600e4.tar.gz calp-a31f308e723d9d7b18a5fe71acea6d7e599600e4.tar.xz |
Slightly better HTML colors.
Diffstat (limited to '')
-rw-r--r-- | module/html/html.scm | 18 | ||||
-rw-r--r-- | static/style.css | 3 |
2 files changed, 17 insertions, 4 deletions
diff --git a/module/html/html.scm b/module/html/html.scm index e9628424..3546a476 100644 --- a/module/html/html.scm +++ b/module/html/html.scm @@ -131,6 +131,18 @@ never on absolute times. For that see date->decimal-hour" (define (d str) (string->date str "~Y-~m-~d")) + +(define (calculate-fg-color c) + (define (str->num c n) (string->number (substring/shared c n (+ n 2)) 16)) + (let ((r (str->num c 1)) + (g (str->num c 3)) + (b (str->num c 5))) + (if (< 1/2 (/ (+ (* 0.299 r) + (* 0.587 g) + (* 0.144 b)) + #xFF)) + "black" "#e5e8e6"))) + (define-public (html-main calendars events) `(html (head (title "Calendar") @@ -138,13 +150,15 @@ never on absolute times. For that see date->decimal-hour" (link (@ (type "text/css") (rel "stylesheet") (href "static/style.css"))) - (style ,(format #f "~{.CAL_~a { background-color: ~a }~%~}" + (style ,(format #f "~{.CAL_~a { background-color: ~a; color: ~a }~%~}" (concat (map (lambda (c) (list (html-attr (if (pair? (attr c 'NAME)) (car (attr c 'NAME)) (attr c 'NAME))) - (or (attr c 'COLOR) "white"))) + (or (attr c 'COLOR) "white") + (or (and=> (attr c 'COLOR) calculate-fg-color ) + "black"))) calendars))))) (body (div (@ (class "calendar")) ,@(time-marker-div) diff --git a/static/style.css b/static/style.css index 2ce4a002..8ac46785 100644 --- a/static/style.css +++ b/static/style.css @@ -71,8 +71,7 @@ body { .event { width: 100%; - border-style: solid; - border-width: 2px; + border: 2px solid black; font-size: 8pt; overflow: hidden; |