improved two major forms.

This commit is contained in:
2022-07-19 15:10:33 -07:00
parent 483e9ad311
commit 0baab4eaf0
14 changed files with 431 additions and 355 deletions

View 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])]]])