Skip to content

Commit

Permalink
bugfix option-ui2
Browse files Browse the repository at this point in the history
  • Loading branch information
awb99 committed Dec 23, 2024
1 parent 133bf7d commit 7e6fc1f
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/options/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
(defn get-editor [t]
(or (get @editors t) editor-view))

(defn create-edit-element [{:keys [set-fn get-fn]} {:keys [path name type] :as options}]
(defn create-edit-element [{:keys [state set-fn get-fn]} {:keys [path name type] :as options}]
(let [editor (get-editor type)]
(if (= type :label)
; label only
Expand All @@ -39,24 +39,27 @@
:display "inline-block"}}

name] ; <label for= "pet-select" >Choose a pet:</label>
[editor {:set-fn (partial set-fn path)
[editor {:set-fn (partial set-fn state path)
:options options}
(get-fn path)]])))
(get-fn @state path)]])))

(defn options-ui2 [{:keys [class style
edit
state
set-fn
get-fn]
:or {set-fn (fn [path v]
;(println "setting " path " to: " v)
(swap! state assoc path v))
get-fn (fn [path]
(get @state path))}}]
get-fn]}]
(let [set-fn (or set-fn
(fn [path v]
;(println "setting " path " to: " v)
(swap! state assoc path v)))
get-fn (or get-fn
(fn [state-val path]
(get state-val path)))]
(into [:div {:style style
:class class}]
(map #(create-edit-element {:set-fn set-fn
:get-fn get-fn} %) edit)))
(map #(create-edit-element {:state state
:set-fn set-fn
:get-fn get-fn} %) edit))))

(defn options-ui [{:keys [class style]} ; styling
{:keys [current state options]
Expand Down

0 comments on commit 7e6fc1f

Please sign in to comment.