This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-31
Channels
- # announcements (1)
- # babashka (27)
- # beginners (107)
- # calva (2)
- # cider (1)
- # clara (1)
- # clj-kondo (17)
- # clojure (74)
- # clojure-europe (18)
- # clojure-nl (4)
- # clojure-norway (3)
- # clojure-spec (11)
- # clojure-uk (3)
- # clojurescript (10)
- # conjure (12)
- # datomic (4)
- # figwheel-main (1)
- # fulcro (28)
- # graalvm (11)
- # hugsql (12)
- # joker (1)
- # klipse (5)
- # malli (2)
- # meander (1)
- # membrane (9)
- # off-topic (26)
- # pedestal (6)
- # remote-jobs (1)
- # ring-swagger (5)
- # shadow-cljs (4)
- # test-check (14)
- # vrac (8)
- # xtdb (8)
@yogthos I am not sure if you mean the vrac components or the html nodes in the form.
For the components, they are not themself visible or disabled. The only choice for them is to be included or not being included in the view at any time.
For the html nodes, visible and disabled would be attributes to set in the same way of the value
attribute on the input html node.
ah ok yeah I was referring to html nodes, and doing it the same way as value makes sense
cause some parts of the template can be rendered once if they have no behaviors, but others will need to observe the state and repaint if the state changes
(defc numeric [title data]
(let [form-id (gen-id "form-")] ;; non-reactive binding to a generated unique string
[:div
[:label {:for form-id} title]
[:input {:type :number
:id form-id
:value (:value data)
:disabled (:disabled? data)
:style {:visibility (if (:visible? data) "visible" "hidden")}
:on-change (dispatch [:input-change data])}]]))
(if (:visible? data) "visible" "hidden")
is a little special, it’s not the same if
than the one that returns html nodes. It’s a if
which returns values, as if it was wrapped into a (val ...)
block.