vrac

Template-based web library [WIP] - https://github.com/green-coder/vrac Zulip archive: https://clojurians.zulipchat.com/#narrow/stream/180378-slack-archive/topic/vrac Clojureverse archive: https://clojurians-log.clojureverse.org/vrac
yogthos 2020-08-31T12:46:38.371600Z

another thing to consider would be how the state of the component would be controlled, for example whether it's visible, disabled, etc. based on the state of the data in the db

yogthos 2020-08-31T12:46:46.371800Z

but otherwise seems comprehensive

2020-08-31T23:45:55.372Z

2020-08-31T23:51:35.375800Z

@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.

yogthos 2020-08-31T23:54:23.377100Z

ah ok yeah I was referring to html nodes, and doing it the same way as value makes sense

yogthos 2020-08-31T23:54:56.377900Z

you would need to differentiate between static and dynamic nodes somehow potentially

yogthos 2020-08-31T23:55:25.378900Z

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

2020-08-31T23:55:27.379Z

(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])}]]))

yogthos 2020-08-31T23:55:47.379400Z

ok yeah that's exactly what I was thinking

1👍
2020-08-31T23:59:45.381800Z

(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.