-
-
Save ajchemist/01c8d811a8534146dbaf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn ->kebab [s] | |
(str/join "-" (map str/lower-case (re-seq #"\w[a-z]+" s)))) | |
(def components '[Card AppBar LeftNav CardTitle]) | |
(defn gen-wrapper [component] | |
`(defmacro ~(symbol (->kebab (str component))) [& args#] | |
(let [[opts# & [children#]] (if (-> args# first map?) | |
[(first args#) (rest args#)] | |
[nil args#])] | |
`(js/React.createElement | |
~(symbol "js" (str "window.MaterialUI." (name '~component))) | |
(cljs.core/clj->js ~opts#) | |
~@children#)))) | |
(defmacro gen-wrappers [] | |
`(do | |
~@(clojure.core/map gen-wrapper components))) | |
(gen-wrappers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment