Add green gradient background for the 8 cheapest hours
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -58,11 +58,15 @@
|
||||
["bg-red-50" "bg-red-100" "bg-red-200" "bg-red-300"
|
||||
"bg-red-400" "bg-red-500" "bg-red-600" "bg-red-700"])
|
||||
|
||||
(def ^:private green-gradient
|
||||
["bg-green-700" "bg-green-600" "bg-green-500" "bg-green-400"
|
||||
"bg-green-300" "bg-green-200" "bg-green-100" "bg-green-50"])
|
||||
|
||||
(defn- rank-bg [rank total]
|
||||
(let [top-start (inc (- total 8))
|
||||
pos (- rank top-start)]
|
||||
(when (>= pos 0)
|
||||
(get red-gradient pos))))
|
||||
(cond
|
||||
(<= rank 8) (get green-gradient (dec rank))
|
||||
(> rank (- total 8)) (get red-gradient (- rank (- total 7)))
|
||||
:else nil))
|
||||
|
||||
(defn- hour-block [hour quarters rank total-hours]
|
||||
(let [sorted (sort-by #(.getMinute (->ldt (:time_dk %))) quarters)
|
||||
@@ -70,16 +74,16 @@
|
||||
month (.getMonthValue (->ldt (:time_dk (first quarters))))
|
||||
tariff (tariffs/tariff-for-hour month hour)
|
||||
bg (rank-bg rank total-hours)
|
||||
dark? (and bg (>= rank (- total-hours 3)))]
|
||||
dark? (and bg (or (<= rank 4) (>= rank (- total-hours 3))))]
|
||||
[:details {:class (str "border-2 border-blue-400 rounded-lg mb-2 " bg)}
|
||||
[:summary {:class (str "flex justify-between py-2 px-3 cursor-pointer font-medium "
|
||||
(if dark? "text-white" "text-gray-900"))}
|
||||
[:span (format "%02d:00" hour)]
|
||||
[:span {:class (str "text-sm " (if dark? "text-red-100" "text-gray-500"))} (str "#" rank)]
|
||||
[:span {:class (str "text-sm " (if dark? "text-white/80" "text-gray-500"))} (str "#" rank)]
|
||||
[:span {:class "font-mono"}
|
||||
(if avg (format "%.1f(%.1f)" (+ avg tariff) avg) "-")]]
|
||||
[:div {:class (str "border-t-2 border-blue-400 px-3 pb-2 "
|
||||
(if dark? "text-red-100" "text-gray-500"))}
|
||||
(if dark? "text-white/80" "text-gray-500"))}
|
||||
(for [q sorted]
|
||||
[:div {:class "flex justify-between py-1 ml-4"}
|
||||
[:span (format "%02d:%02d" hour (.getMinute (->ldt (:time_dk q))))]
|
||||
|
||||
Reference in New Issue
Block a user