-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathform_example.cljs
More file actions
151 lines (130 loc) · 6.53 KB
/
form_example.cljs
File metadata and controls
151 lines (130 loc) · 6.53 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
(ns examples.basic.form-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 form-example
[app owner]
(reify
om/IDisplayName
(display-name[_] "FormSample")
om/IRenderState
(render-state [this state]
(html
[:div.panel.panel-default
[:div.panel-body.row
[:div.form-group.col-lg-3]
[:form.col-lg-6
[:div.form-group
[:label "Name"]
(w/textinput app :name {:input-class "form-control"
:autofocus true
:tabIndex 1
:placeholder "Your name"})]
[:div.form-group
[:label "How old are you?"]
(w/textinput app :age {:input-class "form-control"
:autofocus true
:tabIndex 2
:input-format "numeric"
:pattern "[0-9]"
:min "18"
:max "100"
:align "left"
:placeholder "Adults only! (older than 18 years-old)"})]
[:div.form-group
[:label "Decimal are supported too"]
(w/textinput app :decimal {:input-class "form-control"
:autofocus true
:input-format "numeric"
:step "0.1"
:align "left"
:placeholder "Enter a decimal number"})]
[:div.form-group
[:label "Email"]
(w/textinput app :email {:input-class "form-control"
:tabIndex 3
:placeholder "hello@domain.com"})]
[:div.form-group
[:label "How much hours do you work? (4-12)"]
(w/slider app :hours {:step "1"
:min "4"
:max "12"})
[:label (:hours app)]]
[:div.form-group
[:label "Birth Date"]
(w/textinput app :birth-date {:input-class "form-control"
:input-format "date"
:tabIndex 4
:placeholder "MM/DD/YYYY"})]
[:div.form-group
[:label "Sex"]
(w/radiobutton-group app :sex {:class-name "some-container-class"
:label-class "some-label-class"
:options [{:label " Male"
:checked-value :male}
{:label " Female"
:checked-value :female}]})]
[:div.form-group
[:label "Describe yourself:"]
(w/textinput app :description {:input-class "form-control"
:tabIndex 5
:multiline true
:resize :vertical
:placeholder "A short description of yourself"})]
[:div.form-group
[:label "Marital Status"]
(w/combobox app :marital-status
{:tabIndex 6
:class-name "form-control"
:options (sorted-map :single "Single"
:married "Married"
:divorced "Divorced"
:widowed "Widowed")})]
[:div.form-group
[:label "Favorite Food"]
(w/combobox app :favorite-food
{:tabIndex 7
:class-name "form-control"
:options {"Dairy products" {:cheese "Cheese"
:egg "Egg"}
"Vegetables" {:cabbage "Cabbage"
:lettuce "Lettuce"
:beans "Beans"
:onions "Onions"
:courgettes "Courgettes"}}})]
[:div.form-group
[:label "Password"]
(w/textinput app :password {:input-class "form-control"
:tabIndex 7
:flush-on-enter true
:onEnter #(println "enter pressed!")
:input-format "password"})]
[:div.form-group
[:label "Checkbox"]
(w/checkbox app :some-check {:label " Some Checkbox (Boolean)"
:title "Some tooltip"
:checked-value true
:unchecked-value false})]
[:div.form-group
[:label "Switcher"]
[:br]
(w/switcher app :some-switch {:options [{:value 1 :text "1"}
{:value 2 :text "2"}
{:value 3 :text "3"}]})]
[:div.form-group
[:label "Checks - Toggle values on Sets"]
(w/checkbox app :some-set {:label "check some values (keyword)"
:id "some-value-set"
:checked-value :some-value
:toggle-value true})
(w/checkbox app :some-set {:label "check some values (keyword)"
:id "some-other-value-set"
:checked-value :other-value
:toggle-value true})]
[:button.btn.btn-default {:type "submit"
:tabIndex 8 } "Submit"]
[:hr]
[:div.form-group
[:label "Cursor:"]
[:p.form-control-static (pr-str app)]]]]]))))