|
2 | 2 | {} (:package |docs-workflow) |
3 | 3 | :configs $ {} (:init-fn |docs-workflow.main/main!) (:reload-fn |docs-workflow.main/reload!) |
4 | 4 | :modules $ [] |respo.calcit/ |lilac/ |memof/ |respo-ui.calcit/ |respo-markdown.calcit/ |reel.calcit/ |respo-router.calcit/ |alerts.calcit/ |
5 | | - :version |0.0.4 |
| 5 | + :version |0.0.5 |
6 | 6 | :entries $ {} |
7 | 7 | :files $ {} |
8 | 8 | |docs-workflow.comp.container $ {} |
9 | 9 | :ns $ quote |
10 | 10 | ns docs-workflow.comp.container $ :require (respo-ui.core :as ui) |
11 | 11 | respo-ui.core :refer $ hsl |
12 | | - respo.core :refer $ defcomp defeffect <> >> div button textarea span input list-> |
| 12 | + respo.core :refer $ defcomp defeffect <> >> div button textarea span input list-> a |
13 | 13 | respo.comp.space :refer $ =< |
14 | 14 | reel.comp.reel :refer $ comp-reel |
15 | 15 | respo-md.comp.md :refer $ comp-md |
|
46 | 46 | def style-entry $ {} (:padding "\"0 8px") (:cursor :pointer) (:transition-duration "\"200ms") (:line-height 2.4) |
47 | 47 | :border-bottom $ str "\"1px solid " (hsl 0 0 92) |
48 | 48 | :border-left $ str "\"0px solid " (hsl 200 90 60) |
49 | | - :background-color $ hsl 0 0 100 0.6 |
| 49 | + |style-title $ quote |
| 50 | + def style-title $ {} (:font-family ui/font-fancy) (:font-size 18) (:font-weight 300) |
| 51 | + :color $ hsl 0 0 60 |
50 | 52 | |comp-container $ quote |
51 | 53 | defcomp comp-container (reel docs) |
52 | 54 | let |
|
56 | 58 | state $ or (:data states) |
57 | 59 | {} |
58 | 60 | :selected $ [] |
| 61 | + :key $ first docs |
59 | 62 | :history $ [] |
60 | 63 | selected $ :selected state |
61 | 64 | history $ :history state |
|
67 | 70 | :render $ fn (on-close) |
68 | 71 | div |
69 | 72 | {} $ :style |
70 | | - {} $ :padding "\"0 16px" |
| 73 | + merge ui/expand $ {} (:padding "\"16px 16px 120px") |
| 74 | + :border-top $ str "\"1px solid " (hsl 0 0 94) |
71 | 75 | comp-nav-tree docs ([]) |
72 | 76 | fn (path d!) |
73 | 77 | d! cursor $ next-path state path |
|
76 | 80 | :style $ merge ui/fullscreen ui/global ui/row |
77 | 81 | div |
78 | 82 | {} $ :style |
79 | | - {} (:padding "\"0 8px") (:width "\"20%") (:min-width 266) (:background-color :white) |
| 83 | + merge ui/column $ {} (:padding "\"0 8px") (:width "\"20%") (:min-width 266) (:background-color :white) |
80 | 84 | :border-right $ str "\"1px solid " (hsl 0 0 94) |
81 | 85 | div |
82 | 86 | {} |
83 | 87 | :style $ {} (:position :absolute) (:right 8) (:top 4) |
84 | 88 | :on-click $ fn (e d!) (.show quick-modal d!) |
85 | | - <> "\"Quick Jump" $ {} (:cursor :pointer) (:font-family ui/font-fancy) |
| 89 | + <> "\"Quick Jump" $ merge |
| 90 | + {} (:cursor :pointer) (:font-family ui/font-fancy) |
86 | 91 | div |
87 | 92 | {} $ :style |
88 | | - {} $ :margin-top 12 |
89 | | - <> "\"Pages" $ {} (:font-family ui/font-fancy) |
| 93 | + merge ui/row-parted $ {} (:margin-top 12) |
| 94 | + <> "\"Pages" style-title |
| 95 | + a $ {} (:href "\"mdbook.html") (:inner-text "\"mdbook") |
| 96 | + :style $ {} (:font-size 12) (:font-family ui/font-fancy) (:opacity 0.3) |
90 | 97 | comp-parent-menu selected docs $ fn (path d!) |
91 | 98 | d! cursor $ next-path state path |
92 | 99 | let |
93 | 100 | parent-path $ or (butlast selected) ([]) |
94 | 101 | entries $ find-entries docs parent-path |
95 | | - comp-page-entries (last selected) parent-path entries $ fn (xs d!) |
96 | | - d! cursor $ next-path state xs |
| 102 | + div |
| 103 | + {} $ :style ui/expand |
| 104 | + comp-page-entries (last selected) parent-path entries $ fn (xs d!) |
| 105 | + d! cursor $ next-path state xs |
97 | 106 | div |
98 | 107 | {} $ :style |
99 | 108 | {} $ :margin-top 20 |
100 | | - <> "\"Histories" $ {} (:font-family ui/font-fancy) |
| 109 | + <> "\"Histories" style-title |
101 | 110 | comp-history-menu history docs $ fn (path d!) |
102 | 111 | d! cursor $ next-path state path |
103 | 112 | let |
|
106 | 115 | {} $ :style ui/expand |
107 | 116 | let |
108 | 117 | children $ or (:children target) ([]) |
109 | | - if (empty? children) nil $ div |
110 | | - {} $ :style |
111 | | - {} $ :padding "\"16px" |
112 | | - div ({}) |
113 | | - <> "\"Children pages" $ {} (:font-family ui/font-fancy) |
114 | | - comp-page-entries nil (:selected state) children $ fn (xs d!) |
| 118 | + if (empty? children) nil $ comp-child-entries (:selected state) children |
| 119 | + fn (xs d!) |
115 | 120 | d! cursor $ next-path state xs |
116 | 121 | comp-doc-page target |
117 | 122 | =< nil 120 |
118 | 123 | .render quick-modal |
119 | 124 | when dev? $ comp-reel (>> states :reel) reel ({}) |
| 125 | + |style-child-entry $ quote |
| 126 | + def style-child-entry $ {} (:padding "\"0 8px") (:cursor :pointer) (:transition-duration "\"200ms") (:line-height 2.4) |
120 | 127 | |find-target $ quote |
121 | 128 | defn find-target (entries path) |
122 | 129 | if (empty? path) nil $ let |
|
143 | 150 | target $ find-target docs sub-path |
144 | 151 | [] idx $ div |
145 | 152 | {} |
146 | | - :style $ {} (:cursor :pointer) (:font-style :italic) |
| 153 | + :style $ {} (:cursor :pointer) (:font-style :italic) (:font-family ui/font-fancy) |
| 154 | + :color $ hsl 0 0 40 |
147 | 155 | :background-color $ hsl 180 90 94 |
148 | 156 | :on-click $ fn (e d!) (on-select sub-path d!) |
149 | 157 | <> $ str "\"< " |
|
174 | 182 | div |
175 | 183 | {} (:class-name "\"doc-entry") |
176 | 184 | :style $ merge style-entry |
177 | | - if selected? $ {} (:background-color :white) |
| 185 | + if selected? $ {} |
178 | 186 | :border-left $ str "\"10px solid " (hsl 200 90 70) |
179 | 187 | <> $ :title entry |
| 188 | + =< 8 nil |
| 189 | + if |
| 190 | + not $ empty? (:children entry) |
| 191 | + <> "\"☰" $ {} |
| 192 | + :color $ hsl 180 80 60 |
180 | 193 | |comp-doc-page $ quote |
181 | 194 | defcomp comp-doc-page (target) |
182 | 195 | if (some? target) |
|
221 | 234 | target $ find-target entries path |
222 | 235 | :children target |
223 | 236 | do (js/console.warn "\"no entries found for" entries path) ([]) |
| 237 | + |comp-child-entries $ quote |
| 238 | + defcomp comp-child-entries (parent-path entries on-select) |
| 239 | + div |
| 240 | + {} $ :style |
| 241 | + {} (:padding "\"8px") (:min-width 320) (:max-width 400) (:background-color :white) (:margin "\"8px 12px") (:border-radius "\"4px") |
| 242 | + :border $ str "\"1px solid " (hsl 0 0 86) |
| 243 | + <> "\"Child pages" style-title |
| 244 | + list-> ({}) |
| 245 | + -> entries $ map-indexed |
| 246 | + fn (idx entry) |
| 247 | + [] idx $ div |
| 248 | + {} $ :on-click |
| 249 | + fn (e d!) |
| 250 | + on-select |
| 251 | + conj parent-path $ :key entry |
| 252 | + , d! |
| 253 | + div |
| 254 | + {} (:class-name "\"doc-entry") (:style style-child-entry) |
| 255 | + <> $ :title entry |
| 256 | + =< 8 nil |
| 257 | + if |
| 258 | + not $ empty? (:children entry) |
| 259 | + <> "\"☰" $ {} |
| 260 | + :color $ hsl 180 80 60 |
224 | 261 | |docs-workflow.schema $ {} |
225 | 262 | :ns $ quote (ns docs-workflow.schema) |
226 | 263 | :defs $ {} |
|
241 | 278 | :content $ load-doc "\"design.md" |
242 | 279 | {} (:title "\"Overview") (:key :overview) |
243 | 280 | :content $ load-doc "\"overview.md" |
| 281 | + :children $ [] |
| 282 | + {} (:title "\"Cirru") (:key :cirru) |
| 283 | + :content $ load-doc "\"cirru.md" |
244 | 284 | {} (:title "\"About") (:key :about) |
245 | 285 | :content $ load-doc "\"about.md" |
| 286 | + {} (:title "\"Cirru") (:key :cirru) |
| 287 | + :content $ load-doc "\"cirru.md" |
246 | 288 | |load-doc $ quote |
247 | 289 | defmacro load-doc (filename) |
248 | 290 | read-file $ str "\"docs/" filename |
|
270 | 312 | docs-workflow.config :as config |
271 | 313 | "\"./calcit.build-errors" :default build-errors |
272 | 314 | "\"bottom-tip" :default hud! |
273 | | - "\"highlight.js" :default hljs |
274 | | - "\"highlight.js/lib/languages/bash" :default bash-lang |
275 | | - "\"highlight.js/lib/languages/clojure" :default clojure-lang |
276 | | - "\"highlight.js/lib/languages/rust" :default rust-lang |
277 | 315 | :defs $ {} |
278 | 316 | |render-app! $ quote |
279 | 317 | defn render-app! () $ render! mount-target (comp-container @*reel schema/docs) dispatch! |
|
286 | 324 | |*reel $ quote |
287 | 325 | defatom *reel $ -> reel-schema/reel (assoc :base schema/store) (assoc :store schema/store) |
288 | 326 | |main! $ quote |
289 | | - defn main! () (.!registerLanguage hljs "\"clojure" clojure-lang) (.!registerLanguage hljs "\"bash" bash-lang) (.!registerLanguage hljs "\"rust" rust-lang) |
| 327 | + defn main! () (config/register-languages!) |
290 | 328 | println "\"Running mode:" $ if config/dev? "\"dev" "\"release" |
291 | 329 | if config/dev? $ load-console-formatter! |
292 | 330 | render-app! |
|
313 | 351 | hud! "\"ok~" "\"Ok" |
314 | 352 | hud! "\"error" build-errors |
315 | 353 | |docs-workflow.config $ {} |
316 | | - :ns $ quote (ns docs-workflow.config) |
| 354 | + :ns $ quote |
| 355 | + ns docs-workflow.config $ :require ("\"highlight.js/lib/languages/rust" :default rust-lang) ("\"highlight.js/lib/languages/clojure" :default clojure-lang) ("\"highlight.js/lib/languages/bash" :default bash-lang) ("\"highlight.js" :default hljs) |
317 | 356 | :defs $ {} |
318 | 357 | |dev? $ quote |
319 | 358 | def dev? $ = "\"dev" (get-env "\"mode") |
320 | 359 | |site $ quote |
321 | 360 | def site $ {} (:storage-key "\"workflow") |
| 361 | + |register-languages! $ quote |
| 362 | + defn register-languages! () (.!registerLanguage hljs "\"clojure" clojure-lang) (.!registerLanguage hljs "\"bash" bash-lang) (.!registerLanguage hljs "\"rust" rust-lang) |
0 commit comments