helix

https://github.com/Lokeh/helix
danielneal 2020-01-10T12:07:34.000600Z

Ah, so to get the style prop converted to js and the camel casing, I’d need to somehow tag the react native components as native

danielneal 2020-01-10T12:09:32.001200Z

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

danielneal 2020-01-10T12:09:36.001400Z

that doesn’t work, I guess because ^:native is a reader tag and evaluated at read time rather than macroexpansion time

danielneal 2020-01-10T12:28:01.002500Z

I also tried (with-meta … {:native true}) but I think I’ve lost myself too deep in the macro

danielneal 2020-01-10T12:33:44.003200Z

I guess because rn/Text is a js object that doesn’t implement IMeta

danielneal 2020-01-10T12:42:24.003400Z

maybe I can call specify

danielneal 2020-01-10T12:42:32.003700Z

but the examples look easier some how

lilactown 2020-01-10T16:12:57.004200Z

Try tagging the symbol at macro time

lilactown 2020-01-10T16:13:35.004900Z

Surprised ^:native doesn't work

danielneal 2020-01-10T16:47:39.005200Z

I think ^:native just disappears from the call to gen-tag

lilactown 2020-01-10T16:50:34.006400Z

(macroexpand `($ ^:native ~(symbol "foo") {:foo-bar "baz"}))
doesn’t seem to work either

lilactown 2020-01-10T16:50:57.006700Z

(macroexpand `($ ~(with-meta (symbol "foo") {:native true}) {:foo-bar "baz"}))
seems to work

lilactown 2020-01-10T16:51:14.007Z

(helix.core/create-element "foo" (helix.impl.props/native-props {:foo-bar "baz"}))

danielneal 2020-01-10T16:58:20.007200Z

hmm yes I did try a with-meta variant

danielneal 2020-01-10T16:58:28.007500Z

I’ll have another go

danielneal 2020-01-10T17:06:52.008Z

I’m in over my head a bit with the macro calling a function that generates the code to generate a macro 😄

danielneal 2020-01-10T17:07:12.008400Z

I think I may have messed up some splicing

danielneal 2020-01-10T17:07:42.008700Z

oh wait, I think it’s working, but I’m perhaps getting another unrelated error

danielneal 2020-01-10T17:10:00.009Z

does that work with a namespaced symbol?

danielneal 2020-01-10T17:10:58.009300Z

I think I’m losing the namespace somewhere

danielneal 2020-01-10T17:11:12.009600Z

(defn gen-tag
     [t]
     `(defmacro ~t [& args#]
        `(hx/$ ~(with-meta (symbol "rn" ~(str t)) {:native true})
           ~@args#)))

danielneal 2020-01-10T17:12:15.010100Z

(macroexpand '(Text {:style {:backgroundColor "red"}})) =>

danielneal 2020-01-10T17:12:18.010300Z

(helix.core/create-element Text (helix.impl.props/native-props {:style {:backgroundColor red}}))

danielneal 2020-01-10T17:13:45.010700Z

ah perhaps it’s this line https://github.com/Lokeh/helix/blob/master/src/helix/core.clj#L28-L30

danielneal 2020-01-10T17:14:05.011Z

stripping the ns

lilactown 2020-01-10T17:19:44.011200Z

aha

lilactown 2020-01-10T17:20:17.011400Z

good catch

lilactown 2020-01-10T17:22:50.011600Z

Pushed a fix

lilactown 2020-01-10T17:23:04.011900Z

do you need me to publish to clojars?

danielneal 2020-01-10T17:24:50.012700Z

That would be great but no rush, I'm checking off for the week :)

lilactown 2020-01-10T17:38:15.013Z

pushed out 0.0.6. have a great weekend

danielneal 2020-01-10T18:13:25.013400Z

Awesome! Thanks 🙌🙌