(ns com.oly.static-sites.clojure-demos.components
  (:require
   [com.oly.static-sites.clojure-demos.state :refer [site-state]]
   [com.oly.static-sites.clojure-demos.helpers :refer [copy->clipboard slugify]]))

(defn notification []
  (if  (-> @site-state :notification)
    [:div.fixed.p-5.top-20.right-0.border-2.border-sky-400.bg-white.opacity-100.transition-opacity.delay-150.duration-200
     (-> @site-state :notification)]
    [:<>]))

(defn header-on-click-copy-link [v]
  {:on-click (fn [] (copy->clipboard (slugify v)))})

(defn header-lvl1 [v _]
  [:h1.text-2xl.fw6.lh-title.mt-0.mb-2 {:id (slugify v)}
   [:a {:name (slugify v)} [:i.fa-solid.fa-link (header-on-click-copy-link v)] v]])

(defn header-lvl2 [v _]
  [:h2.text-xl.fw6.lh-title.mt-0.mb-2 {:id (slugify v)}
   [:a {:name (slugify v)} [:i.fa-solid.fa-link (header-on-click-copy-link v)] v]])

(defn header-lvl3 [v _]
  [:h3.text-base.fw6.lh-title.mt-0.mb-2 {:id (slugify v)}
   [:a {:name (slugify v)} [:i.fa-solid.fa-link (header-on-click-copy-link v)] v]])
