This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-13
Channels
- # announcements (2)
- # babashka (30)
- # beginners (44)
- # biff (20)
- # calva (15)
- # cider (7)
- # clerk (4)
- # clojure (15)
- # clojure-austin (1)
- # clojure-europe (35)
- # clojure-hungary (1)
- # clojure-nl (1)
- # clojure-norway (6)
- # clojure-uk (7)
- # clojurescript (33)
- # conjure (1)
- # cryogen (1)
- # cursive (3)
- # data-science (8)
- # docker (2)
- # emacs (78)
- # gratitude (2)
- # hyperfiddle (26)
- # improve-getting-started (1)
- # jobs-discuss (12)
- # lsp (7)
- # malli (11)
- # missionary (57)
- # off-topic (14)
- # pathom (13)
- # portal (6)
- # reagent (6)
- # releases (3)
- # ring (25)
- # shadow-cljs (18)
- # squint (11)
- # vim (3)
Hello, I trying to create a basic popup, but its not working. When I hover my mouse over the text nothing happens. Is it wrong? How can I create a basic popup functionality?
#?(:cljs (defn popover [text]
[:div.popover text]))
#?(:cljs
(defn app []
(let [show-popover? (reagent/atom false)]
[:div
[:a {:on-mouse-enter #(reset! show-popover? true)
:on-mouse-leave #(reset! show-popover? false)}
"Hover me to show popover"]
(when @show-popover?
[popover "This is the popover content."])]))
)
You probaby need to update the R/atom inside the render function so that it can be rerendered when the value of the R/atom changes. Something like this:
#?(:cljs (defn popover [text]
[:div.popover text]))
#?(:cljs
(defn app []
(let [show-popover? (reagent/atom false)]
(fn []
[:div
[:a {:on-mouse-enter #(reset! show-popover? true)
:on-mouse-leave #(reset! show-popover? false)}
"Hover me to show popover"]
(when @show-popover?
[popover "This is the popover content."])])))
)
it worked thanks :)) How can I add style to pop up? can you show me mini example if possible. So I can update it later 🙂
There are multiple ways to do it. Perhaps the simplest way for now is to add some inline css stying to your popover like this
#?(:cljs (defn popover [text]
[:div.popover {:style {:background-color "green"
;; etc, add any css that you may need
}}
text]))