/
dropdown_example.cljs
85 lines (73 loc) · 3.2 KB
/
dropdown_example.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
(ns examples.basic.dropdown-example
(:require [om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]
[sablono.core :as html :refer-macros [html]]
[om-widgets.core :as w]))
(defn dropdown-example
[cursor owner]
(reify
om/IRenderState
(render-state [this state]
(html
[:div.panel.panel-default
[:div.panel-heading (str "Selected cursor value: " (get-in cursor [:selected-dropdown]))]
[:div.panel-body
;; ---------------------------------------------------------------------
;; Sizes
(w/dropdown cursor
{:id :testing
:title "Small Dropdown Button"
:korks [:selected-dropdown]
:size :sm
:items (get-in cursor [:default])}) [:hr]
(w/dropdown cursor
{:id :testing
:title "Normal with URLS"
:korks [:selected-dropdown]
:items (get-in cursor [:urls])}) [:hr]
;; ---------------------------------------------------------------------
;; Callback
(w/dropdown cursor
{:id :testing
:title "on-selection Callback"
:on-selection #(.alert js/window (str "Selected value: " %))
:items (get-in cursor [:urls])}) [:hr]
;; ---------------------------------------------------------------------
;; Disabled
(w/dropdown cursor
{:id :testing
:title "Disabled entries"
:korks [:selected-dropdown]
:items (get-in cursor [:disabled])}) [:hr]
;; ---------------------------------------------------------------------
;; Dividers
(w/dropdown cursor
{:id :testing
:title "With Dividers"
:korks [:selected-dropdown]
:items (get-in cursor [:dividers])}) [:hr]
;; ---------------------------------------------------------------------
;; Links
(w/dropdown cursor
{:id :testing
:title "Dropdown Link"
:as-link? true
:korks [:selected-dropdown]
:size :sm
:items (get-in cursor [:default])}) [:hr]
;; ---------------------------------------------------------------------
;; Badges
(w/dropdown cursor
{:id :testing
:title "With badge"
:badge 10
:korks [:selected-dropdown]
:items (get-in cursor [:default])}) [:hr]
;; ---------------------------------------------------------------------
;; Icons
(w/dropdown cursor
{:id :testing
:title "With icon"
:icon :calendar
:korks [:selected-dropdown]
:items (get-in cursor [:default])})]]))))