|
1 | 1 |
|
2 | 2 | {} (:package |app) |
3 | 3 | :configs $ {} (:init-fn |app.main/main!) (:reload-fn |app.main/reload!) |
4 | | - :modules $ [] |respo.calcit/ |lilac/ |memof/ |respo-ui.calcit/ |respo-markdown.calcit/ |reel.calcit/ |
| 4 | + :modules $ [] |respo.calcit/ |lilac/ |memof/ |respo-ui.calcit/ |respo-markdown.calcit/ |reel.calcit/ |respo-router.calcit/ |
5 | 5 | :version |0.0.1 |
6 | 6 | :entries $ {} |
7 | 7 | :files $ {} |
8 | 8 | |app.comp.container $ {} |
9 | 9 | :ns $ quote |
10 | 10 | ns app.comp.container $ :require (respo-ui.core :as ui) |
11 | | - respo.core :refer $ defcomp defeffect <> >> div button textarea span input |
| 11 | + respo-ui.core :refer $ hsl |
| 12 | + respo.core :refer $ defcomp defeffect <> >> div button textarea span input list-> |
12 | 13 | respo.comp.space :refer $ =< |
13 | 14 | reel.comp.reel :refer $ comp-reel |
14 | 15 | respo-md.comp.md :refer $ comp-md |
15 | 16 | app.config :refer $ dev? |
| 17 | + app.schema :refer $ docs |
| 18 | + "\"remarkable" :refer $ Remarkable |
| 19 | + "\"highlight.js" :default hljs |
| 20 | + "\"cirru-color" :as color |
16 | 21 | :defs $ {} |
17 | 22 | |comp-container $ quote |
18 | 23 | defcomp comp-container (reel) |
|
21 | 26 | states $ :states store |
22 | 27 | cursor $ or (:cursor states) ([]) |
23 | 28 | state $ or (:data states) |
24 | | - {} $ :content "\"" |
| 29 | + {} $ :selected ([]) |
25 | 30 | div |
26 | | - {} $ :style (merge ui/global ui/row) |
27 | | - textarea $ {} |
28 | | - :value $ :content state |
29 | | - :placeholder "\"Content" |
30 | | - :style $ merge ui/expand ui/textarea |
31 | | - {} $ :height 320 |
32 | | - :on-input $ fn (e d!) |
33 | | - d! cursor $ assoc state :content (:value e) |
34 | | - =< 8 nil |
35 | | - div |
36 | | - {} $ :style ui/expand |
37 | | - comp-md "|This is some content with `code`" |
38 | | - =< |8px nil |
39 | | - button $ {} (:style ui/button) (:inner-text "\"Run") |
40 | | - :on-click $ fn (e d!) |
41 | | - println $ :content state |
| 31 | + {} (:class-name "\"calcit-tile") |
| 32 | + :style $ merge ui/fullscreen ui/global ui/row |
| 33 | + list-> |
| 34 | + {} $ :style |
| 35 | + merge ui/row $ {} |
| 36 | + :background-color $ hsl 0 0 94 0.8 |
| 37 | + apply-args |
| 38 | + [] |
| 39 | + , docs ([]) (:selected state) |
| 40 | + fn (acc entries base-path selected) |
| 41 | + let |
| 42 | + base-path' base-path $ ; "\"problem in compiling tail recursions" |
| 43 | + next-acc $ conj acc |
| 44 | + [] (count acc) |
| 45 | + comp-sidebar |
| 46 | + >> states $ count acc |
| 47 | + first selected |
| 48 | + , entries $ fn (p d!) |
| 49 | + d! cursor $ assoc state :selected (conj base-path' p) |
| 50 | + if (empty? selected) next-acc $ let |
| 51 | + s0 $ first selected |
| 52 | + target $ find entries |
| 53 | + fn (entry) |
| 54 | + = s0 $ :key entry |
| 55 | + if |
| 56 | + or (nil? target) |
| 57 | + empty? $ get target :children |
| 58 | + , next-acc $ recur next-acc (get target :children) (conj base-path s0) (rest selected) |
| 59 | + let |
| 60 | + target $ find-target docs (:selected state) |
| 61 | + if (some? target) |
| 62 | + div |
| 63 | + {} $ :style |
| 64 | + merge ui/expand $ {} (:padding "\"8px 16px") |
| 65 | + :background-color $ hsl 0 0 100 0.6 |
| 66 | + div $ {} |
| 67 | + :innerHTML $ .!render md (:content target) |
| 68 | + div |
| 69 | + {} $ :style |
| 70 | + merge ui/expand $ {} (:padding "\"20px 16px") |
| 71 | + do $ <> "\"Empty" |
| 72 | + {} (:font-family ui/font-fancy) (:font-style :italic) |
| 73 | + :color $ hsl 0 0 80 |
42 | 74 | when dev? $ comp-reel (>> states :reel) reel ({}) |
| 75 | + |md $ quote |
| 76 | + def md $ new Remarkable |
| 77 | + js-object (:html false) (:breaks true) |
| 78 | + :highlight $ fn (code lang) |
| 79 | + if (= lang "\"cirru") (color/generate code) |
| 80 | + .-value $ .!highlightAuto hljs code lang |
| 81 | + |style-entry $ quote |
| 82 | + def style-entry $ {} (:padding "\"0 8px") (:cursor :pointer) (:transition-duration "\"200ms") (:line-height 2.4) |
| 83 | + :border-bottom $ str "\"1px solid " (hsl 0 0 92) |
| 84 | + :border-left $ str "\"0px solid " (hsl 200 90 60) |
| 85 | + :background-color $ hsl 0 0 100 0.6 |
| 86 | + |comp-sidebar $ quote |
| 87 | + defcomp comp-sidebar (states selected entries on-select) |
| 88 | + let |
| 89 | + cursor $ :cursor states |
| 90 | + state $ or (:data states) |
| 91 | + {} $ :query "\"" |
| 92 | + div |
| 93 | + {} $ :style |
| 94 | + {} (:min-width 200) (:max-width 240) |
| 95 | + :border-right $ str "\"1px solid " (hsl 0 0 94) |
| 96 | + input $ {} |
| 97 | + :style $ merge ui/input |
| 98 | + {} (:width "\"100%") (:border :none) (:line-height 32) (:height 32) |
| 99 | + :border-bottom $ str "\"1px solid " (hsl 0 0 90) |
| 100 | + :placeholder "\"Search..." |
| 101 | + :value $ :query state |
| 102 | + :on-input $ fn (e d!) |
| 103 | + d! cursor $ assoc state :query (:value e) |
| 104 | + list-> ({}) |
| 105 | + -> entries |
| 106 | + filter $ fn (entry) |
| 107 | + if |
| 108 | + blank? $ :query state |
| 109 | + , true $ -> (:title entry) .!toLowerCase |
| 110 | + .includes? $ :query state |
| 111 | + map-indexed $ fn (idx entry) |
| 112 | + [] idx $ div |
| 113 | + {} (:class-name "\"doc-entry") |
| 114 | + :style $ merge style-entry |
| 115 | + if |
| 116 | + = selected $ :key entry |
| 117 | + {} (:background-color :white) |
| 118 | + :border-left $ str "\"10px solid " (hsl 200 90 70) |
| 119 | + :on-click $ fn (e d!) |
| 120 | + on-select (:key entry) d! |
| 121 | + <> $ :title entry |
| 122 | + |find-target $ quote |
| 123 | + defn find-target (entries path) |
| 124 | + if (empty? path) nil $ let |
| 125 | + p0 $ first path |
| 126 | + if-let |
| 127 | + target $ find entries |
| 128 | + fn (entry) |
| 129 | + = p0 $ :key entry |
| 130 | + if |
| 131 | + = 1 $ count path |
| 132 | + , target $ recur (:children target) (rest path) |
| 133 | + w-log nil |
43 | 134 | |app.schema $ {} |
44 | 135 | :ns $ quote (ns app.schema) |
45 | 136 | :defs $ {} |
46 | 137 | |store $ quote |
47 | 138 | def store $ {} |
48 | 139 | :states $ {} |
49 | 140 | :cursor $ [] |
| 141 | + |docs $ quote |
| 142 | + def docs $ [] |
| 143 | + {} (:title "\"Guide") (:key :guide) |
| 144 | + :content $ load-doc "\"guide.md" |
| 145 | + {} (:title "\"Design") (:key :design) |
| 146 | + :content $ load-doc "\"design.md" |
| 147 | + :children $ [] |
| 148 | + {} (:title "\"Guide") (:key :guide) |
| 149 | + :content $ load-doc "\"guide.md" |
| 150 | + {} (:title "\"Design") (:key :design) |
| 151 | + :content $ load-doc "\"design.md" |
| 152 | + {} (:title "\"Overview") (:key :overview) |
| 153 | + :content $ load-doc "\"overview.md" |
| 154 | + {} (:title "\"About") (:key :about) |
| 155 | + :content $ load-doc "\"about.md" |
| 156 | + |load-doc $ quote |
| 157 | + defmacro load-doc (filename) |
| 158 | + read-file $ str "\"docs/" filename |
50 | 159 | |app.updater $ {} |
51 | 160 | :ns $ quote |
52 | 161 | ns app.updater $ :require |
|
71 | 180 | app.config :as config |
72 | 181 | "\"./calcit.build-errors" :default build-errors |
73 | 182 | "\"bottom-tip" :default hud! |
| 183 | + "\"highlight.js" :default hljs |
| 184 | + "\"highlight.js/lib/languages/bash" :default bash-lang |
| 185 | + "\"highlight.js/lib/languages/clojure" :default clojure-lang |
74 | 186 | :defs $ {} |
75 | 187 | |render-app! $ quote |
76 | 188 | defn render-app! () $ render! mount-target (comp-container @*reel) dispatch! |
|
83 | 195 | |*reel $ quote |
84 | 196 | defatom *reel $ -> reel-schema/reel (assoc :base schema/store) (assoc :store schema/store) |
85 | 197 | |main! $ quote |
86 | | - defn main! () |
| 198 | + defn main! () (.!registerLanguage hljs "\"clojure" clojure-lang) (.!registerLanguage hljs "\"bash" bash-lang) |
87 | 199 | println "\"Running mode:" $ if config/dev? "\"dev" "\"release" |
88 | 200 | if config/dev? $ load-console-formatter! |
89 | 201 | render-app! |
|
0 commit comments