Skip to content

Commit 470ca03

Browse files
Hide sticky headers in tests
Add style tag in screenshot routine
1 parent ce0b2be commit 470ca03

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

src/nextjournal/clerk/render.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@
515515
[:div
516516
[:div.overflow-x-auto.overflow-y-hidden.w-full
517517
(into [:table.text-xs.sans-serif.text-gray-900.dark:text-white.not-prose {:ref !table-ref}] children)]
518-
[:div.overflow-x-auto.overflow-y-hidden.w-full.shadow
518+
[:div.overflow-x-auto.overflow-y-hidden.w-full.shadow.sticky-table-header
519519
[:table.text-xs.sans-serif.text-gray-900.dark:text-white.not-prose {:ref !table-clone-ref :style {:margin 0}}]]]))
520520

521521
(defn throwable-view [{:keys [via trace]}]

ui_tests/screenshots.cljs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
([{:keys [out-dir]} page]
4545
(println+flush "📷 Starting screenshotting…")
4646
(p/let [og-captures (.locator page ".open-graph-image-capture")
47+
_ (.addStyleTag page #js {:content ".sticky-table-header { display: none !important; box-shadow: none !important;}"})
4748
og-captures-count (.count og-captures)
4849
results (if (< 0 og-captures-count)
4950
og-captures
@@ -56,25 +57,25 @@
5657
(p/let [res (.nth results i)
5758
bounds (.boundingBox res)]
5859
(if true #_ (<= 250 (.-height bounds))
59-
(p/let [id (.getAttribute res "data-block-id")
60-
imgs (.locator res "img")
61-
imgs-count (.count imgs)
62-
single-image? (= imgs-count 1)
63-
_ (println+flush (str "🔍 Result #" (inc i) " contains " imgs-count " " (if single-image? "image" "images") "."))
64-
subject (if single-image? (.first imgs) res)
65-
_ (println+flush (str "📸 Screenshotting result #" (inc i) " - ID: " id
66-
" (" (if single-image? "single image" "entire result") ")"
67-
" with bounds " (.-width bounds) "×" (.-height bounds)))
68-
buffer (.screenshot subject)
69-
base64 (.toString buffer "base64")
70-
image-uri (str "data:image/png;base64," base64)
71-
_ (.evaluate res (str "nextjournal.clerk.trim_image.append_trimmed_image("
72-
(pr-str image-uri) "," (pr-str (str "res-" i)) ")"))
73-
trimmed-res (.locator page (str "#res-" i))
74-
trimmed-bounds (.boundingBox trimmed-res)]
75-
(println+flush (str "🔪 Trimming result #" (inc i) " to bounds " (.-width trimmed-bounds) "×" (.-height trimmed-bounds)))
76-
(.screenshot trimmed-res #js {:path (->path out-dir (str (if id (name (edn/read-string id)) (str "result-" (inc i))) ".png"))}))
77-
(println+flush "🦘 Skipping result with bounds" (str (.-width bounds) "×" (.-height bounds))))
60+
(p/let [id (.getAttribute res "data-block-id")
61+
imgs (.locator res "img")
62+
imgs-count (.count imgs)
63+
single-image? (= imgs-count 1)
64+
_ (println+flush (str "🔍 Result #" (inc i) " contains " imgs-count " " (if single-image? "image" "images") "."))
65+
subject (if single-image? (.first imgs) res)
66+
_ (println+flush (str "📸 Screenshotting result #" (inc i) " - ID: " id
67+
" (" (if single-image? "single image" "entire result") ")"
68+
" with bounds " (.-width bounds) "×" (.-height bounds)))
69+
buffer (.screenshot subject)
70+
base64 (.toString buffer "base64")
71+
image-uri (str "data:image/png;base64," base64)
72+
_ (.evaluate res (str "nextjournal.clerk.trim_image.append_trimmed_image("
73+
(pr-str image-uri) "," (pr-str (str "res-" i)) ")"))
74+
trimmed-res (.locator page (str "#res-" i))
75+
trimmed-bounds (.boundingBox trimmed-res)]
76+
(println+flush (str "🔪 Trimming result #" (inc i) " to bounds " (.-width trimmed-bounds) "×" (.-height trimmed-bounds)))
77+
(.screenshot trimmed-res #js {:path (->path out-dir (str (if id (name (edn/read-string id)) (str "result-" (inc i))) ".png"))}))
78+
(println+flush "🦘 Skipping result with bounds" (str (.-width bounds) "×" (.-height bounds))))
7879
(p/recur (inc i)))
7980
(println+flush "✅ Done."))))))
8081

0 commit comments

Comments
 (0)