mirror of
https://github.com/penpot/penpot.git
synced 2025-06-02 03:41:43 +02:00
✨ SVG generation first version
This commit is contained in:
parent
28f90da70e
commit
96098be5ae
19 changed files with 104 additions and 99 deletions
|
@ -33,8 +33,7 @@
|
|||
:cy cy
|
||||
:rx rx
|
||||
:ry ry
|
||||
:transform transform
|
||||
:id (str "shape-" id)}))]
|
||||
:transform transform}))]
|
||||
|
||||
[:& shape-custom-stroke {:shape shape
|
||||
:base-props props
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
(obj/merge!
|
||||
#js {:x 0
|
||||
:y 0
|
||||
:id (str "shape-" id)
|
||||
:width width
|
||||
:height height}))]
|
||||
[:svg {:x x :y y :width width :height height
|
||||
|
|
|
@ -54,7 +54,6 @@
|
|||
:y y
|
||||
:fill (if (debug? :group) "red" "transparent")
|
||||
:opacity 0.5
|
||||
:id (str "group-" id)
|
||||
:width width
|
||||
:height height}])])))
|
||||
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
;; defined by the Mozilla Public License, v. 2.0.
|
||||
;;
|
||||
;; Copyright (c) 2020 UXBOX Labs SL
|
||||
|
||||
(ns app.main.ui.shapes.icon
|
||||
(:require
|
||||
[rumext.alpha :as mf]
|
||||
[app.common.geom.shapes :as geom]
|
||||
[app.main.ui.shapes.attrs :as attrs]
|
||||
[app.main.ui.shapes.group :refer [mask-id-ctx]]
|
||||
[app.util.object :as obj]))
|
||||
|
||||
(mf/defc icon-shape
|
||||
{::mf/wrap-props false}
|
||||
[props]
|
||||
(let [shape (unchecked-get props "shape")
|
||||
{:keys [id x y width height metadata rotation content]} shape
|
||||
|
||||
mask-id (mf/use-ctx mask-id-ctx)
|
||||
transform (geom/transform-matrix shape)
|
||||
vbox (apply str (interpose " " (:view-box metadata)))
|
||||
|
||||
props (-> (attrs/extract-style-attrs shape)
|
||||
(obj/merge!
|
||||
#js {:x x
|
||||
:y y
|
||||
:transform transform
|
||||
:id (str "shape-" id)
|
||||
:width width
|
||||
:height height
|
||||
:viewBox vbox
|
||||
:preserveAspectRatio "none"
|
||||
:mask mask-id
|
||||
:dangerouslySetInnerHTML #js {:__html content}}))]
|
||||
[:g {:transform transform}
|
||||
[:> "svg" props]]))
|
||||
|
||||
(mf/defc icon-svg
|
||||
[{:keys [shape] :as props}]
|
||||
(let [{:keys [content id metadata]} shape
|
||||
view-box (apply str (interpose " " (:view-box metadata)))
|
||||
mask-id (mf/use-ctx mask-id-ctx)
|
||||
props {:viewBox view-box
|
||||
:id (str "shape-" id)
|
||||
:mask mask-id
|
||||
:dangerouslySetInnerHTML #js {:__html content}}]
|
||||
[:& "svg" props]))
|
|
@ -43,7 +43,6 @@
|
|||
#js {:x x
|
||||
:y y
|
||||
:transform transform
|
||||
:id (str "shape-" id)
|
||||
:width width
|
||||
:height height
|
||||
:preserveAspectRatio "none"
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
props (-> (attrs/extract-style-attrs shape)
|
||||
(obj/merge!
|
||||
#js {:transform transform
|
||||
:id (str "shape-" id)
|
||||
:d pdata}))]
|
||||
(if background?
|
||||
[:g {:mask mask-id}
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#js {:x x
|
||||
:y y
|
||||
:transform transform
|
||||
:id (str "shape-" id)
|
||||
:width width
|
||||
:height height}))]
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
group-props (-> props
|
||||
(obj/clone)
|
||||
(obj/without ["shape" "children"])
|
||||
(obj/set! "id" (str "shape-" (:id shape)))
|
||||
(obj/set! "className" "shape")
|
||||
(obj/set! "filter" (filters/filter-str filter-id shape)))]
|
||||
[:& (mf/provider muc/render-ctx) {:value render-id}
|
||||
|
|
|
@ -231,7 +231,6 @@
|
|||
:y y
|
||||
:data-colors (retrieve-colors shape)
|
||||
:transform (geom/transform-matrix shape)
|
||||
:id (str id)
|
||||
:width width
|
||||
:height height
|
||||
:mask mask-id}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue