File tree Expand file tree Collapse file tree 6 files changed +78
-14
lines changed
resources/public/examples/basic Expand file tree Collapse file tree 6 files changed +78
-14
lines changed Original file line number Diff line number Diff line change 1
- (defproject org.clojars.intception /om-widgets " 0.3.22 "
1
+ (defproject org.clojars.intception /om-widgets " 0.3.23 "
2
2
:description " Widgets for OM/React"
3
3
:url " https://github.com/orgs/intception/"
4
4
:license {:name " Eclipse Public License"
Original file line number Diff line number Diff line change 21
21
< meta name ="theme-color " content ="#ffffff ">
22
22
23
23
< link href ="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css " rel ="stylesheet ">
24
- < link href ="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css " rel ="stylesheet ">
25
24
< link href ="css/datepicker.css " rel ="stylesheet ">
26
25
< link href ="css/om-widgets-base.css " rel ="stylesheet ">
27
26
Original file line number Diff line number Diff line change 1
1
(ns examples.basic.core
2
2
(:require [om.core :as om :include-macros true ]
3
- [om.dom :as dom :include-macros true ]
4
- [om-widgets.layouts :as layout :include-macros true ]
5
3
[om-widgets.core :as w]
6
- [om-widgets.navbar :as navbar]
7
- [sablono.core :as html :refer-macros [html]]
8
- [om-widgets.grid :refer [row-builder]]
4
+ [sablono.core :refer-macros [html]]
9
5
[examples.basic.state-example :as state]
10
6
[examples.basic.tab-example :refer [tab-example]]
11
7
[examples.basic.form-example :refer [form-example]]
Original file line number Diff line number Diff line change 14
14
om/IRenderState
15
15
(render-state [this state]
16
16
(html
17
- [:div.panel.panel-default
18
- [:div.panel-heading " Form" ]
19
- [:div.panel-body
20
- [:form
17
+ [:div.panel.sdsdpanel-default
18
+ [:div.sdpanel-body.row
19
+ [:div.form-group.col-lg-3 ]
20
+ [:form.col-lg-6
21
+
21
22
[:div.form-group
22
23
[:label " Name" ]
23
24
(w/textinput app :name {:input-class " form-control"
110
111
:checked-value true
111
112
:unchecked-value false })]
112
113
114
+ [:div.form-group
115
+ [:label " Switcher" ]
116
+ [:br ]
117
+ (w/switcher app :some-switch {:options [{:value 1 :text " 1" }
118
+ {:value 2 :text " 2" }
119
+ {:value 3 :text " 3" }]})]
113
120
114
121
[:div.form-group
115
122
[:label " Checks - Toggle values on Sets" ]
Original file line number Diff line number Diff line change 1
1
(ns om-widgets.core
2
- (:require [om.core :as om :include-macros true ]
3
- [om.dom :as dom :include-macros true ]
4
- [om-widgets.textinput]
2
+ (:require [om-widgets.textinput]
5
3
[om-widgets.checkbox]
6
4
[om-widgets.dropdown]
7
5
[om-widgets.navbar]
15
13
[om-widgets.page-switcher]
16
14
[om-widgets.popover]
17
15
[om-widgets.slider]
16
+ [om-widgets.switcher]
18
17
[om-widgets.editable-list-view]
19
18
[om-widgets.utils]))
20
19
25
24
(def datepicker om-widgets.datepicker /datepicker )
26
25
(def radiobutton om-widgets.radiobutton /radiobutton )
27
26
(def radiobutton-group om-widgets.radiobutton /radiobutton-group )
27
+ (def switcher om-widgets.switcher /switch )
28
28
(def combobox om-widgets.combobox /combobox )
29
29
(def button om-widgets.button /button )
30
30
(def grid om-widgets.grid /grid )
Original file line number Diff line number Diff line change
1
+ (ns om-widgets.switcher
2
+ (:require [om.core :as om :include-macros true ]
3
+ [om.dom :as dom :include-macros true ]
4
+ [schema.core :as s :include-macros true ]
5
+ [sablono.core :as html :refer-macros [html]]
6
+ [cljs.core.async :refer [put! chan <! alts! timeout close!]]
7
+ [om-widgets.utils :as utils]))
8
+
9
+
10
+ (defn- build-label-class [cursor cursor-path value]
11
+ (str " btn btn-default" (when (= (get-in cursor [cursor-path]) value) " active" )))
12
+
13
+ (defn item
14
+ [cursor owner]
15
+ (reify
16
+ om/IRenderState
17
+ (render-state
18
+ [this {:keys [value text cursor-path channel] :as state}]
19
+ (html
20
+ [:label {:class (build-label-class cursor cursor-path value)}
21
+ [:input {:type " radio"
22
+ :key text
23
+ :onChange (fn [e]
24
+ (when channel
25
+ (put! channel value))
26
+ (om/update! cursor cursor-path value))}
27
+ text]]))))
28
+
29
+ (defn switcher
30
+ [cursor owner]
31
+ (reify
32
+ om/IRenderState
33
+ (render-state
34
+ [this {:keys [options cursor-path channel classes] :as state}]
35
+ (html
36
+ (utils/make-childs [:div {:class [" btn-group" (or classes " " )]
37
+ :data-toggle " buttons" }]
38
+ (map #(om/build item
39
+ cursor
40
+ {:state {:value (:value %)
41
+ :text (:text %)
42
+ :channel channel
43
+ :cursor-path cursor-path}})
44
+ options))))))
45
+
46
+ ; ; ---------------------------------------------------------------------
47
+ ; ; Schema
48
+
49
+ (def OptionsSchema
50
+ [{:value s/Any
51
+ :text s/Str}])
52
+
53
+ ; ; ---------------------------------------------------------------------
54
+ ; ; Public
55
+
56
+ (defn switch
57
+ [cursor cursor-path {:keys [options channel classes]}]
58
+ (s/validate OptionsSchema options)
59
+ (om/build switcher cursor {:state {:cursor-path cursor-path
60
+ :options options
61
+ :classes classes
62
+ :channel channel}}))
You can’t perform that action at this time.
0 commit comments