/
home.cljs
35 lines (31 loc) · 1.04 KB
/
home.cljs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(ns cljs-spa.page.home
(:require
;; See https://github.com/pesterhazy/cljs-spa-example/issues/13
[react-select :refer [default] :rename {default react-select}]
[cljs-spa.state :refer [!state]]))
(def options
[{:value "simplicity" :label "simplicity"}
{:value "immutable data" :label "immutable data"}
{:value "lazy sequences" :label "lazy sequences"}])
(defn selector-ui []
[:> react-select
{:is-multi true
:options (clj->js options)
:on-change (fn [xs] (swap! !state assoc :selection
(->> (js->clj xs :keywordize-keys true)
(map :label)
(into #{}))))}])
(defn result-ui []
[:div
[:h3 "So you like"]
(let [selection (:selection @!state)]
(if (seq selection)
[:div (pr-str selection)]
"Nothing yet"))])
(defn page-ui []
[:div {:style {:max-width 400}}
[:h3 "Home"]
[:div {:style {:margin-top 20,
:margin-bottom 20}} "What do you like?"]
[selector-ui]
[result-ui]])