Skip to content

Commit 4c6525c

Browse files
author
awb99
committed
frepl single value ui
1 parent 7875f2f commit 4c6525c

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

reval-ui/src/reval/frepl.cljs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(ns reval.frepl
22
(:require
33
[taoensso.timbre :refer-macros [debugf info warn warnf error]]
4+
[clojure.string :refer [blank?]]
45
[reagent.core :as r]
56
[promesa.core :as p]
67
[nano-id.core :refer [nano-id]]
@@ -14,7 +15,45 @@
1415
; kernel
1516
[reval.kernel.protocol :refer [kernel-eval]]
1617
[reval.kernel.clj-remote] ; side effects
17-
[reval.dali.viewer.notebook :refer [segment]]))
18+
[dali.viewer :refer [viewer2]]
19+
[dali.viewer.text :refer [text]]))
20+
21+
(defn nil-result? [result]
22+
(println "result: " result)
23+
(let [data (:data result)
24+
[span _opts val] data
25+
;nilr (= data [:span {:style {:color "grey"}} nil])
26+
is-vector (vector? data)
27+
is-span (= span :span)
28+
is-nil (= val "nil")
29+
nilr (and is-vector is-span is-nil)]
30+
(println "data: " data "nilr: " nilr "span: " span " val: " val
31+
"is-span " is-span
32+
"is-nil " is-nil
33+
"is-vector " is-vector)
34+
nilr))
35+
36+
(defn segment [{:keys [_id err out result] :as segment}]
37+
; copied and modified from ; [reval.dali.viewer.notebook :refer [segment]]
38+
; reason: frepl should have big view of the resulting data, and in a
39+
; notebook the layout is different.
40+
(println "frepl segment: " segment)
41+
(cond
42+
(and result (not (nil-result? result)))
43+
[:div.mt-1.mb-1.w-full.h-full
44+
{:style {:max-width "800px"
45+
:max-height "400px"}}
46+
[viewer2 result]]
47+
err
48+
[:div.mt-1.mb-1.w-full.h-full
49+
{:style {:max-width "800px"
50+
:max-height "400px"}}
51+
[viewer2 err]]
52+
(not (blank? out))
53+
[text {:text out
54+
:class "bg-blue-200 max-w-full overflow-x-auto h-full w-full"}]
55+
:else
56+
[:div "no result/error/console output."]))
1857

1958
;; codemirror
2059

0 commit comments

Comments
 (0)