Fork me on GitHub
#hyperfiddle
<
2023-02-21
>
Dustin Getz15:02:50

@pez i've switched to calva, how do i configure the indentation of fulcro-style dom to not align vertically?

pez16:02:17

There is a setting to tell Calva where to look for cljfmt config file. This should be an edn file. See https://calva.io/formatting/#configuration

👀 2
Dustin Getz16:02:30

Is there a cljfmt rule that people use to do this?

pez16:02:09

From there it is about adding the indentation rules into that file. You seem to want [[:inner 0]] for electric/dom. Maybe something like

{:indents {hyperfiddle.electric/dom [[:inner 0]]}
 :alias-map {"dom" "electric/dom"}}

👍 2
pez16:02:08

If the config file is within the workspace Calva will hotreload it. So you can have a :experimentation (or whatever) section in it and experiment within the file. (`tab` formats the current enclosing form).

Dustin Getz16:02:05

got it working, thank you

🙏 2
pez16:02:46

Was the alias-map necessary? I'm guessing it might be because Calva only formats the minimal amount of text, so cljfmt doesn't have an ns-form...

Dustin Getz16:02:48

I used {#"dom/.*" [[:inner 0]]}

🙏 2
Dustin Getz16:02:06

hyperfiddle.electric-dom2/div [[:inner 0]] didn't resolve the aliases

Dustin Getz16:02:20

dom/div did resolve the aliases but i need the regex anyway

pez16:02:38

FYI: cljfmt and Cursive are quite incompatible around some default formatting so it can get a bit of a whitespace war with the require forms and some other cases. I've never quite figured it out. (And no-one else has either, for all I know.)

Dustin Getz16:02:05

yeah we see that too

tatut17:02:10

so what would be the equivalent of mount/unmount in react like libraries… m/observe looks like it is used like that, but I don’t really grok it yet

Dustin Getz18:02:39

you can use these, i'll consider them for inclusion in the core ns

Dustin Getz18:02:41

(defmacro on-mount [& body] `(new (m/observe #(do (% nil) ~@body (fn [])))))
(defmacro on-unmount [& body] `(new (m/observe #(do (% nil) (fn [] ~@body)))))

; usage 
; note the body is ordinary Clojure, not Electric, so no transfers, side effects only
(on-mount (swap! !selected# select-if-first dom/node))
(on-unmount (swap! !selected# ?pass-on-to-first dom/node))

Dustin Getz18:02:19

(from a thread yesterday)

tatut04:02:09

thanks, that makes sense