diff options
-rw-r--r-- | README | 10 | ||||
-rw-r--r-- | README.in | 9 | ||||
-rw-r--r-- | module/output/html.scm | 82 | ||||
-rw-r--r-- | static/script.js | 31 | ||||
-rw-r--r-- | static/style.css | 61 |
5 files changed, 106 insertions, 87 deletions
@@ -24,13 +24,18 @@ repports, and other stuff should be sent to <hugo@lysator.liu.se>. If you want to contribute something yourself, either see TODO.* for things to do, or run `grep -RE 'TODO|NOTE'. -Requirements ------------- +Requirements & Dependencies +--------------------------- For basic functionallity guile-2.2 or greater should be enough (tested to work with guile-3.0). You do however need to supply your own calendar files. I recommend vdirsyncer for fetching local copies from all over the internet. +For popups to work the JS library Tipped is also needed, which +brings a transitive dependency on JQuery. +- https://tippedjs.com +- JQuery + Building -------- Since guile is primarily a scripting language no explicit @@ -43,3 +48,4 @@ Techical Details ---------------- - Internally all weeks start on sunday, which is repsenented as `0'. + @@ -12,10 +12,14 @@ Contributing ------------ Contributions are more than welcome. Patches, feature requests, bug repports, and other stuff should be sent to <hugo@lysator.liu.se>. If you want to contribute something yourself, either see TODO.* for things to do, or run `grep -RE 'TODO|NOTE'. -Requirements ------------- +Requirements & Dependencies +--------------------------- For basic functionallity guile-2.2 or greater should be enough (tested to work with guile-3.0). You do however need to supply your own calendar files. I recommend vdirsyncer for fetching local copies from all over the internet. +For popups to work the JS library Tipped is also needed, which brings a transitive dependency on JQuery. +- https://tippedjs.com +- JQuery + Building -------- Since guile is primarily a scripting language no explicit compilation step is required. Just run module/main.scm and the appropriate modules will be compiled (guile will tell you what it's doing). For building this README, run @@ -24,3 +28,4 @@ Since guile is primarily a scripting language no explicit compilation step is re Techical Details ---------------- - Internally all weeks start on sunday, which is repsenented as `0'. + diff --git a/module/output/html.scm b/module/output/html.scm index 702d229d..fb771507 100644 --- a/module/output/html.scm +++ b/module/output/html.scm @@ -103,7 +103,7 @@ -(define* (btn key: onclick href +(define* (btn key: onclick href (class '()) allow-other-keys: rest: args) (when (and onclick href) @@ -115,7 +115,7 @@ (let ((body #f)) `(,(cond [onclick 'button] [href 'a]) - (@ (class "btn") + (@ (class ,(string-join (cons "btn" class) " ")) ,(cond [onclick `(onclick ,onclick)] [href `(href ,href)]) ,@(let loop ((rem args)) @@ -131,19 +131,21 @@ (div ,body)))) -(define (popup ev) - `(div (@ (class "popup")) - (nav (@ (class "popup-control CAL_" ,(html-attr (or (attr (parent ev) 'NAME) - "unknown")))) - ,(btn "×" - title: "Stäng" - onclick: "close_popup(this)" - ) - ,(btn "📅" - title: "Ladda ner" - href: (string-append "/calendar/" (attr ev 'UID) ".ics"))) +(define (popup ev id) + `(div (@ (class "popup-container") (id ,id)) + (div (@ (class "popup")) + (nav (@ (class "popup-control CAL_" ,(html-attr (or (attr (parent ev) 'NAME) + "unknown")))) + ,(btn "×" + title: "Stäng" + onclick: "close_popup(this)" + class: '("close-tooltip") + ) + ,(btn "📅" + title: "Ladda ner" + href: (string-append "/calendar/" (attr ev 'UID) ".ics"))) - ,(fmt-single-event ev))) + ,(fmt-single-event ev)))) (define (data-attributes event) (hash-map->list @@ -185,29 +187,29 @@ (inner x (right-subtree tree)))))) (define* (make-block ev optional: (extra-attributes '())) - `(div (@ ,@(assq-merge - extra-attributes - `((class "event CAL_" ,(html-attr (or (attr (parent ev) 'NAME) - "unknown")) - ,(when (and (attr ev 'PARTSTAT) - (string= "TENTATIVE" (attr ev 'PARTSTAT))) - " tentative")) - ;; TODO only if in debug mode? - ,@(data-attributes ev)))) - (div (@ (class "event-inner")) - ;; NOTE These popup's are far from good. Main problem being that - ;; the often render off-screen for events high up on the screen. - ,(popup ev) - (a (@ (href "#" ,(UID ev)) - (class "hidelink")) - (div (@ (class "body")) - ,(when (attr ev 'RRULE) - `(span (@ (class "repeating")) "↺")) - ,((get-config 'summary-filter) ev (attr ev 'SUMMARY)) - ,(when (attr ev 'LOCATION) - `(span (@ (class "location")) - ,(string-map (lambda (c) (if (char=? c #\,) #\newline c)) - (attr ev 'LOCATION))))))))) + + (define popup-id (symbol->string (gensym "popup"))) + + `((a (@ (href "#" ,(UID ev)) + (class "hidelink")) + (div (@ ,@(assq-merge + extra-attributes + `((class "event CAL_" ,(html-attr (or (attr (parent ev) 'NAME) + "unknown")) + ,(when (and (attr ev 'PARTSTAT) + (string= "TENTATIVE" (attr ev 'PARTSTAT))) + " tentative")) + (data-tipped-options ,(format #f "inline: '~a'" popup-id)) + ;; TODO only if in debug mode? + ,@(data-attributes ev)))) + ,(when (attr ev 'RRULE) + `(span (@ (class "repeating")) "↺")) + ,((get-config 'summary-filter) ev (attr ev 'SUMMARY)) + ,(when (attr ev 'LOCATION) + `(span (@ (class "location")) + ,(string-map (lambda (c) (if (char=? c #\,) #\newline c)) + (attr ev 'LOCATION)))))) + ,(popup ev popup-id))) ;; Format single event for graphical display (define (create-block date ev) @@ -624,9 +626,15 @@ (content ,(date->string start-date "~s")))) (meta (@ (name end-time) (content ,(date->string (date+ end-date (date day: 1)) "~s")))) + ,(include-css "http://gandalf.adrift.space:8000/tipped/dist/css/tipped.css") + ,(include-css "/static/style.css") ,(include-alt-css "/static/dark.css" '(title "Dark")) ,(include-alt-css "/static/light.css" '(title "Light")) + + (script (@ (src "https://code.jquery.com/jquery-3.1.1.min.js")) "") + (script (@ (src "http://gandalf.adrift.space:8000/tipped/dist/js/tipped.min.js")) "") + (script (@ (src "/static/script.js")) "") (style ,(format #f "~:{.CAL_~a { background-color: ~a; color: ~a }~%.CAL_bg_~a { border-color: ~a }~%~}" (map (lambda (c) diff --git a/static/script.js b/static/script.js index 8617159a..6cca186e 100644 --- a/static/script.js +++ b/static/script.js @@ -251,15 +251,18 @@ window.onload = function () { } } + /* for (let popup of document.getElementsByClassName("popup")) { ev = parents_until(popup, {class: "event"}) e = ev.getElementsByClassName("body")[0] e.onclick = new_popup; /* disable scroll to element in side list if popups are available. - */ + * / e.parentElement.removeAttribute("href"); } + */ + document.onkeydown = function (evt) { evt = evt || window.event; @@ -269,3 +272,29 @@ window.onload = function () { } } + +$(document).ready(function() { + Tipped.setDefaultSkin("purple"); + Tipped.create(".event", { + /* no padding, I am the one who styles! */ + padding: false, + /* Don't remove from DOM when hiding */ + detach: false, + + /* click element to toggle. + Elements with class "close-tooltip" also + acts as close buttons */ + showOn: 'click', + hideOn: 'click', + + /* makes popups relative our scrolling days view */ + container: '.days', + + /* Ensures that the popups stay within the given area, + and don't strectch the container */ + containment: { + selector: '.days', + }, + behaviour: 'sticky', + }); +}); diff --git a/static/style.css b/static/style.css index ac490322..aad9a80c 100644 --- a/static/style.css +++ b/static/style.css @@ -396,6 +396,9 @@ along with their colors. height: 100%; padding: 0; overflow-x: scroll; + + /* allow for popup placement */ + position: relative; } .events { @@ -456,6 +459,7 @@ along with their colors. .event { transition: 0.3s; font-size: var(--event-font-size); + overflow: hidden; } .days .event { @@ -464,8 +468,6 @@ along with their colors. .events .event { width: 100%; - - } .events .event.continuing { @@ -581,60 +583,35 @@ along with their colors. .clock-22 { top: calc(100%/24 * 22); } .clock-24 { top: calc(100%/24 * 24); } -.event-inner { - /* Makes the popup's "position: absolute" be relative the event. - unset, initial, and inherit all seem to work */ - position: unset; - width: 100%; - height: 100%; -} /* Popups ---------------------------------------- */ -.event-inner .popup { - /* TODO & NOTE - If I understand it correctly this is absolute to the nearest offset parent. - since .event-inner has a position: unset the offset parent becomes - - event for week view, and - - body for month view. - This has the effect that top and left attributes become relative the offset - parent (even though without them the element is positioned relative to it's - direct event parent (except not in month view if the day is scrolled)). - - I think it's something here which stops popups in the month view from going - of the edge of the screen. I just want the same thing to be true for the - week view, since it's REALY ugly when a popup makes the calendar wider. - */ - position: absolute; - display: flex; - /* A scale(0%) is chosen for hiding the element for the following reasons: - - visibility: hidden still reserves space, which causes unwanted scroll- - bars since the final position of the popup is calculated at runtime - - Easier animation - */ - transform: scale(0); - transition: transform 0.3s cubic-bezier(0.33, 1, 0.68, 1); - z-index: 100; +.popup-container { + display: none; +} + +.popup { + display: flex; background-color: #dedede; color: black; overflow-y: auto; - max-width: 100ch; + max-width: 60ch; max-height: 60ch; min-width: 40ch; } -.event-inner .popup article { +.popup article { /* makes the text in the popup scroll, but not the sidebar */ overflow-y: auto; - padding: 1em; + word-break: break-word; } -.event-inner .popup .location { +.popup .location { font-style: initial; } @@ -659,14 +636,8 @@ along with their colors. font-size: 150%; } -.popup.show { - transform: scale(1); -} - -.event-inner .body { - overflow: hidden; - width: 100%; - height: 100%; +.tpd-tooltip a, .tpd-tooltip a:hover { + color: blue; } #bar { |