|
26 | 26 | states $ :states store |
27 | 27 | cursor $ or (:cursor states) ([]) |
28 | 28 | state $ or (:data states) |
29 | | - {} $ :selected ([]) |
| 29 | + {} |
| 30 | + :selected $ [] |
| 31 | + :history $ [] |
| 32 | + selected $ :selected state |
| 33 | + history $ :history state |
30 | 34 | div |
31 | 35 | {} (:class-name "\"calcit-tile") |
32 | 36 | :style $ merge ui/fullscreen ui/global ui/row |
33 | | - list-> |
| 37 | + div |
34 | 38 | {} $ :style |
35 | | - merge ui/row $ {} |
36 | | - :background-color $ hsl 0 0 94 0.8 |
37 | | - apply-args |
| 39 | + {} $ :background-color :white |
| 40 | + div ({}) (<> "\"Search entry") |
| 41 | + div ({}) (<> "\"Pages") |
| 42 | + list-> |
| 43 | + {} $ :style ({}) |
| 44 | + if |
| 45 | + > (count selected) 0 |
| 46 | + -> |
| 47 | + range $ dec (count selected) |
| 48 | + map $ fn (idx) |
| 49 | + let |
| 50 | + sub-path $ slice selected 0 (inc idx) |
| 51 | + target $ find-target docs sub-path |
| 52 | + [] idx $ div |
| 53 | + {} |
| 54 | + :style $ {} (:cursor :pointer) |
| 55 | + :background-color $ hsl 180 90 94 |
| 56 | + :on-click $ fn (e d!) |
| 57 | + d! cursor $ assoc state :selected sub-path |
| 58 | + <> $ str "\"< " |
| 59 | + or (:title target) "\"NOT FOUND" |
38 | 60 | [] |
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) |
| 61 | + let |
| 62 | + parent-path $ or (butlast selected) ([]) |
| 63 | + entries $ find-entries docs parent-path |
| 64 | + comp-page-entries (last selected) parent-path entries $ fn (xs d!) |
| 65 | + d! cursor $ assoc state :selected xs |
| 66 | + div ({}) (<> "\"Histories") |
59 | 67 | let |
60 | 68 | 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 |
| 69 | + div |
| 70 | + {} $ :style ui/expand |
| 71 | + let |
| 72 | + children $ or (:children target) ([]) |
| 73 | + if (empty? children) nil $ div |
| 74 | + {} $ :style |
| 75 | + {} $ :padding "\"16px" |
| 76 | + div ({}) |
| 77 | + <> "\"Children pages" $ {} (:font-family ui/font-fancy) |
| 78 | + comp-page-entries nil (:selected state) children $ fn (xs d!) |
| 79 | + d! cursor $ assoc state :selected xs |
| 80 | + comp-doc-page target |
74 | 81 | when dev? $ comp-reel (>> states :reel) reel ({}) |
75 | 82 | |md $ quote |
76 | 83 | def md $ new Remarkable |
|
83 | 90 | :border-bottom $ str "\"1px solid " (hsl 0 0 92) |
84 | 91 | :border-left $ str "\"0px solid " (hsl 200 90 60) |
85 | 92 | :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 | 93 | |find-target $ quote |
123 | 94 | defn find-target (entries path) |
124 | 95 | if (empty? path) nil $ let |
|
130 | 101 | if |
131 | 102 | = 1 $ count path |
132 | 103 | , target $ recur (:children target) (rest path) |
133 | | - w-log nil |
| 104 | + , nil |
| 105 | + |comp-doc-page $ quote |
| 106 | + defcomp comp-doc-page (target) |
| 107 | + if (some? target) |
| 108 | + div |
| 109 | + {} $ :style |
| 110 | + merge ui/expand $ {} (:padding "\"8px 16px") |
| 111 | + :background-color $ hsl 0 0 100 0.6 |
| 112 | + div $ {} |
| 113 | + :innerHTML $ .!render md (:content target) |
| 114 | + div |
| 115 | + {} $ :style |
| 116 | + merge ui/expand $ {} (:padding "\"20px 16px") |
| 117 | + do $ <> "\"Empty" |
| 118 | + {} (:font-family ui/font-fancy) (:font-style :italic) |
| 119 | + :color $ hsl 0 0 80 |
| 120 | + |comp-page-entries $ quote |
| 121 | + defcomp comp-page-entries (selected parent-path entries on-select) |
| 122 | + div |
| 123 | + {} $ :style |
| 124 | + {} (:min-width 200) (:max-width 240) |
| 125 | + :border-right $ str "\"1px solid " (hsl 0 0 94) |
| 126 | + list-> ({}) |
| 127 | + -> entries $ map-indexed |
| 128 | + fn (idx entry) |
| 129 | + [] idx $ let |
| 130 | + selected? $ = selected (:key entry) |
| 131 | + div |
| 132 | + {} $ :on-click |
| 133 | + fn (e d!) |
| 134 | + on-select |
| 135 | + conj parent-path $ :key entry |
| 136 | + , d! |
| 137 | + div |
| 138 | + {} (:class-name "\"doc-entry") |
| 139 | + :style $ merge style-entry |
| 140 | + if selected? $ {} (:background-color :white) |
| 141 | + :border-left $ str "\"10px solid " (hsl 200 90 70) |
| 142 | + <> $ :title entry |
| 143 | + |find-entries $ quote |
| 144 | + defn find-entries (entries path) |
| 145 | + if (empty? path) entries $ if-let |
| 146 | + target $ find-target entries path |
| 147 | + :children target |
| 148 | + do (js/console.warn "\"no entries found for" entries path) ([]) |
134 | 149 | |app.schema $ {} |
135 | 150 | :ns $ quote (ns app.schema) |
136 | 151 | :defs $ {} |
|
0 commit comments