aboutsummaryrefslogtreecommitdiff
path: root/src/cashflow/frontend/utils.clj
blob: 25091a64805017537d129f083cd71e9018214137 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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") "€"))])