Skip to content

Commit

Permalink
Delay first evaluation (needs a proper fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
zampino committed Aug 2, 2023
1 parent a3f6782 commit 76fdd7d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/nextjournal/clerk/render/editor.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@

(defonce bar-height 26)

(defn spinner-svg [& [{:keys [size] :or {size 16}}]]
[:div.flex.items-center.justify-center {:class "w-[50px] h-[50px]"}
[:svg.animate-spin.text-greenish
{:xmlns "http://www.w3.org/2000/svg" :fill "none" :viewBox "0 0 24 24"
:style {:width size :height size}}
[:circle.opacity-25 {:cx "12" :cy "12" :r "10" :stroke "currentColor" :stroke-width "4"}]
[:path.opacity-75 {:fill "currentColor" :d "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"}]]])

(defn view [code-string {:as _opts :keys [eval-notebook-fn]}]
(let [!notebook (hooks/use-state nil)
!eval-result (hooks/use-state nil)
Expand Down Expand Up @@ -212,7 +220,8 @@
{:key "Escape"
:run #(reset! !show-docstring? false)}]))]))
@!container-el))]
(on-eval view)
;; FIXME! we need a callback on ws ready
(js/setTimeout #(on-eval view) 500)
#(.destroy view))))
(code/use-dark-mode !view)
[:<>
Expand All @@ -236,9 +245,11 @@
[:div.bg-white.dark:bg-slate-950.bg-white.flex.flex-col.overflow-y-auto
{:ref !notebook-panel
:style {:width "50vw" :height (str "calc(100vh - " (* bar-height 2) "px)")}}
(when-let [notebook @!notebook]
(if-some [notebook @!notebook]
[:> render/ErrorBoundary {:hash (gensym)}
[render/inspect-presented notebook]])]]
[render/inspect-presented notebook]]
[:div.flex.flex-col.items-center.justify-items-center.my-10
[spinner-svg {:size "100px"}]])]]
[:div.absolute.left-0.bottom-0.w-screen.font-mono.text-white.border-t.dark:border-slate-600
[:div.bg-slate-900.dark:bg-slate-800.flex.px-4.font-mono.gap-4.items-center.text-white
{:class "text-[12px]" :style {:height bar-height}}
Expand Down

0 comments on commit 76fdd7d

Please sign in to comment.