Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extensible viewers with lazy loading #1

Merged
merged 111 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
79dfbb3
Bring in nextjournal.viewer
mk Aug 13, 2021
1f978f4
Switch to viewers repo
mk Aug 16, 2021
4d1daed
Add missing :git/url keys to deps.edn
kommen Aug 16, 2021
64e71b6
Use viewers repo for devcards and markdown using :deps/root
kommen Aug 16, 2021
242b6b4
:git/url keys are not needed with latest clj cli tools
kommen Aug 16, 2021
628c3c1
Add index.html
mk Aug 17, 2021
b7f093e
Pairing session with @jackrusher
mk Aug 18, 2021
f9f102b
Bump viewers module
mk Aug 23, 2021
5d75c04
Uncomment default viewers
mk Aug 23, 2021
d19af6c
Evolve Clerk sci viewer
mk Aug 24, 2021
532e869
Add bb.edn with first watch:cljs task
mk Aug 24, 2021
47d286b
Fix printing maps and js objects, add set example and more demo data
philippamarkovics Aug 24, 2021
b3863b6
Run girouette in Clerk
mk Aug 24, 2021
0aeefc6
Remove obsoete cruft from nextjournal viewers
mk Aug 24, 2021
f5ed1e4
Adjust missing viewer error
philippamarkovics Aug 24, 2021
be6b804
Adjust viewer styles
philippamarkovics Aug 24, 2021
5dfb726
Fix warnings and make error badge smaller
mk Aug 24, 2021
c07de5b
Improve map viewer
mk Aug 24, 2021
478e40a
Ignore Cursive project folders
philippamarkovics Aug 25, 2021
3a60070
Ignore more stuff in public and yarn.lock
philippamarkovics Aug 25, 2021
38beae9
Start working a bit on the marketing website
philippamarkovics Aug 25, 2021
505fe6b
Improve map & object viewer
mk Aug 25, 2021
e69750d
Show the data in collection viewers
mk Aug 26, 2021
d8ce063
Add toggle-expanded for coll viewers
mk Aug 26, 2021
b7388ba
Moving parens around
mk Aug 26, 2021
9140927
Fix loop
mk Aug 27, 2021
211d68a
Bump viewers
mk Aug 27, 2021
ceff335
Fix key & doctype warnings
mk Aug 27, 2021
3eb3dda
Fix rule 30 viewer
mk Aug 27, 2021
810d736
Bump girouette to latest
mk Aug 30, 2021
6ddd249
Drop girouette, use styles from viewers repo
philippamarkovics Aug 31, 2021
30c4bf7
Lazy loading wip
mk Sep 2, 2021
aed0d93
minor fixes to fetch
mk Sep 7, 2021
f99bd40
Refactor viewers to be cljc
mk Sep 7, 2021
6bc205a
Working impl for fetch
mk Sep 8, 2021
5a919e8
Include katex styles in clerk view
philippamarkovics Sep 8, 2021
c74e2a0
Add cider-nrepl dependency and bump shadow-cljs
kommen Sep 8, 2021
912a968
Remove unused girouette references
kommen Sep 8, 2021
706e86b
Bump viewers version
philippamarkovics Sep 8, 2021
d926c49
Watch less files for CSS generation in development
kommen Sep 8, 2021
b635237
First cut of client-side lazy loading for collections
mk Sep 8, 2021
dd9ce84
Refactor adding inspect-lazy fn
mk Sep 9, 2021
b02aa57
Add workaround for devcards livereload issue
mk Sep 9, 2021
c5228bc
Fix fetch for maps
mk Sep 9, 2021
cc6f34f
Fetch data when clicking elision
mk Sep 9, 2021
482b1c6
Fix console formatting by bringing in cljs devtools
mk Sep 9, 2021
d04f69a
Minor cleanup
mk Sep 10, 2021
ef7ed29
Load the first 20 items of each level on mount
mk Sep 10, 2021
d9c1f56
Start integrating Clerk
mk Sep 10, 2021
8040248
Use sci viewer entry point in Clerk
mk Sep 12, 2021
e393d32
Fix notebook viewer
mk Sep 13, 2021
2cf179b
Fix and enable more viewers
mk Sep 13, 2021
60dd56d
Get Clerk notebook rendering working again
mk Sep 13, 2021
d6ee31d
Make lazy loading work in Clerk notebooks
mk Sep 13, 2021
bac7826
Make whole pagination notebook render
mk Sep 13, 2021
1bed44d
Check off completed items in onwards notebook
mk Sep 13, 2021
dfb961f
Bump viewers
philippamarkovics Sep 13, 2021
2b407fe
Fix livereload and start on new viewer api
mk Sep 15, 2021
0176371
Get Rule 30 viewers working partially
mk Sep 16, 2021
dad2f1b
Make Rule 30 work
mk Sep 16, 2021
50e24f4
wip
mk Sep 16, 2021
777e370
Start ripping out metadata for viewers
mk Sep 17, 2021
6a64d2e
Use scope to use viewers set on ns
mk Sep 18, 2021
af2a16c
Fix set-viewers! on initial load
mk Sep 18, 2021
c98e47b
Fall back to default root viewers when ns viewers aren't set
mk Sep 18, 2021
17cc287
Fix viewer selection in Clojure, cleanup & update onwards notebook
mk Sep 18, 2021
ac569b7
Handle deref expressions, update onwards
mk Sep 19, 2021
5a4b3fe
Fix rule 30, only eval viewer predicates in Clojure
mk Sep 20, 2021
75e724f
Handle lazy infinite sequences
mk Sep 20, 2021
586731f
Fix notebook viewer devcard
philippamarkovics Sep 20, 2021
7fb289c
Fix breaking set opening
philippamarkovics Sep 20, 2021
03cf1c8
More data structure examples
philippamarkovics Sep 20, 2021
07bcde4
Fix js only viewers (vega + plotly) by opting out of lazy loading
mk Sep 20, 2021
1c5765a
Fix regressions in map viewer
mk Sep 20, 2021
6710c44
Fix uuid & inst viewers
mk Sep 20, 2021
94d023c
Show more… button for maps as well
mk Sep 20, 2021
49e177c
Fix breaking tagged values, collections and maps
philippamarkovics Sep 20, 2021
f5909ef
Sort maps & sets, use viewer selection in Clojure to render
mk Sep 20, 2021
00c9021
Don't force selected viewer when elision is in place
mk Sep 21, 2021
0a91df1
Use nbsp only where necessary
philippamarkovics Sep 22, 2021
fad9c91
Only allow expanding when parent is already expanded
philippamarkovics Sep 22, 2021
e23032d
Fix mathjax devcard
mk Sep 22, 2021
427064d
First cut of per-expression viewer overrides
mk Sep 22, 2021
e412ee7
Fix react key to make blob re-render when changed
mk Sep 22, 2021
3f43a4a
Fix datafy for namespace scope
mk Sep 22, 2021
b3bb88d
Start viewer api notebook
mk Sep 23, 2021
096ddd0
Make passing viewers down & Rule 30 notebook work (mostly)
mk Sep 23, 2021
a466894
Silence logging & update viewer api notebook
mk Sep 23, 2021
d7b16c3
Bump viewers & remove devcards livereload workaround
mk Sep 23, 2021
ac7f951
Restore part of main function that's still needed
mk Sep 23, 2021
1d95ac5
Fix lazy fib by catching exception computing `bounded-count`
mk Sep 23, 2021
e8ed793
Make elision viewer correctly render hiccup
mk Sep 27, 2021
f2c3c29
Fix expanding viewers
philippamarkovics Sep 27, 2021
256d8d0
Fix rendering of maps with nested values
mk Sep 27, 2021
e8cf270
Add `map-entry` viewer to render space in Rule 30 notebook map
mk Sep 27, 2021
6d16ec9
Fix loading of results without a description
mk Sep 27, 2021
c8a1ac7
Fix map display and use edamame for regexp reading
mk Sep 28, 2021
9ff4320
Add file viewer and reader to make pagination notebook work again
mk Sep 28, 2021
18bad43
Build lazy loading for strings & wrap results in maps w/ blob-id
mk Sep 28, 2021
bdb4328
Fix per-expression and fn? viewers
mk Sep 29, 2021
b47ec8b
Simplify viewer api: drop view-as & reverse argument order in with-vi…
mk Sep 29, 2021
a3308f7
Opt out of lazy loading for named viewers
mk Sep 29, 2021
520d4ae
Use newer viewer api for error message
mk Sep 29, 2021
2c289fa
Eval preds to make colors example work
mk Sep 29, 2021
bef9173
More exhaustive color parsing
philippamarkovics Sep 30, 2021
fee24db
Implement exception viewer
philippamarkovics Sep 30, 2021
32e010d
Use custom Fn+ record to keep original form on fn
mk Oct 1, 2021
9760d0d
Simplify by restricting Fn+ to Clojure
mk Oct 2, 2021
04fd22c
Demunge call in stacktrace and add throwing notebook
mk Oct 2, 2021
ef15557
Make with-viewer(s) macros, simplify fn rebuilding using reader tag
mk Oct 4, 2021
712029a
First pass on docstrings and use macro helper fn naming convention
mk Oct 4, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .clj-kondo/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{:lint-as {applied-science.js-interop/defn clojure.core/defn
applied-science.js-interop/fn clojure.core/fn
applied-science.js-interop/let clojure.core/let
cljs.core/specify! cljs.core/reify
reagent.core/with-let clojure.core/let
nextjournal.view/defview clojure.core/defn
nextjournal.devcards/defcard clj-kondo.lint-as/def-catch-all}
:skip-comments true
:linters {:consistent-alias {:aliases {datomic.api datomic
nextjournal.log log
clojure.string str
clojure.spec.alpha s}}
:unresolved-symbol {:exclude [(cljs.core.match/match)
(cljs.test/is [match?])
(clojure.test/is [match?])
(clojure.core.match/match)]}
:unused-namespace {:exclude [clojure.string
nextjournal.devcards
nextjournal.log]}}}
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@
.cpcache/
.lsp/
.nrepl-port

/node_modules/
/public/css/app.css
/public/js/
/.shadow-cljs/
.idea/
clerk.iml
public/girouette.css
public/images/
yarn.lock
20 changes: 20 additions & 0 deletions bb.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{:tasks {:init (def tailwind-build-cmd "npx tailwindcss --input stylesheets/app.css --output public/css/app.css")
yarn-install {:doc "Installs and updates npm dependencies"
:task (shell "yarn install")}

watch:cljs {:doc "Starts shadow-cljs server"
:task (clojure "-M:sci:demo:shadow")
:depends [yarn-install]}

watch:css {:doc "Starts a watcher for css files tailwindcss"
:task (shell (str tailwind-build-cmd " --watch"))
:depends [yarn-install]}

release:css {:doc "Builds the css files with tailwindcss for release"
:task (shell tailwind-build-cmd {:extra-env {"NODE_ENV" "production"}})
:depends [yarn-install]}

-dev {:depends [watch:cljs watch:css]}
dev {:doc "Start app in dev mode, compiles cljs and css"
:task (run '-dev {:parallel true})}}
:min-bb-version "0.5.1"}
14 changes: 13 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,22 @@
hiccup/hiccup {:mvn/version "2.0.0-alpha2"}
lambdaisland/uri {:mvn/version "1.4.70"}


arrowic/arrowic {:mvn/version "0.1.1"}
rewrite-clj/rewrite-clj {:mvn/version "0.6.1"}}

:aliases {:demo {:extra-paths ["notebooks/src"]
:aliases {:sci {:extra-deps {io.github.nextjournal/viewers {:git/url "git@github.com:nextjournal/viewers.git"
:git/sha "913ed6d4964171248c6b700ff925aa7ef092d59d"}
metosin/reitit-frontend {:mvn/version "0.5.15"}
borkdude/sci {:mvn/version "0.2.6"}
applied-science/js-interop {:mvn/version "0.3.0"}}}

:shadow {:extra-deps {thheller/shadow-cljs {:mvn/version "2.15.9"}
binaryage/devtools {:mvn/version "1.0.3"}
cider/cider-nrepl {:mvn/version "0.26.0"}}
:main-opts ["-m" "shadow.cljs.devtools.cli" "watch" "browser"]}

:demo {:extra-paths ["notebooks/src"]
:extra-deps {com.github.seancorfield/next.jdbc {:mvn/version "1.2.659"}
org.xerial/sqlite-jdbc {:mvn/version "3.34.0"}
org.clojure/data.csv {:mvn/version "1.0.0"}}}}}
3 changes: 3 additions & 0 deletions notebooks/boom.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
;; Boom 💥
;; This will blow up shortly.
(throw (ex-info "boom!" {:rand-int (rand-int 1000) :range-100 (range 100)}))
47 changes: 34 additions & 13 deletions notebooks/onwards.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,43 @@
;; - [x] Don't cache things that are fast to evaluate
;; - [x] Handle conditional read in cljc files
;; - [x] Add README
;; - [ ] Make viewer registration local (on form + namespace)
;; - [x] Markdown should support Nextjournal Flavored Markdown including:
;; - [x] TODO lists 😹
;; - [x] Inline Formulas $E^2=m^2+\vec{p}^2$
;; - [ ] Fix analyzer error for aliases requires w/o ns (e.g. in viewers notebooks)
;; ## Viewers
;; - [x] Make viewer api open with predicates
;; - [x] Make viewer registration local on namespace
;; - [x] Make js-only viewers like plotly & vega work
;; - [x] Fix maps
;; - [x] Sort maps
;; - [x] Lazy seqs
;; - [x] Fix Rule 30 maps
;; - [x] Drop vector brackets when lazy load map element
;; - [x] Review viewer registration api
;; - [x] Simplify viewer api (drop `view-as` & change argument order in `with-viewer`/`s`)
;; - [x] Fix seeing map with blob-id in Rule 30 notebook
;; - [x] Turn `with-viewers` into a macro and make it take same unquoted form as `set-viewers!`
;; - [ ] Consistently use `Fn+Form` to carry viewer functions
;; - [ ] Show sci eval error when viewers error on eval
;; - [ ] Make map-viewer pass down options to select map-entry renderer for children and remove viewer from Rule 30
;; - [x] Drop lazy loading attempts in plotly + vega viewers
;; - [ ] Keep expanded state when lazy loading
;; - [ ] Allow to control viewer expansion state programmatically
;; - [ ] Move update opts fn to viewer map
;; - [x] Restrict string length + enable lazy loading
;; - [ ] Datafy + Nav
;; - [ ] Metadata viewer
;; - [ ] Persist viewer expansion state across reloads
;; - [x] Let the viewer opt into pagination
;; - [ ] Return complete datastructure if reasonably small (larger than the 20 elements we currently serve)
;; - [ ] A browser refresh is currently needed to reset a viewer override like in `notebooks/rule_30.clj`, otherwise it will carry over the viewer override to other notebooks that do no specify an override
;; - [ ] Evaluation error messages are poorly formatted
;; - [ ] Viewer errors are not displayed correctly
;; - [x] A browser refresh is currently needed to reset a viewer override like in `notebooks/rule_30.clj`, otherwise it will carry over the viewer override to other notebooks that do no specify an override
;; - [x] Evaluation error messages are poorly formatted
;; - [ ] Make stacktraces clickable
;; - [x] `first-generation` in `notebooks/rule_30.clj` renders incorrectly because of pagination type coercion from vector to list
;; - [ ] `(def r (range 100))` in `notebooks/pagination.clj` shows incorrect `count`
;; - [ ] Figure out distributed caching using CAS + cloud bucket
;; - [ ] Markdown should support Nextjournal Flavored Markdown including:
;; - [ ] TODO lists 😹
;; - [ ] Inline Formulas $E^2=m^2+\vec{p}^2$
;; - [ ] Better Error display
;; - [x] Fix jar hashing (contents, not filename)
;; - [x] `(def r (range 100))` in `notebooks/pagination.clj` shows incorrect `count`
;; - [x] Printing of very large values
;; ## Ideas
;; - [ ] Hook up distributed caching using CAS + cloud bucket
;; - [ ] Status log
;; - [ ] Datafy + Nav
;; - [ ] Allow to pin notebook
;; - [ ] Make viewer api open with predicates
47 changes: 35 additions & 12 deletions notebooks/pagination.clj
Original file line number Diff line number Diff line change
@@ -1,34 +1,57 @@
;; # Pagination
#_(require '[nextjournal.clerk.viewer :as v])
#_(nextjournal.clerk/show! "notebooks/pagination.clj")

(range)

(def notebooks
(clojure.java.io/file "notebooks"))

[(clojure.java.io/file "notebooks")]
(subs (slurp "/usr/share/dict/words") 0 10100)

[notebooks]

(sort (into #{} (map str) (file-seq notebooks)))
(into #{} (map str) (file-seq notebooks))

(def r (range 100))

(map inc r)

(mapv inc r)
#_
[(mapv inc r)]

^:clerk/no-cache (shuffle r)

#_#_#_
;; A long list.
(range 1000)

;; A somewhat large map.
(zipmap (range 1000) (map #(* % %) (range 1000)))



^:clerk/no-cache (shuffle (range 42))


#_
(v/register-viewer! :vector {:n 20} (fn [x options]
(v/html (into [:div.flex.flex-col] (map (partial v/inspect options)) x))))
(let [[first-three others] (split-at 3 [:A :A :B :B :C :C :D :D])]
{:first-three first-three
:others others})

(frequencies [:A :A :B :B :C :C :D :D])

(group-by first [[:A :B :B] [:B :C :C] [:C :A :A]])

(take 5
(repeatedly (fn []
{:name (str
(rand-nth ["Oscar" "Karen" "Vlad" "Rebecca" "Conrad"]) " "
(rand-nth ["Miller" "Stasčnyk" "Ronin" "Meyer" "Black"]))
:role (rand-nth [:admin :operator :manager :programmer :designer])
:id (java.util.UUID/randomUUID)
:created-at #inst "2021"})))

(defn flat->nested
[root coll]
(if-let [children (seq (filter #(= (:id root) (:parent %)) coll))]
(map #(assoc root :children (flat->nested % coll)) children)
(list root)))

(let [items (concat [{:id 0 :parent nil :name "item-0"}]
(for [x (range 1 5)]
{:id x :parent (dec x) :name (format "item-%d" x)}))]
(flat->nested (-> (filter #(= (:parent %) nil) items) first) items))
24 changes: 18 additions & 6 deletions notebooks/rule_30.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@
(ns rule-30
(:require [nextjournal.clerk.viewer :as v]))

(v/register-viewers!
{:number #(v/html [:div.inline-block {:style {:width 16 :height 16}
:class (if (pos? %) "bg-black" "bg-white border-solid border-2 border-black")}])
:vector #(v/html (into [:div.flex.inline-flex] (map (partial v/inspect %2)) %1))
:list #(v/html (into [:div.flex.flex-col] (map (partial v/inspect %2)) %1))})
(v/set-viewers!
[{:pred number? :fn #(v/html [:div.inline-block {:style {:width 16 :height 16}
:class (if (pos? %) "bg-black" "bg-white border-solid border-2 border-black")}])}
{:pred map-entry? :fn #(v/html (into [:<>] (comp (v/inspect-children %2) (interpose " ")) %1))}
{:pred vector? :fn #(v/html (into [:div.flex.inline-flex] (v/inspect-children %2) %1))}
{:pred list? :fn #(v/html (into [:div.flex.flex-col] (v/inspect-children %2) %1))}])

0

1

[0 1 0]

(list 0 1 0)

;; Now let's define Rule 30 as a map. It maps a vector of three cells to a new value for a cell. Notice how the map viewer can be used as-is and uses our number and vector viewers.
(def rule-30
Expand All @@ -26,5 +35,8 @@
(assoc (vec (repeat n 0)) (/ (dec n) 2) 1)))

;; Finally, we can evolve the board.

(let [evolve #(mapv rule-30 (partition 3 1 (repeat 0) (cons 0 %)))]
(->> first-generation (iterate evolve) (take 17)))
(->> first-generation (iterate evolve) (take 17) (apply list)))

#_(nextjournal.clerk/show! "notebooks/rule_30.clj")
88 changes: 88 additions & 0 deletions notebooks/viewer_api.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
;; # 👁 Clerk Viewer API
;; Clerk comes with a moldable viewer api that is open.

(ns notebook.viewer-api
(:require [nextjournal.clerk.viewer :as v]))

;; ## 🧩 Built-in Viewers
;; The default set of viewers are able to render Clojure data.
{:hello "world 👋" :num [1 2 3]}



;; And can handle lazy infinte sequences, only partially loading data by default with the ability to load more data on request.
(range)

(def fib (lazy-cat [0 1] (map + fib (rest fib))))

;; In addition, there's a number of built-in viewers.
;; ### 🕸 Hiccup
;; The `html` viewer interprets `hiccup` when passed a vector.
(v/html [:div "As Clojurians we " [:em "really"] " enjoy hiccup"])

;; Alternatively you can pass it an HTML string.
(v/html "Never <strong>forget</strong>.")


;; ### 📑 Markdown
;; The Markdown viewer is useful for programmatically generated markdown.
(v/md (clojure.string/join "\n" (map #(str "* Item " (inc %)) (range 3))))


;; ### 🧮 TeX
;; The TeX viewer is built on [KaTeX](https://katex.org/).
(v/tex "f^{\\circ n} = \\underbrace{f \\circ f \\circ \\cdots \\circ f}_{n\\text{ times}}.\\,")


;; ### 📊 Plotly
(v/plotly {:data [{:z [[1 2 3] [3 2 1]] :type "surface"}]})

;; ### 📈 Vega Lite
(v/vl {:width 650 :height 400 :data {:url "https://vega.github.io/vega-datasets/data/us-10m.json"
:format {:type "topojson" :feature "counties"}}
:transform [{:lookup "id" :from {:data {:url "https://vega.github.io/vega-datasets/data/unemployment.tsv"}
:key "id" :fields ["rate"]}}]
:projection {:type "albersUsa"} :mark "geoshape" :encoding {:color {:field "rate" :type "quantitative"}}})

;; ### 👾 Code
;; The code viewer uses [clojure-mode](https://nextjournal.github.io/clojure-mode/) for syntax highlighting.
(v/code (macroexpand '(when test
expression-1
expression-2)))

;; ## 🚀 Extensibility

(v/with-viewer (fn [name] (v/html [:div "Greetings to " [:strong name] "!"])) "James Maxwell Clerk")


^:clerk/no-cache
(v/with-viewers [{:pred 'number? :fn #(v/html [:div.inline-block {:style {:width 16 :height 16}
:class (if (pos? %) "bg-black" "bg-white border-solid border-2 border-black")}])}]
(take 10 (repeatedly #(rand-int 2))))

(v/with-viewers
[{:pred #(and (string? %)
(re-matches
(re-pattern
(str "(?i)"
"(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|"
"(rgb|hsl)a?\\((-?\\d+%?[,\\s]+){2,3}\\s*[\\d\\.]+%?\\))")) %))
:fn #(v/html [:div.inline-block.rounded-sm.shadow
{:style {:width 16
:height 16
:border "1px solid rgba(0,0,0,.2)"
:background-color %}}])}]
["#571845"
"rgb(144,12,62)"
"rgba(199,0,57,1.0)"
"hsl(11,100%,60%)"
"hsla(46, 97%, 48%, 1.000)"])

(re-matches
(re-pattern
(str "(?i)"
"(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|"
"(rgb|hsl)a?\\((-?\\d+%?[,\\s]+){2,3}\\s*[\\d\\.]+%?\\))"))
"hsla(46, 97%, 48%, 1.000)")

#_(nextjournal.clerk/show! "notebooks/viewer_api.clj")
3 changes: 2 additions & 1 deletion notebooks/viewers/plotly.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
;; # Plotly 📈
(require '[nextjournal.clerk.viewer :as v])
(ns viewers.plotly
(:require [nextjournal.clerk.viewer :as v]))

(v/plotly {:data [{:z [[1 2 3]
[3 2 1]]
Expand Down
3 changes: 2 additions & 1 deletion notebooks/viewers/vega.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
;; # Vega Lite 🗺
(require '[nextjournal.clerk.viewer :as v])
(ns viewers.vega
(:require [nextjournal.clerk.viewer :as v]))

(v/vl {:width 650 :height 400 :data {:url "https://vega.github.io/vega-datasets/data/us-10m.json"
:format {:type "topojson" :feature "counties"}}
Expand Down
32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"dependencies": {
"@codemirror/autocomplete": "0.18.8",
"@codemirror/closebrackets": "0.18.0",
"@codemirror/commands": "0.18.3",
"@codemirror/comment": "0.18.1",
"@codemirror/fold": "0.18.2",
"@codemirror/gutter": "0.18.4",
"@codemirror/highlight": "0.18.4",
"@codemirror/history": "0.18.1",
"@codemirror/language": "0.18.2",
"@codemirror/lint": "0.18.6",
"@codemirror/matchbrackets": "0.18.0",
"@codemirror/rectangular-selection": "0.18.1",
"@codemirror/search": "0.18.4",
"@codemirror/state": "0.18.7",
"@codemirror/view": "0.18.19",
"@toycode/markdown-it-class": "1.2.4",
"d3-require": "1.2.4",
"js-yaml": "^4.1.0",
"katex": "0.12.0",
"lezer-clojure": "0.1.10",
"markdown-it": "10.0.0",
"markdown-it-task-lists": "^2.1.1",
"markdown-it-texmath": "^0.9.1",
"process": "^0.11.10",
"punycode": "^2.1.1",
"react": "^17.0.2",
"react-dom": "16.9.0",
"tailwindcss": "2.2.12"
}
}
Loading