Skip to content

Commit 83f40d3

Browse files
committed
Fix dropdown/navbar markup
1 parent fccab3e commit 83f40d3

File tree

2 files changed

+34
-27
lines changed

2 files changed

+34
-27
lines changed

‎src/om_widgets/dropdown.cljs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
om/IRenderState
114114
(render-state [_ {:keys [title items icon badge channel] :as state}]
115115
(html
116-
[:div (build-dropdown-js-options state)
116+
[:li (build-dropdown-js-options state)
117117
[:a (-> {:class "dropdown-toggle"}
118118
(th/when-> (string? title)
119119
(merge {:title title})))
@@ -139,10 +139,10 @@
139139
(will-mount [_] (channel-processing cursor owner))
140140

141141
om/IRenderState
142-
(render-state [_ {:keys [title as-link? icon badge items channel] :as state}]
142+
(render-state [_ {:keys [title as-link? icon badge items channel class-name] :as state}]
143143
(let [title (str (when icon " ") title " ")]
144144
(html
145-
[:div (build-dropdown-js-options state)
145+
[:li (build-dropdown-js-options state)
146146
(if as-link?
147147
[:a.btn-link
148148
(when icon [:span {:class icon}])

‎src/om_widgets/navbar.cljs

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,43 +28,50 @@
2828
om/IRenderState
2929
(render-state [_ {:keys [channel on-selection active-path]}]
3030
(html
31-
[:li {:class [(when (= (get-in cursor [active-path])
32-
(:id entry))
33-
"active")]}
3431

3532
(if (:items entry)
3633
(dropdown cursor (->> {:id (:id entry)
3734
:type :menu
3835
:icon (:icon entry)
3936
:title (:text entry)
37+
:className (if (= (get-in cursor [active-path])
38+
(:id entry))
39+
"active"
40+
"")
4041
:on-selection (fn [v]
4142
(on-selection v)
4243
(when (om/get-state owner :collapsed?)
4344
(put! channel :toggle-menu)))
4445
:items (:items entry)}
4546
(th/when->> (:className entry)
4647
(merge {:className (:className entry)}))))
47-
[:a (->> {}
48-
(th/when->> (:className entry)
49-
(merge {:className (:className entry)}))
50-
(th/when->> (:url entry)
51-
(merge {:href (:url entry)}))
52-
(th/when->> on-selection
53-
(merge {:onClick (fn [e]
54-
(on-selection (:id @entry))
55-
(when (om/get-state owner :collapsed?)
56-
(put! channel :toggle-menu)))})))
57-
58-
(when (or (:iconClassName entry) (:icon entry))
59-
[:span {:class (or (:iconClassName entry)
60-
(u/glyph (:icon entry)))}])
61-
62-
(if (fn? (:text entry))
63-
((:text entry))
64-
[:span (:text entry)])
65-
66-
(when (:badge entry)
67-
[:span.badge (:badge entry)])])]))))
48+
49+
50+
[:li {:class [(when (= (get-in cursor [active-path])
51+
(:id entry))
52+
"active")]}
53+
[:a (->> {}
54+
(th/when->> (:className entry)
55+
(merge {:className (:className entry)}))
56+
(th/when->> (:url entry)
57+
(merge {:href (:url entry)}))
58+
(th/when->> on-selection
59+
(merge {:onClick (fn [e]
60+
(on-selection (:id @entry))
61+
(when (om/get-state owner :collapsed?)
62+
(put! channel :toggle-menu)))})))
63+
64+
(when (or (:iconClassName entry) (:icon entry))
65+
[:span {:class (or (:iconClassName entry)
66+
(u/glyph (:icon entry)))}])
67+
68+
(if (fn? (:text entry))
69+
((:text entry))
70+
[:span (:text entry)])
71+
72+
(when (:badge entry)
73+
[:span.badge (:badge entry)])]])))))
74+
6875

6976
(defn- navbar-nav
7077
[{:keys [cursor entries]} owner]

0 commit comments

Comments
 (0)