Fork me on GitHub
Tala Tarazi14:01:17

Hi all, I just started working on re-frame. I created a class for a button and i want to add a different styling for hover state. how can i achieve that.

(defclass largeBtn
  {:font-size "16px"
   :font-weight "bold"
   :color "white"
   :background-color "#7070FA"
   :border-radius "4px"
   :border "1px solid #5555F2"
   :padding "9px 20px"


You do not actually need Re-frame for that. It is a local state of the button itself. So you can just create a Reagent atom that keeps track of the hoover state. The moment the user hoovers, set the value and use the trigger to update the styling.

Tala Tarazi14:01:08

Can't i add it to the style file i already have? not creating another class for it?

Tala Tarazi14:01:27

like we do in css something like &hover


You mean like something like this? Not sure if that would work. I may have made my initial answer a bit complex, since you referred to Re-frame

largeBtn:hover  {
background-color: yellow;


:hover is a pseudo-class, and pseudo-classes cannot be used in inline styles. And Reagent can only generate inline styles. So you either have to use CSS (maybe regular CSS, maybe some CSS-in-JS solution - doesn't matter here), or you have to change the inline styles according to some ratom, as vanelsas mentions above.


How to extend a protocol to clojurescript collections generically? If I have a protocol, for example:

(defprotocol MyProto
  (myfun []))
and I extend it as such:
(extend-protocol MyProto
  (myfun [] :result)
the following doesn't work:
(myfun {})
=> No protocol method MyProto.myfun defined for type cljs.core/PersistentArrayMap
even though I can see that (satisfies? IMap {}) => true Hence my question, how do I extend myfun to maps generically without having to keep up with clojurescript internals (i.e. the various map implementations)? Thank you in advance for your advice!


this question has been asked a few times in the last month. here's the current wisdom

✔️ 1

I did some research but didn't know of the other channel, thanks!


For ClojureScript 1.11.4 when trying to do an advanced build I get the following warning.

goog/i18n/numberformat.js:963:8: ERROR - [JSC_LANGUAGE_FEATURE] This language feature is only supported for ECMASCRIPT_2019 mode or better: Optional catch binding.
  963|       } catch {
I have a workaround and the question was raised in as well, but just curious if this known? Thanks!