Files
integreat/src/clj/auto_ap/ssr/components/inputs.clj
2023-05-11 09:43:37 -07:00

25 lines
1.1 KiB
Clojure

(ns auto-ap.ssr.components.inputs)
(defn select- [params & children]
(into
[:select {:class "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
:name (:name params)}
(cond->>
(map (fn [[k v]]
[:option {:value k :selected (= v (:value params))} v])
(:options params))
(:allow-blank? params) (conj [:option {:value "" :selected (not (:value params))} ""]))]
children))
(defn text-input- [params]
[:input
(update params
:class str " bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500")
])
(defn field- [params & rest]
(into
[:div
[:label {:class "block mb-2 text-sm font-medium text-gray-900 dark:text-white"} (:label params)]]
rest))