1
+ (ns kii.ui.conf.components.manage-animations
2
+ (:require [reagent.core :as r]
3
+ [taoensso.timbre :as timbre :refer-macros [log logf]]
4
+ [kii.ui.re-frame :refer [<<= <== =>> >=>]]
5
+ [cljs-react-material-ui.reagent :as mui]
6
+ [cljs-react-material-ui.icons :as mui-icons]
7
+ [cuerdas.core :as str]
8
+ [kii.util :as util]
9
+ ))
10
+
11
+ (defn alter-settings
12
+ [setting f]
13
+ (as-> setting x
14
+ (str/split x " ," )
15
+ (f x)
16
+ (str/join " ," x)))
17
+
18
+ (defn manage-animations
19
+ []
20
+ (let [animations (<<= [:conf/animations ])]
21
+ [:div
22
+ [:h3 " Manage Visualizations" ]
23
+ [mui/table {:selectable false
24
+ :wrapper-style {:margin-right " 20px" }
25
+ }
26
+ [mui/table-header {:display-select-all false
27
+ :adjust-for-checkbox false }
28
+ [mui/table-row
29
+ [mui/table-header-column " Name" ]
30
+ [mui/table-header-column " Auto-start?" ]
31
+ [mui/table-header-column " Actions" ]
32
+ ]
33
+ ]
34
+ [mui/table-body {:display-row-checkbox false }
35
+ (for [[key animation] (seq animations)]
36
+ ^{:key key}
37
+ [mui/table-row
38
+ [mui/table-row-column (name key)]
39
+ [mui/table-row-column
40
+ [mui/toggle
41
+ {:default-toggled (str/includes? (:settings animation) " start" )
42
+ :disabled (= " reaction" (:type animation))
43
+ :on-toggle (fn [_ toggled]
44
+ (>=> [:conf/partial-update-animation
45
+ {:settings (alter-settings
46
+ (:settings animation)
47
+ (if toggled
48
+ #(conj % " start" )
49
+ (fn [x] (filter #(not= (str/trim %) " start" ) x))))}
50
+ key])
51
+ )
52
+ }]
53
+ ]
54
+ [mui/table-row-column
55
+ [mui/icon-button
56
+ {:on-click #(>=> [:conf/delete-animation key])}
57
+ [mui-icons/action-delete
58
+ {:color " gray"
59
+ :hover-color " black" }
60
+ ]
61
+ ]
62
+ ]
63
+ ]
64
+ )]]
65
+ ]))
0 commit comments