From 506ee537f165708d6f49a727cec3e63ad9b5b295 Mon Sep 17 00:00:00 2001 From: "chris (daiyi)" Date: Wed, 30 Aug 2017 16:30:02 +0200 Subject: [PATCH] Create app-state tab --- src/day8/re_frame/trace.cljs | 8 ++++++-- src/day8/re_frame/trace/app_state.cljs | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 src/day8/re_frame/trace/app_state.cljs diff --git a/src/day8/re_frame/trace.cljs b/src/day8/re_frame/trace.cljs index 45ac82b..66a8a1c 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] @@ -391,11 +392,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))