Fork me on GitHub
#reagent
<
2018-05-28
>
valtteri05:05:06

@kwladyka This is how I got withStyles working.

(defn with-styles [styles]
  (->> styles
       (transform-keys keyword->PasCamelCase)
       clj->js
       js/MaterialUIStyles.withStyles))

(defn ->styled [styles component-name]
  (let [style-fn (with-styles styles)]
    (-> (gobj/get js/MaterialUI component-name)
        style-fn
        r/adapt-react-class)))

(def red-bg {:root {:background-color "red"}})
(def red-btn (->styled red-bg "Button"))
However I didn’t yet find a way to create a function where I can pass Reagent component created with adapt-react-class to a style-hoc-creator-whatever function. I tried reactifying the component with no success. I’m not sure if it’s possible to easily achieve something like this with the withStyles approach:
[with-styles { … }
 [my-component-1 { … }]
 [my-component-2 { … }]]

🍺 1
valtteri05:05:00

Since I don’t urgently need this I’m not going to spend too much time finding out. I might get back to this later though.