mirror of
https://github.com/status-im/re-frame-10x.git
synced 2025-02-04 10:23:39 +00:00
Add css styles from jsonml
This commit is contained in:
parent
3a2f14cf32
commit
64815b3aa6
@ -456,6 +456,9 @@
|
||||
color: #8f8f8f;
|
||||
content: "}";
|
||||
}
|
||||
#--re-frame-trace-- .re-frame-trace--object {
|
||||
display: block;
|
||||
}
|
||||
#--re-frame-trace-- .re-frame-trace--object:before {
|
||||
color: #8f8f8f;
|
||||
content: "▶ ";
|
||||
|
@ -579,5 +579,6 @@
|
||||
color: @text-color-muted;
|
||||
content: "▶ ";
|
||||
}
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
@ -30,14 +30,16 @@
|
||||
[: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 jsonml-style
|
||||
[style-map]
|
||||
{:style {:background "rgba(0,0,0,0.04)"}})
|
||||
(defn string->css [css-string]
|
||||
(->> (map #(str/split % #":") (str/split (get css-string "style") #";"))
|
||||
(reduce (fn [acc [property value]]
|
||||
(assoc acc (keyword property) value)) {})))
|
||||
|
||||
(defn str->hiccup
|
||||
[string]
|
||||
(cond (= string "span") :span
|
||||
(= string "style") :style
|
||||
(= string ", ") " "
|
||||
:else string))
|
||||
|
||||
(defn crawl
|
||||
@ -55,7 +57,7 @@
|
||||
(.-object (get jsonml 1))
|
||||
(.-config (get jsonml 1))))]
|
||||
(mapv jsonml->hiccup jsonml))
|
||||
(object? jsonml) (jsonml-style jsonml)
|
||||
(object? jsonml) {:style (string->css (js->clj jsonml))}
|
||||
:else (str->hiccup jsonml)))
|
||||
|
||||
(defn tab [data]
|
||||
|
Loading…
x
Reference in New Issue
Block a user