improved two major forms.
This commit is contained in:
34
src/cljs/auto_ap/views/components.cljs
Normal file
34
src/cljs/auto_ap/views/components.cljs
Normal file
@@ -0,0 +1,34 @@
|
||||
(ns auto-ap.views.components
|
||||
(:require [reagent.core :as r]
|
||||
[clojure.string :as str]))
|
||||
|
||||
|
||||
(defn checkbox [{:keys [on-change
|
||||
value
|
||||
label]
|
||||
:as props}]
|
||||
(into [:label.checkbox
|
||||
[:input (-> props
|
||||
(assoc
|
||||
:type "checkbox"
|
||||
:on-change (fn []
|
||||
(on-change (not value)))
|
||||
:checked value)
|
||||
(dissoc :value))]
|
||||
" " label
|
||||
]
|
||||
(r/children (r/current-component))))
|
||||
|
||||
(defn select-field [{:keys [options allow-nil? class] :as props}]
|
||||
[:div.select {:class class}
|
||||
[:select (-> props
|
||||
(dissoc :allow-nil? :class :options)
|
||||
(update :value (fn [v]
|
||||
(if (str/blank? v)
|
||||
""
|
||||
v))))
|
||||
[:<>
|
||||
(when allow-nil?
|
||||
[:option {:value nil}])
|
||||
(for [[k v] options]
|
||||
^{:key k} [:option {:value k} v])]]])
|
||||
Reference in New Issue
Block a user