0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-21 06:02:32 -05:00

💄 Add syntax optimization for gradient handlers component

This commit is contained in:
Andrey Antukh 2024-12-10 14:04:13 +01:00
parent 848db3f13c
commit 969c6a2e2f
4 changed files with 10 additions and 8 deletions

View file

@ -162,7 +162,7 @@
(mf/defc workspace*
{::mf/wrap-props false
{::mf/props :obj
::mf/wrap [mf/memo]}
[{:keys [project-id file-id page-id layout-name]}]

View file

@ -622,7 +622,7 @@
:hover-disabled? hover-disabled?}])])
(when show-gradient-handlers?
[:& gradients/gradient-handlers
[:> gradients/gradient-handlers*
{:id (first selected)
:zoom zoom}])

View file

@ -441,8 +441,9 @@
:r (/ 4 zoom)
:fill "var(--app-white)"}]))]))
(mf/defc gradient-handlers*
[{:keys [zoom stops gradient editing shape] :as kk}]
(mf/defc gradient-handlers-impl*
{::mf/props :obj}
[{:keys [zoom stops gradient editing shape]}]
(let [transform (gsh/transform-matrix shape)
transform-inverse (gsh/inverse-transform-matrix shape)
@ -509,8 +510,9 @@
:on-change-finish on-change-finish
:on-change-width on-change-width}]))
(mf/defc gradient-handlers
{::mf/wrap [mf/memo]}
(mf/defc gradient-handlers*
{::mf/wrap [mf/memo]
::mf/props :obj}
[{:keys [id zoom]}]
(let [shape-ref (mf/use-memo (mf/deps id) #(refs/object-by-id id))
shape (mf/deref shape-ref)
@ -520,7 +522,7 @@
editing-stop (:editing-stop state)]
(when (and (some? gradient) (= id (:shape-id gradient)))
[:& gradient-handlers*
[:> gradient-handlers-impl*
{:zoom zoom
:gradient gradient
:stops stops

View file

@ -617,7 +617,7 @@
:hover-disabled? hover-disabled?}])])
(when show-gradient-handlers?
[:& gradients/gradient-handlers
[:> gradients/gradient-handlers*
{:id (first selected)
:zoom zoom}])