helix

https://github.com/Lokeh/helix
danielneal 2019-12-27T15:01:56.000500Z

hey @lilactown I’m struggling to get the macros working to generate react native components

danielneal 2019-12-27T15:02:05.001Z

This works:

danielneal 2019-12-27T15:02:06.001100Z

#?(:clj
   (defmacro View [& args]
     `(hx/$ ~(symbol "rn" "View") ~@args)))

#?(:clj
   (defmacro Text [& args]
     `(hx/$ ~(symbol "rn" "Text") ~@args)))

#?(:clj
   (defmacro ActivityIndicator [& args]
     `(hx/$ ~(symbol "rn" "ActivityIndicator") ~@args)))

danielneal 2019-12-27T15:02:21.001600Z

but every time I try to do the loop I get some kind of mad error

danielneal 2019-12-27T15:02:25.001800Z

any ideas?

danielneal 2019-12-27T15:20:05.002Z

ah, this seems to work

#?(:clj
   (defn gen-tag
     [t]
     `(defmacro ~t [& args#]
        `(hx/$ ~(symbol "rn" ~(str t)) ~@args#))))

#?(:clj
   (defmacro gen-tags
     []
     `(do
        ~@(for [t tags]
            (gen-tag t)))))

#?(:clj
   (gen-tags))

danielneal 2019-12-27T15:20:37.002700Z

(where tags = '[View Text ActivityIndicator…] )

lilactown 2019-12-27T17:28:25.003Z

Cool

lilactown 2019-12-27T17:28:56.003700Z

Although that might not work quite right for React Native

lilactown 2019-12-27T17:30:07.005500Z

It won’t convert kebab-case props to camelCase for you, and it won’t recursively convert the “style” prop to a JS obj