diff --git a/src/day8/re_frame/trace.cljs b/src/day8/re_frame/trace.cljs index 96d99fb..851ef82 100644 --- a/src/day8/re_frame/trace.cljs +++ b/src/day8/re_frame/trace.cljs @@ -1,5 +1,6 @@ (ns day8.re-frame.trace (:require [day8.re-frame.trace.subvis :as subvis] + [day8.re-frame.trace.app-state :as app-state] [day8.re-frame.trace.styles :as styles] [day8.re-frame.trace.components :as components] [day8.re-frame.trace.localstorage :as localstorage] @@ -331,11 +332,14 @@ [:button {:class (str "tab button " (when (= @selected-tab :traces) "active")) :on-click #(reset! selected-tab :traces)} "Traces"] [:button {:class (str "tab button " (when (= @selected-tab :subvis) "active")) - :on-click #(reset! selected-tab :subvis)} "SubVis"]]] + :on-click #(reset! selected-tab :subvis)} "SubVis"] + [:button {:class (str "tab button " (when (= @selected-tab :app-state) "active")) + :on-click #(reset! selected-tab :app-state)} "app-state"]]] (case @selected-tab :traces [render-trace-panel] :subvis [subvis/render-subvis traces - [:div.panel-content-scrollable]])]]]))}))) + [:div.panel-content-scrollable]] + :app-state [app-state/tab @traces])]]]))}))) (defn panel-div [] (let [id "--re-frame-trace--" diff --git a/src/day8/re_frame/trace/app_state.cljs b/src/day8/re_frame/trace/app_state.cljs new file mode 100644 index 0000000..15f794b --- /dev/null +++ b/src/day8/re_frame/trace/app_state.cljs @@ -0,0 +1,23 @@ +(ns day8.re-frame.trace.app-state + (:require [reagent.core :as r] + [clojure.string :as str])) + +(defn classname + [obj] + (str/replace (pr-str (type obj)) #"\.|/" "-")) + +(defn view + [data] + (if (string? data) + [:span.data-string data] + [:div {:class (classname data)}])) + +(defn crawl + [data] + (if (coll? data) + (into (view data) (mapv crawl data)) + (view data))) + +(defn tab [data] + (println (crawl data)) + (crawl data))