mirror of
https://github.com/status-im/re-frame-10x.git
synced 2025-01-11 22:54:14 +00:00
Add docstring to string->css function
This commit is contained in:
parent
448cee365e
commit
019ebc7748
@ -4,7 +4,11 @@
|
||||
[devtools.formatters.core :as cljs-devtools]))
|
||||
|
||||
(defn string->css [css-string]
|
||||
(->> (str/split (get css-string "style") #";")
|
||||
"This function converts jsonml css-strings to valid css maps for hiccup.
|
||||
Example: 'margin-left:0px;min-height:14px;' converts to
|
||||
{:margin-left '0px', :min-height '14px'}"
|
||||
|
||||
(->> (str/split css-string #";")
|
||||
(map #(str/split % #":"))
|
||||
(reduce (fn [acc [property value]]
|
||||
(assoc acc (keyword property) value)) {})))
|
||||
@ -31,18 +35,19 @@
|
||||
(defn jsonml->hiccup [jsonml]
|
||||
(if (number? jsonml)
|
||||
jsonml
|
||||
(let [[head & args] jsonml
|
||||
tagnames #{"span" "ol" "li" "div"}]
|
||||
(let [[head & args] jsonml
|
||||
tagnames #{"span" "ol" "li" "div"}]
|
||||
(cond
|
||||
(contains? tagnames head) (let [[style & children] args]
|
||||
[(keyword head) {:style (string->css (js->clj style))}
|
||||
[(keyword head) {:style (-> (js->clj style)
|
||||
(get "style")
|
||||
(string->css))}
|
||||
(into [:div {:style {:display "inline-block"}}]
|
||||
(mapv jsonml->hiccup children))])
|
||||
(= head "object") [data-structure jsonml]
|
||||
(= jsonml ", ") " "
|
||||
:else jsonml))))
|
||||
|
||||
|
||||
(defn render-state [data]
|
||||
[:div {:style {:flex "1 0 auto" :width "100%" :height "100%" :display "flex" :flex-direction "column"}}
|
||||
[:div.panel-content-scrollable
|
||||
|
Loading…
x
Reference in New Issue
Block a user