mirror of
https://github.com/status-im/re-frame-10x.git
synced 2025-02-18 08:56:25 +00:00
Expand and collapse data structures
This commit is contained in:
parent
32f5699f7f
commit
4c5b4b8194
@ -48,15 +48,28 @@
|
|||||||
(into (view data) (mapv crawl data))
|
(into (view data) (mapv crawl data))
|
||||||
(view data)))
|
(view data)))
|
||||||
|
|
||||||
|
(declare jsonml->hiccup)
|
||||||
|
|
||||||
|
(defn data-structure
|
||||||
|
[jsonml]
|
||||||
|
(let [expand? (r/atom true)]
|
||||||
|
(fn []
|
||||||
|
[:span.re-frame-trace--object
|
||||||
|
{:on-click #(swap! expand? not)}
|
||||||
|
(jsonml->hiccup (if @expand?
|
||||||
|
(cljs-devtools/body-api-call
|
||||||
|
(.-object (get jsonml 1))
|
||||||
|
(.-config (get jsonml 1)))
|
||||||
|
(cljs-devtools/header-api-call
|
||||||
|
(.-object (get jsonml 1))
|
||||||
|
(.-config (get jsonml 1)))))])))
|
||||||
|
|
||||||
(defn jsonml->hiccup
|
(defn jsonml->hiccup
|
||||||
[jsonml]
|
[jsonml]
|
||||||
(cond
|
(cond
|
||||||
(array? jsonml) (if (= "object" (get jsonml 0))
|
(and (array? jsonml)
|
||||||
[:span.re-frame-trace--object
|
(= "object" (get jsonml 0))) [data-structure jsonml]
|
||||||
(jsonml->hiccup (cljs-devtools/body-api-call
|
(array? jsonml) (mapv jsonml->hiccup jsonml)
|
||||||
(.-object (get jsonml 1))
|
|
||||||
(.-config (get jsonml 1))))]
|
|
||||||
(mapv jsonml->hiccup jsonml))
|
|
||||||
(object? jsonml) {:style (string->css (js->clj jsonml))}
|
(object? jsonml) {:style (string->css (js->clj jsonml))}
|
||||||
:else (str->hiccup jsonml)))
|
:else (str->hiccup jsonml)))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user