(ns auto-ap.ssr.components.tags
  (:require [auto-ap.ssr.hiccup-helper :as hh]))


(defn pill- [params & children]
  (into
   [:span (cond-> params
            true (update :class str "  text-xs font-medium px-2 py-0.5 rounded whitespace-nowrap")

            (= :primary (:color params))
            (update :class str " bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-300 ")

            (= :secondary (:color params))
            (update :class str " bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300 ")

            (= :yellow (:color params))
            (update :class str " bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300")

            (= :red (:color params))
            (update :class str " bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-300"))]
   children))

(defn badge- [params & children]
  [:div (merge params {:class (-> (hh/add-class "absolute inline-flex items-center justify-center w-6 h-6 text-xs font-black text-white 
                               border-3 border-white rounded-full -top-2 -right-2 dark:border-gray-900"
                                                (:class params)
                                                )
                                  (hh/add-class (or (some-> (:color params) (#(str "bg-" % "-300")))
                                                    "bg-red-300")))}) children])
