~sjm/redwood

ref: 8739a8f9f85d3ee990c60f9a5457c9ac534ada1e redwood/src/redwood/core.cljs -rw-r--r-- 1.6 KiB
8739a8f9Sam Marshall add timestamped journal 10 months ago
                                                                                
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
(ns redwood.core
  (:require [reagent.core :as r]
            [reagent.dom :as rd]
            [re-frame.core :as rf]
            [cljs-time.core :as t]
            [akiroz.re-frame.storage :refer [reg-co-fx!]]
            [redwood.data.app :as app]
            [redwood.data.time :as dt]
            [redwood.events :as e]
            [redwood.styles :as st]
            [redwood.queries :as q]
            [redwood.components.journal.add-entry :refer [add-entry]]
            [redwood.components.journal.display :refer [display-journal]]
            [redwood.components.date :refer [date]]
            [redwood.components.top-bar :refer [top-bar]]
            [redwood.components.top-bar.set-date :refer [set-date]]
            [redwood.components.clock :refer [clock]]))

(defn root []
  [:div {:style {:font-family "'Roboto Mono', monospace"}}
   [top-bar]
   [:div
    {:style {:display "grid"
             :grid-template-columns "2fr 1fr 2fr"}}
    [date]]
   [:div
    {:style {:display "grid"
             :font-size 64
             :grid-template-columns "3fr 1fr 3fr"}}
    [clock]
    [:div {:style (merge
                    st/all-center
                    {:grid-column 3
                     :text-decoration "underline"
                     :font-size 16
                     :color "blue"})}

     [:p {:style {:cursor "pointer"} 
          :on-click #(rf/dispatch [::e/add-time (t/seconds 30)])}
      "30s"]]]
   [add-entry]
   [display-journal]])
   

(reg-co-fx!
  :redwood
  {:fx :store
   :cofx :store})

(defn main
  []
  (rf/dispatch-sync [::e/init])
  (rd/render [root]
             (.getElementById js/document "app")))