react

"mulling over state management stuff"
martinklepsch 2021-03-25T23:59:23.014700Z

Would be curious to hear a bit more about how you’re implementing tooltips. I started with an API like (WithTooltip {:msg "abc"} (SomeComponent)) but had to use a wrapper element around SomeComponent to get a ref for tooltip positioning. This also complicated positioning when SomeComponent had margins, confusing the positioning of the tooltip library I’ve been using. I think I’m now converging on something way more low level than the above but ultimately more flexible and explicit:

(WithTooltip
  {:msg "My Tooltip"}
  (fn [{:keys [set-ref! show! hide!] :as args}]
    (ui/ButtonIcon
      {:ref set-ref!
       :on-mouse-enter show!
       :on-mouse-leave hide!}
      "Click here"))
This then internally uses a React fragment to not wrap the ButtonIcon component again. Would be happy about feedback/tire-kicking/alternative ideas!