Add the ability to render external svgs.

This commit is contained in:
Andrey Antukh 2015-12-26 16:43:26 +02:00
parent 517b3f6db3
commit 75b3aaf2a6
3 changed files with 33 additions and 4 deletions

View file

@ -24,12 +24,29 @@
(assoc data :view-box (apply str (interpose " " view-box)))
data))
(defn extract-attrs
"Extract predefinet attrs from shapes."
[shape]
(select-keys shape [:width :height :view-box :x :y :cx :cy]))
(defmethod -render :builtin/icon
[{:keys [data width height view-box] :as shape} attrs]
[{:keys [data] :as shape} attrs]
(let [attrs (as-> shape $
(select-keys $ [:width :height :view-box])
(extract-attrs $)
(remove-nil-vals $)
(merge $ attrs)
(transform-attrs $))]
(html
[:svg attrs data])))
(defmethod -render :builtin/icon-svg
[{:keys [image] :as shape} attrs]
(let [attrs (as-> shape $
(extract-attrs $)
(remove-nil-vals $)
(merge $ attrs)
(transform-attrs $))]
(html
[:svg attrs
[:image image]])))