0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-16 08:51:32 -05:00

Add icon-raw shape related components.

This commit is contained in:
Andrey Antukh 2016-10-21 00:22:41 +02:00
parent 27f1884a47
commit 050e291e0f

View file

@ -13,6 +13,7 @@
;; --- Icon Component
(declare icon-shape)
(declare icon-raw-shape)
(mx/defc icon-component
{:mixins [mx/static mx/reactive]}
@ -24,18 +25,44 @@
:on-mouse-down on-mouse-down}
(icon-shape shape identity)]))
(mx/defc icon-raw-component
{:mixins [mx/static mx/reactive]}
[{:keys [id] :as shape}]
(let [selected (mx/react common/selected-ref)
selected? (contains? selected id)
on-mouse-down #(common/on-mouse-down % shape selected)]
[:g.shape {:class (when selected? "selected")
:on-mouse-down on-mouse-down}
(icon-raw-shape shape identity)]))
;; --- Icon Shape
(mx/defc icon-shape
{:mixins [mx/static]}
[{:keys [data id] :as shape} factory]
(let [key (str "shape-" id)
(let [key (str "shape-icon-" id)
rfm (geom/transformation-matrix shape)
attrs (merge {:id key :key key :transform (str rfm)}
(attrs/extract-style-attrs shape)
(attrs/make-debug-attrs shape))]
[:g attrs data]))
(mx/defc icon-raw-shape
{:mixins [mx/static]}
[{:keys [x1 y1 content id metadata] :as shape} factory]
(let [key (str "shape-icon-raw-" id)
;; rfm (geom/transformation-matrix shape)
view-box (apply str (interpose " " (:view-box metadata)))
size (geom/size shape)
attrs (merge {:id key :key key ;; :transform (str rfm)
:x x1 :y y1 :view-box view-box
:preserve-aspect-ratio "none"
:dangerouslySetInnerHTML {:__html content}}
size
(attrs/extract-style-attrs shape)
(attrs/make-debug-attrs shape))]
[:svg attrs]))
;; --- Icon SVG
(mx/defc icon-svg