This commit is contained in:
2023-09-28 22:24:27 -07:00
11 changed files with 183 additions and 48 deletions

View File

@@ -4,12 +4,92 @@
(defn button-icon- [_ i]
[:div.h-4.w-4 i])
(defn bg-colors [color disabled]
(let [base-color (cond (= :primary color)
"green"
(= :secondary color)
"blue"
(nil? color)
"white"
:else
color)
disabled-weight (when disabled 400)]
(format " bg-%s-%d hover:bg-%s-%d focus:ring-%s-%d dark:bg-%s-%d dark:hover:bg-%s-%d "
base-color
(or disabled-weight 500)
base-color
(or disabled-weight 600)
base-color
(or disabled-weight 200)
base-color
(or disabled-weight 600)
base-color
(or disabled-weight 700)
)))
(defn dark-color-weight [disabled]
(if disabled
400
600))
(defn hover-color-weight [disabled]
(if disabled
400
600))
(for [color ["green" "blue" "white"]
weight (range 100 900 100)]
(str "bg-" color "-" weight))
;;ensuring these colors show up
;; => ("bg-green-100"
;; "bg-green-200"
;; "bg-green-300"
;; "bg-green-400"
;; "bg-green-500"
;; "bg-green-600"
;; "bg-green-700"
;; "bg-green-800"
;; "bg-blue-100"
;; "bg-blue-200"
;; "bg-blue-300"
;; "bg-blue-400"
;; "bg-blue-500"
;; "bg-blue-600"
;; "bg-blue-700"
;; "bg-blue-800"
;; "bg-white-100"
;; "bg-white-200"
;; "bg-white-300"
;; "bg-white-400"
;; "bg-white-500"
;; "bg-white-600"
;; "bg-white-700"
;; "bg-white-800")
(defn button- [params & children]
[:button (update params
:class #(cond-> %
true (str " focus:ring-4 font-bold rounded-lg text-xs p-3 text-center mr-2 inline-flex items-center hover:scale-105 transition duration-100 justify-center")
(= :secondary (:color params)) (str " text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700")
(= :primary (:color params)) (str " text-white bg-green-500 hover:bg-green-600 focus:ring-green-300 dark:bg-green-600 dark:hover:bg-green-700 ")
true (str " focus:ring-4 font-bold rounded-lg text-xs p-3 text-center mr-2 inline-flex items-center justify-center"
(bg-colors (:color params) (:disabled params)))
(not (:disabled params))
(str " hover:scale-105 transition duration-100")
(:disabled params)
(str " cursor-not-allowed")
(not (nil? (:color params)))
(str " text-white ")
(nil? (:color params))
(str " bg-white dark:bg-gray-600 border-gray-300 dark:border-gray-700 text-gray-500 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-100 font-medium border border-gray-300 dark:border-gray-700")))
[:div.htmx-indicator.flex.items-center