summaryrefslogtreecommitdiff
path: root/src/aome/core.cljs
blob: a4cb41f6d6e29a34a59fd295aac90d13ef979e44 (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
33
34
35
36
37
38
39
40
(ns aome.core
  (:require [reagent.core :as r]
            [reagent.dom.client :as rdclient]
            [aome.org-file :as aorg-file]))

(defn header []
  [:fieldset
   [:div {:class ["field" "label" "border" "small"] :style {:display :inline-block :margin-top :auto}}
    [:input {:type :text :placeholder " " :value @aorg-file/current-file-name
             :on-change #(reset! aorg-file/current-file-name (.. % -target -value))}]
    [:label "File name"]]
   [:div {:class ["field" "label" "suffix" "border" "small"] :style {:width :fit-content :display :inline-block :margin-top :auto}}
    [:select {:on-change #(reset! aorg-file/current-file-extension (.. % -target -value))}
     [:option {:selected (= @aorg-file/current-file-extension ".org")} ".org"]
     [:option {:selected (= @aorg-file/current-file-extension ".org.gpg")} ".org.gpg"]]
    [:label "File extension"]
    [:i "arrow_drop_down"]]
   [:button {:class ["responsive" "border"] :style {:display :inline-block :width :fit-content} :on-click aorg-file/save-to-file-picker!}
    [:i "save"]
    [:span "Save"]]
   [:button {:class ["responsive" "border"] :style {:width :fit-content} :on-click aorg-file/load-from-file-picker!}
    [:i "file_open"]
    [:span "Read file"]]])

(defn editor []
  [:textarea {:style {:resize :none :width "100%" :height "50em"}
              :on-change #(reset! aorg-file/content (.. % -target -value))
              :value @aorg-file/content}])

(defn render []
  [:div
   [header]
   [editor]])

(defn init! []
  (-> js/document
      (.getElementById "app")
      rdclient/create-root
      (rdclient/render [render])))