mirror of
https://github.com/status-im/re-frame-10x.git
synced 2025-01-12 07:04:25 +00:00
Don't interfere with app's cljs-devtools prefs
Also properly set :initial-hierarchy-depth-budget
This commit is contained in:
parent
77068d3b5d
commit
cf81870e13
@ -1,16 +1,12 @@
|
|||||||
(ns day8.re-frame.trace.app-db
|
(ns day8.re-frame.trace.app-db
|
||||||
|
(:require-macros [day8.re-frame.trace.macros :refer [with-cljs-devtools-prefs]])
|
||||||
(:require [reagent.core :as r]
|
(:require [reagent.core :as r]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[devtools.formatters.core :as cljs-devtools]
|
[devtools.prefs]
|
||||||
|
[devtools.formatters.core]
|
||||||
[day8.re-frame.trace.localstorage :as localstorage]
|
[day8.re-frame.trace.localstorage :as localstorage]
|
||||||
[day8.re-frame.trace.components :as components]))
|
[day8.re-frame.trace.components :as components]))
|
||||||
|
|
||||||
(devtools.prefs/set-pref! :header-style "")
|
|
||||||
|
|
||||||
;; Hide the index spans on the left hand of collections. Shows how many elements in a collection.
|
|
||||||
(devtools.prefs/set-pref! :none-style "display: none")
|
|
||||||
(devtools.prefs/set-pref! :index-tag [:span :none-style])
|
|
||||||
|
|
||||||
(defn string->css [css-string]
|
(defn string->css [css-string]
|
||||||
"This function converts jsonml css-strings to valid css maps for hiccup.
|
"This function converts jsonml css-strings to valid css maps for hiccup.
|
||||||
Example: 'margin-left:0px;min-height:14px;' converts to
|
Example: 'margin-left:0px;min-height:14px;' converts to
|
||||||
@ -21,10 +17,28 @@
|
|||||||
(reduce (fn [acc [property value]]
|
(reduce (fn [acc [property value]]
|
||||||
(assoc acc (keyword property) value)) {})))
|
(assoc acc (keyword property) value)) {})))
|
||||||
|
|
||||||
(def config {:initial-hierarchy-depth-budget false})
|
|
||||||
|
|
||||||
(declare jsonml->hiccup)
|
(declare jsonml->hiccup)
|
||||||
|
|
||||||
|
(def default-cljs-devtools-prefs @devtools.prefs/default-config)
|
||||||
|
|
||||||
|
(def customized-cljs-devtools-prefs
|
||||||
|
{:header-style ""
|
||||||
|
:none-style "display: none"
|
||||||
|
:index-tag [:span :none-style] ;;; Hide the index spans on the left hand of collections. Shows how many elements in a collection.
|
||||||
|
:initial-hierarchy-depth-budget false})
|
||||||
|
|
||||||
|
(def effective-cljs-devtools-prefs (merge default-cljs-devtools-prefs customized-cljs-devtools-prefs))
|
||||||
|
|
||||||
|
(defn make-devtools-api-call [api-fn & args]
|
||||||
|
(with-cljs-devtools-prefs effective-cljs-devtools-prefs
|
||||||
|
(apply api-fn args)))
|
||||||
|
|
||||||
|
(defn cljs-devtools-header [& args]
|
||||||
|
(apply make-devtools-api-call devtools.formatters.core/header-api-call args))
|
||||||
|
|
||||||
|
(defn cljs-devtools-body [& args]
|
||||||
|
(apply make-devtools-api-call devtools.formatters.core/body-api-call args))
|
||||||
|
|
||||||
(defn data-structure [jsonml]
|
(defn data-structure [jsonml]
|
||||||
(let [expanded? (r/atom false)]
|
(let [expanded? (r/atom false)]
|
||||||
(fn [jsonml]
|
(fn [jsonml]
|
||||||
@ -35,10 +49,10 @@
|
|||||||
:on-click #(swap! expanded? not)}
|
:on-click #(swap! expanded? not)}
|
||||||
[:button.expansion-button (if @expanded? "▼" "▶")]]
|
[:button.expansion-button (if @expanded? "▼" "▶")]]
|
||||||
(jsonml->hiccup (if @expanded?
|
(jsonml->hiccup (if @expanded?
|
||||||
(cljs-devtools/body-api-call
|
(cljs-devtools-body
|
||||||
(.-object (get jsonml 1))
|
(.-object (get jsonml 1))
|
||||||
(.-config (get jsonml 1)))
|
(.-config (get jsonml 1)))
|
||||||
(cljs-devtools/header-api-call
|
(cljs-devtools-header
|
||||||
(.-object (get jsonml 1))
|
(.-object (get jsonml 1))
|
||||||
(.-config (get jsonml 1)))))])))
|
(.-config (get jsonml 1)))))])))
|
||||||
|
|
||||||
@ -81,7 +95,7 @@
|
|||||||
(and @expanded?
|
(and @expanded?
|
||||||
(or (string? data)
|
(or (string? data)
|
||||||
(number? data))) [:div {:style {:margin "10px 0"}} data]
|
(number? data))) [:div {:style {:margin "10px 0"}} data]
|
||||||
@expanded? (jsonml->hiccup (cljs-devtools/header-api-call data config)))]])))
|
@expanded? (jsonml->hiccup (cljs-devtools-header data)))]])))
|
||||||
|
|
||||||
(defn render-state [data]
|
(defn render-state [data]
|
||||||
(let [subtree-input (r/atom "")
|
(let [subtree-input (r/atom "")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user