mirror of
https://github.com/penpot/penpot.git
synced 2025-01-10 08:50:57 -05:00
⚡ Add nano optimizations to fo_text react component
This commit is contained in:
parent
43cd4656b4
commit
ee91ab5dad
1 changed files with 11 additions and 10 deletions
|
@ -8,6 +8,7 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.colors :as cc]
|
[app.common.colors :as cc]
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
|
[app.common.data.macros :as dm]
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.main.ui.shapes.attrs :as attrs]
|
[app.main.ui.shapes.attrs :as attrs]
|
||||||
[app.main.ui.shapes.text.styles :as sts]
|
[app.main.ui.shapes.text.styles :as sts]
|
||||||
|
@ -169,16 +170,16 @@
|
||||||
[colors color-mapping color-mapping-inverse]))
|
[colors color-mapping color-mapping-inverse]))
|
||||||
|
|
||||||
(mf/defc text-shape
|
(mf/defc text-shape
|
||||||
{::mf/wrap-props false
|
{::mf/props :obj
|
||||||
::mf/forward-ref true}
|
::mf/forward-ref true}
|
||||||
[props ref]
|
[{:keys [shape grow-type]} ref]
|
||||||
(let [shape (obj/get props "shape")
|
(let [transform (gsh/transform-str shape)
|
||||||
transform (gsh/transform-str shape)
|
id (dm/get-prop shape :id)
|
||||||
|
x (dm/get-prop shape :x)
|
||||||
{:keys [id x y width height content]} shape
|
y (dm/get-prop shape :y)
|
||||||
grow-type (obj/get props "grow-type") ;; This is only needed in workspace
|
width (dm/get-prop shape :width)
|
||||||
;; We add 8px to add a padding for the exporter
|
height (dm/get-prop shape :height)
|
||||||
;; width (+ width 8)
|
content (get shape :content)
|
||||||
|
|
||||||
[colors _color-mapping color-mapping-inverse] (retrieve-colors shape)]
|
[colors _color-mapping color-mapping-inverse] (retrieve-colors shape)]
|
||||||
|
|
||||||
|
@ -186,7 +187,7 @@
|
||||||
{:x x
|
{:x x
|
||||||
:y y
|
:y y
|
||||||
:id id
|
:id id
|
||||||
:data-colors (->> colors (str/join ","))
|
:data-colors (str/join "," colors)
|
||||||
:data-mapping (-> color-mapping-inverse clj->js js/JSON.stringify)
|
:data-mapping (-> color-mapping-inverse clj->js js/JSON.stringify)
|
||||||
:transform transform
|
:transform transform
|
||||||
:width (if (#{:auto-width} grow-type) 100000 width)
|
:width (if (#{:auto-width} grow-type) 100000 width)
|
||||||
|
|
Loading…
Reference in a new issue