mirror of
https://github.com/penpot/penpot.git
synced 2025-02-10 00:58:26 -05:00
Attach debug related attrs to rendered shapes.
This commit is contained in:
parent
db73b0787b
commit
7933955a69
1 changed files with 26 additions and 15 deletions
|
@ -15,7 +15,13 @@
|
|||
"Extract predefinet attrs from shapes."
|
||||
[shape]
|
||||
(select-keys shape [:rotation :width :height
|
||||
:x :y :opacity :fill]))
|
||||
:x :y :opacity :fill :view-box]))
|
||||
|
||||
(defn- make-debug-attrs
|
||||
[attrs]
|
||||
(let [xf (map (fn [[x v]]
|
||||
[(keyword (str "data-" (name x))) v]))]
|
||||
(into {} xf attrs)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Implementation
|
||||
|
@ -26,12 +32,28 @@
|
|||
(let [key (str "use-" id)
|
||||
transform (-> (merge shape attrs)
|
||||
(svg/calculate-transform))
|
||||
attrs {:id key
|
||||
:key key
|
||||
:transform transform}]
|
||||
attrs {:id key :key key :transform transform}
|
||||
attrs (-> (extract-attrs shape)
|
||||
(make-debug-attrs)
|
||||
(merge attrs))]
|
||||
(html
|
||||
[:g attrs data])))
|
||||
|
||||
(defmethod shapes/-render :builtin/group
|
||||
[{:keys [items id] :as shape} attrs]
|
||||
(let [key (str "group-" id)
|
||||
tfm (-> (merge shape attrs)
|
||||
(svg/calculate-transform))
|
||||
attrs {:id key :key key :transform tfm}
|
||||
attrs (-> (extract-attrs shape)
|
||||
(make-debug-attrs)
|
||||
(merge attrs))
|
||||
shapes-by-id (get @st/state :shapes-by-id)]
|
||||
(html
|
||||
[:g attrs
|
||||
(for [item (map #(get shapes-by-id %) items)]
|
||||
(shapes/-render item nil))])))
|
||||
|
||||
(defmethod shapes/-render-svg :builtin/icon
|
||||
[{:keys [data id view-box] :as shape} attrs]
|
||||
(let [key (str "icon-svg-" id)
|
||||
|
@ -44,14 +66,3 @@
|
|||
(html
|
||||
[:svg attrs data])))
|
||||
|
||||
(defmethod shapes/-render :builtin/group
|
||||
[{:keys [items id] :as shape} attrs]
|
||||
(let [key (str "group-" id)
|
||||
tfm (-> (merge shape attrs)
|
||||
(svg/calculate-transform))
|
||||
attrs {:id key :key key :transform tfm}
|
||||
shapes-by-id (get @st/state :shapes-by-id)]
|
||||
(html
|
||||
[:g attrs
|
||||
(for [item (map #(get shapes-by-id %) items)]
|
||||
(shapes/-render item nil))])))
|
||||
|
|
Loading…
Add table
Reference in a new issue