(ns auto-ap.ssr.components.card
  (:require [auto-ap.ssr.hiccup-helper :as hh]
            [auto-ap.ssr.hx :as hx]
            [clojure.string :as str]))

(defn card- [params & children]
  (into [:div (update params :class 
                      #(cond-> (or % "")
                         (not (str/includes? (or % "") "bg-")) (hh/add-class "dark:bg-gray-800 bg-white ")
                         true (hh/add-class "shadow-md sm:rounded-lg border-2 border-gray-200 dark:border-gray-900 overflow-hidden")))]
        children))

(defn content-card- [params & children]
  [:section (merge params {:class (hh/add-class " py-3 sm:py-5" (:class params))})
   [:div {:class (:max-w params "max-w-screen-2xl")}
    (into 
      [:div {:class "relative overflow-scroll shadow-md dark:bg-gray-800 sm:rounded-lg border-2 border-gray-200 dark:border-gray-900 bg-white"}]
      children)]])
