diff --git a/resources/public/js/cx.js b/resources/public/js/cx.js index 3af4ee3..9472336 100644 --- a/resources/public/js/cx.js +++ b/resources/public/js/cx.js @@ -24,9 +24,29 @@ function ensure_show_modal() { document.getElementById("modal").addEventListener('htmx:afterSwap', showModal) } +function stopPropagate(e) { + e.stopPropagation(); +} + +function preventDefault(e) { + e.preventDefault(); +} + +function apply_stop_propagate_handler() { + document.querySelectorAll('.stop-propagate').forEach((el) => el.removeEventListener('click', stopPropagate)); + document.querySelectorAll('.stop-propagate').forEach((el) => el.addEventListener('click', stopPropagate)); +} + +function apply_prevent_default_handler() { + document.querySelectorAll('.prevent-default').forEach((el) => el.removeEventListener('click', preventDefault)); + document.querySelectorAll('.prevent-default').forEach((el) => el.addEventListener('click', preventDefault)); +} + function apply_handlers() { ensure_cx_toggle() ensure_show_modal() + apply_stop_propagate_handler() + apply_prevent_default_handler() } function handle_response_errors(err) { diff --git a/src/co/gaiwan/compass/html/sessions.clj b/src/co/gaiwan/compass/html/sessions.clj index b102bb2..1caaa23 100644 --- a/src/co/gaiwan/compass/html/sessions.clj +++ b/src/co/gaiwan/compass/html/sessions.clj @@ -84,7 +84,8 @@ :value (if (session/participating? session user) "Leave" - "Join")}]]))) + "Join") + :class "prevent-default stop-propagate"}]]))) (o/defstyled session-card-actions :nav :flex :justify-end :w-full @@ -123,13 +124,16 @@ [join-btn session user]])) (o/defstyled session-card :div - :flex :gap-1 - :bg-surface-2 - :shadow-2 - :boder :border-solid :border-surface-3 + [:a :flex :gap-1 + :bg-surface-2 + :shadow-2 + :boder :border-solid :border-surface-3] #_:text-center + [:a + {:text-decoration "none" + :color "inherit"}] [:.title :font-size-4 :font-semibold :mt-3 :mb-2 - [:a {:color t/--text-1}]] + {:color t/--text-1}] [:.subtitle :font-size-3 :font-medium :mb-3 {:color t/--text-2}] [:.details :w-full #_:items-center :py-3 :mr-2 :relative] @@ -162,21 +166,23 @@ ;; :cx-toggle "expanded" ;; :cx-target (str "." session-card) :hx-disinherit "hx-target hx-select"} - [:div.type (:session.type/name type)] - - [img+join-widget session user] - - [:div.details - [:h2.title - [:a {:href (url-for :session/get {:id (:db/id session)})} - [:span.datetime - (str (time/truncate-to (time/local-time time) :minutes)) " · "] - title]] - [:h3.subtitle (session/subtitle session)] - #_[:div.expansion - [session-card-actions session user]] - [:div.loc (fmt-dur duration) " @ " (:location/name location)] - #_[:p.host "Organized by " organized]]])) + [:a + {:href (url-for :session/get {:id (:db/id session)}) } + [:div.type (:session.type/name type)] + + [img+join-widget session user] + + [:div.details + [:h2.title + [:span + [:span.datetime + (str (time/truncate-to (time/local-time time) :minutes)) " · "] + title]] + [:h3.subtitle (session/subtitle session)] + #_[:div.expansion + [session-card-actions session user]] + [:div.loc (fmt-dur duration) " @ " (:location/name location)] + #_[:p.host "Organized by " organized]]]])) (o/defrules session-card-pulse (garden.stylesheet/at-keyframes