File tree 3 files changed +34
-22
lines changed
3 files changed +34
-22
lines changed Original file line number Diff line number Diff line change 13
13
:pet :hamster
14
14
; bool
15
15
:run-parallel true
16
- :debug? false
16
+ :environment { :enabled true }
17
17
; string
18
18
:search " "
19
19
; view
38
38
:name " RunParallel?"
39
39
:spec :bool
40
40
:class " pt-0 px-2 py-1 placeholder-gray-400 text-gray-700 relative bg-white rounded text-sm border border-gray-400 outline-none focus:outline-none focus:shadow-outline" }
41
- {:path :debug?
42
- :name " DebugMode "
41
+ {:path [ :environment :enabled ]
42
+ :name " EnvEnabled? "
43
43
:spec :bool }
44
44
{:path :search
45
45
:name " SearchBox"
Original file line number Diff line number Diff line change 1
1
{:name " options"
2
2
; build
3
3
:lazy false
4
-
5
4
:cljs-namespace [options.core
6
5
options.edit]
7
-
8
6
:cljs-ns-bindings {'options.core {'options-ui options.core/options-ui}
9
- 'options.editr {'bool options.edit/bool
10
- 'button options.edit/button
11
- 'select options.edit/select
12
- 'string options.edit/string
13
- 'view options.edit/view}}
14
-
7
+ 'options.edit {'bool options.edit/bool
8
+ 'button options.edit/button
9
+ 'select options.edit/select
10
+ 'string options.edit/string
11
+ 'view options.edit/view}}
15
12
; runtime
16
-
17
13
:theme {:available {:options {true [" options/options.css" ]}}
18
14
:current {:options true }}
19
15
;
Original file line number Diff line number Diff line change 33
33
[:span name] ; <label for= "pet-select" >Choose a pet:</label>
34
34
(get-editor-fn config current-val)]))
35
35
36
+ (defn get-value [state path]
37
+ (cond
38
+ (keyword? path)
39
+ (path @state)
40
+
41
+ (vector? path)
42
+ (get-in @state path)
43
+
44
+ :else
45
+ nil ))
46
+
47
+ (defn set-value [state path v]
48
+ (println " set-value path: " path " value: " v)
49
+ (cond
50
+ (keyword? path)
51
+ (swap! state assoc path v)
52
+
53
+ (vector? path)
54
+ (swap! state assoc-in path v)
55
+
56
+ :else
57
+ nil ))
58
+
36
59
(defn create-edit-element [state options]
37
- (let [kw (:path options)
38
- set-fn (fn [v]
39
- (when kw
40
- (println " setting state for kw: " kw " to val: " v)
41
- (swap! state assoc kw v)))]
42
- [edit-element {:set-fn set-fn
43
- :options options}
44
- (if kw
45
- (kw @state)
46
- nil )]))
60
+ [edit-element {:set-fn #(set-value state (:path options) %)
61
+ :options options}
62
+ (get-value state (:path options))])
47
63
48
64
(defn options-ui [{:keys [class style] :as styling} ; styling
49
65
{:keys [current state options]
You can’t perform that action at this time.
0 commit comments