Add missing attributes on shape svg rendering.

This commit is contained in:
Andrey Antukh 2016-01-20 19:25:35 +02:00
parent a832bf89b4
commit 49cff5429e

View file

@ -14,14 +14,14 @@
(defn- extract-attrs (defn- extract-attrs
"Extract predefinet attrs from shapes." "Extract predefinet attrs from shapes."
[shape] [shape]
(select-keys shape [:rotation :width :height (select-keys shape [:fill :opacity]))
:x :y :opacity :fill :view-box]))
(defn- make-debug-attrs (defn- make-debug-attrs
[attrs] [shape]
(let [xf (map (fn [[x v]] (let [attrs (select-keys shape [:rotation :width :height :x :y])
[(keyword (str "data-" (name x))) v]))] xf (map (fn [[x v]]
(into {} xf attrs))) [(keyword (str "data-" (name x))) v]))]
(into {} xf attrs)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Implementation ;; Implementation
@ -32,10 +32,9 @@
(let [key (str "use-" id) (let [key (str "use-" id)
transform (-> (merge shape attrs) transform (-> (merge shape attrs)
(svg/calculate-transform)) (svg/calculate-transform))
attrs {:id key :key key :transform transform} attrs (merge {:id key :key key :transform transform}
attrs (-> (extract-attrs shape) (extract-attrs shape)
(make-debug-attrs) (make-debug-attrs shape))]
(merge attrs))]
(html (html
[:g attrs data]))) [:g attrs data])))