diff --git a/src/day8/re_frame/trace/app_state.cljs b/src/day8/re_frame/trace/app_state.cljs index d6680b4..963b38b 100644 --- a/src/day8/re_frame/trace/app_state.cljs +++ b/src/day8/re_frame/trace/app_state.cljs @@ -5,31 +5,6 @@ [cljs.pprint :refer [pprint]])) -(defn css-munge - [string] - (str/replace string #"\.|/" "-")) - -(defn namespace-css - [classname] - (str "re-frame-trace--" classname)) - -(defn type-string - [obj] - (cond - (number? obj) "number" - (boolean? obj) "boolean" - (string? obj) "string" - (nil? obj) "nil" - (keyword? obj) "keyword" - (symbol? obj) "symbol" - :else (pr-str (type obj)))) - -(defn view - [data] - (if (coll? data) - [:div {:class (str (namespace-css "collection") " " (namespace-css (css-munge (type-string data))))}] - [:span {:class (str (namespace-css "primative") " " (namespace-css (css-munge (type-string data))))} (str data)])) - (defn string->css [css-string] (->> (map #(str/split % #":") (str/split (get css-string "style") #";")) (reduce (fn [acc [property value]] @@ -42,12 +17,6 @@ (= string ", ") " " :else string)) -(defn crawl - [data] - (if (coll? data) - (into (view data) (mapv crawl data)) - (view data))) - (declare jsonml->hiccup) (defn data-structure @@ -68,10 +37,11 @@ [jsonml] (cond (and (array? jsonml) - (= "object" (get jsonml 0))) [data-structure jsonml] + (= "object" (first jsonml))) [data-structure jsonml] (array? jsonml) (mapv jsonml->hiccup jsonml) (object? jsonml) {:style (string->css (js->clj jsonml))} - :else (str->hiccup jsonml))) + (or (string? jsonml) + (integer? jsonml)) (str->hiccup jsonml))) (defn tab [data] [:div {:style {:flex "1 0 auto" :width "100%" :height "100%" :display "flex" :flex-direction "column"}}