Skip to content

Commit a8358cf

Browse files
mkphilippamarkovics
authored andcommitted
Add Tap Inspector to book and homepage
1 parent 91c3168 commit a8358cf

File tree

4 files changed

+41
-13
lines changed

4 files changed

+41
-13
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Changes can be:
2020

2121
* 📖 Improve Table of Contents design and fixing re-rendering issues. Also added suport for chapter expansion.
2222

23+
* 📒 Mention Tap Inspector in Book of Clerk & on Homepage
24+
2325
* 🛠 Upgrade `framer-motion` dep to `10.12.16`.
2426

2527
* 💫 Assign `:name` to every viewer in `default-viewers`

book.clj

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@
132132
;; nmap <silent> <localleader>cs :execute ClerkShow()<CR>
133133
;; ```
134134

135-
136-
137135
;; ## 🔍 Viewers
138136

139137
;; Clerk comes with a number of useful built-in viewers e.g. for
@@ -913,6 +911,20 @@ v/table-viewer
913911

914912
^{::clerk/budget nil ::clerk/auto-expand-results? true} rows
915913

914+
;; ## 🚰 Tap Inspector
915+
916+
;; Clerk comes with an inspector notebook for Clojure's tap system. Use the following form from your REPL to show it.
917+
918+
;;```clojure
919+
;;(nextjournal.clerk/show! 'nextjournal.clerk.tap)
920+
;;```
921+
922+
;; You can then call `tap>` from anywhere in your codebase and the Tap Inspector will show your value. This supports the full viewer api described above.
923+
924+
;;```clojure
925+
;;(tap> (clerk/html [:h1 "Hello 🚰 Tap Inspector 👋"]))
926+
;;```
927+
916928
;; ## 🧱 Static Building
917929

918930
;; Clerk can make a static HTML build from a collection of notebooks.

notebooks/onwards.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Notes about what currently breaks 💥 and what could be better tomorrow.
107107
## 📖 Book Updates
108108
- [ ] Explain `render-opts` and `viewer-opts` in book
109109
- [ ] Add sync atoms to book
110-
- [ ] Add tap inspector to book
110+
- [x] Add tap inspector to book
111111
- [ ] Add customizing clerk: markdown backtick eval example to book
112112
- [ ] Add example for cross-document table of contents
113113
## 💡 Ideas

src/nextjournal/clerk/home.clj

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@
126126
:placeholder "Type to filter…"
127127
:value (:query @!state "")
128128
:on-input (fn [e] (swap! !state #(-> %
129-
(assoc :query (.. e -target -value))
130-
(dissoc :selected-path))))
129+
(assoc :query (.. e -target -value))
130+
(dissoc :selected-path))))
131131
:ref !input-el}]
132132
[:div.text-slate-400.absolute
133133
{:class "left-[10px] top-[11px]"}
@@ -139,6 +139,13 @@
139139
{:class "right-[10px] top-[9px]"}
140140
"⌘J"]]))))
141141

142+
(defn code-highlight
143+
([code] (code-highlight {} code))
144+
([opts code]
145+
[:span.font-mono.bg-white.bg-amber-100.border.border-amber-300.relative.dark:bg-slate-900.dark:border-slate-600.rounded.font-bold
146+
{:class (str "px-[4px] py-[1px] -top-[1px] mx-[2px] " (:class opts))}
147+
code]))
148+
142149
{::clerk/visibility {:result :show}}
143150

144151
^{::clerk/css-class ["w-full" "m-0"]}
@@ -153,23 +160,29 @@
153160
[:div.rounded-lg.border-2.border-amber-100.bg-amber-50.dark:border-slate-600.dark:bg-slate-800.dark:text-slate-100.px-8.py-4.mx-auto.text-center.font-sans.mt-6.md:mt-4
154161
[:div.font-medium
155162
"Call "
156-
[:span.font-mono.text-sm.bg-white.bg-amber-100.border.border-amber-300.relative.dark:bg-slate-900.dark:border-slate-600.rounded.font-bold
157-
{:class "px-[4px] py-[1px] -top-[1px] mx-[2px]"}
158-
"nextjournal.clerk/show!"]
163+
(code-highlight {:class "text-sm"} "nextjournal.clerk/show!")
159164
" from your REPL to make a notebook appear!"]
160165
[:div.mt-2.text-sm "⚡️ This works best when you " [:a {:href "https://book.clerk.vision/#editor-integration"} "set up your editor to use a key binding for this!"]]]
161-
[:div.rounded-lg.border-2.border-indigo-100.bg-indigo-50.dark:border-slate-600.dark:bg-slate-800.dark:text-slate-100.px-8.py-4.mt-6.text-center.font-sans
166+
[:div.rounded-lg.border-2.border-indigo-100.bg-indigo-50.dark:border-slate-600.dark:bg-slate-800.dark:text-slate-100.px-8.py-4.mt-4.text-center.font-sans
162167
[:div.font-medium.md:flex.items-center.justify-center
163-
[:span.text-xl.relative {:class "top-[2px] mr-2"} "📖"]
164-
[:span "New to Clerk? Learn all about it in " [:a {:href "https://book.clerk.vision"} [:span.block.md:inline "The Book of Clerk."]]]]
168+
[:span.text-xl.relative {:class "top-[2px] mr-2"} ""]
169+
[:span "🌱 New to Clerk? Learn all about it in the " [:a {:href "https://book.clerk.vision"} [:span.block.md:inline "📖 Book of Clerk."]]]]
165170
#_
166171
[:div.mt-2.text-sm
167172
"Here are some handy links:"
168173
[:a.ml-3 {:href "#"} "🚀 Getting Started"]
169174
[:a.ml-3 {:href "#"} "🔍 Viewers"]
170175
[:a.ml-3 {:href "#"} "🙈 Controlling Visibility"]]]
176+
[:div.rounded-lg.border-2.border-amber-100.bg-amber-50.dark:border-slate-600.dark:bg-slate-800.dark:text-slate-100.px-8.py-4.mx-auto.text-center.font-sans.mt-6.md:mt-4
177+
[:div [:span.font-medium "💡 Tip:"] " Show the " [:a {:href "/'nextjournal.clerk.tap"} "🚰 Tap Inspector"] " to inspect values using " (code-highlight {:class "text-sm" }"tap>") "."]
178+
[:div.mt-2.text-xs
179+
(code-highlight {:class "text-sm"} "(nextjournal.clerk/show 'nextjournal.clerk.tap)")]]
171180
#_[:div.mt-6
172-
(clerk/with-viewer filter-input-viewer `!filter)]
181+
(clerk/with-viewer filter-input-viewer `!filter)]])
182+
183+
^{::clerk/css-class ["w-full" "m-0"]}
184+
(clerk/html
185+
[:div.max-w-prose.px-8.mx-auto.-mt-6
173186
[:div.flex.mt-6.border-t.dark:border-slate-700.font-sans
174187
[:div {:class (str "w-1/2 pt-6 " (when-not (seq @!filter) "pr-6 border-r dark:border-slate-700"))}
175188
[:h4.text-lg "All Notebooks"]
@@ -183,4 +196,5 @@
183196
(cond
184197
error [:div {:class "-mx-8"} (clerk/md error)]
185198
paths (let [{:keys [query]} @!filter]
186-
(clerk/with-viewer index-viewer {:paths (filter (partial query-fn query) paths)}))))])]])
199+
(clerk/with-viewer index-viewer {:paths (filter (partial query-fn query) paths)}))))])]]
200+
)

0 commit comments

Comments
 (0)