Fork me on GitHub
#clojurescript
<
2022-01-16
>
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"
   })

vanelsas14:01:17

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

vanelsas14:01:38

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;
}

p-himik15:01:45

: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.

simonacca14:01:20

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
  IMap
  (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!

lilactown17:01:19

this question has been asked a few times in the last month. here's the current wisdom https://clojurians.slack.com/archives/C07UQ678E/p1641410630296000

✔️ 1
simonacca17:01:28

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

athomasoriginal16:01:33

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 https://ask.clojure.org/index.php/11426/optional-catch-binding-problem-in-recent-versions as well, but just curious if this known? Thanks!