aboutsummaryrefslogtreecommitdiff
path: root/src/cashflow/frontend/utils.clj
diff options
context:
space:
mode:
Diffstat (limited to 'src/cashflow/frontend/utils.clj')
-rw-r--r--src/cashflow/frontend/utils.clj32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/cashflow/frontend/utils.clj b/src/cashflow/frontend/utils.clj
new file mode 100644
index 0000000..25091a6
--- /dev/null
+++ b/src/cashflow/frontend/utils.clj
@@ -0,0 +1,32 @@
+(ns cashflow.frontend.utils
+ (:require [hiccup2.core :as html]
+ [dotenv :as env]))
+
+(defn render-component [component]
+ (-> component
+ html/html
+ str))
+
+(defn render-page [title & body]
+ (-> [:html
+ [:head
+ [:meta {:name "viewport" :content "width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"}]
+ [:meta {:charset "UTF-8"}]
+ [:title title]
+ [:link {:rel "stylesheet" :href "/static/style.css"}]
+ [:link {:rel "stylesheet" :href "/static/beer.css"}]
+ [:meta {:name "robots" :content "noindex,nofollow"}]]
+ (apply conj [:body] body [[:script {:src "/static/beer.js"}]
+ [:script {:src "/static/htmx.js"}]
+ [:script {:src "/static/hyperscript.js"}]])]
+ render-component))
+
+(defn render-amount [amount]
+ [:p {:style {:color (cond
+ (pos? amount) :limegreen
+ (neg? amount) :red
+ :else :orange)}}
+ (str (when (pos? amount) "+")
+ amount
+ (or (env/env "CONCURRENCY") "€"))])
+