0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-23 23:35:58 -05:00

Don't create function references for token-pill callbacks

This commit is contained in:
Andrey Antukh 2025-02-04 18:13:07 +01:00
parent 333cc5996c
commit a53c37bc3c
3 changed files with 11 additions and 12 deletions

View file

@ -133,13 +133,11 @@
[:& cmm/asset-section-block {:role :content}
[:div {:class (stl/css :token-pills-wrapper)}
(for [token (sort-by :name tokens)]
(let [theme-token (get active-theme-tokens (wtt/token-identifier token))
(let [theme-token (get active-theme-tokens (:name token))
multiple-selection (< 1 (count selected-shapes))
full-applied (:all-selected? (attribute-actions token selected-shapes (or all-attributes attributes)))
applied (wtt/shapes-token-applied? token selected-shapes (or all-attributes attributes))
on-token-click (fn [e]
(on-token-pill-click e token))
on-context-menu (fn [e] (on-context-menu e token))]
applied (wtt/shapes-token-applied? token selected-shapes (or all-attributes attributes))]
[:> token-pill*
{:key (:name token)
:token-type-props token-type-props
@ -151,7 +149,7 @@
:full-applied (if multiple-selection
false
applied)
:on-click on-token-click
:on-click on-token-pill-click
:on-context-menu on-context-menu}]))]])]]))
(defn sorted-token-groups

View file

@ -21,7 +21,9 @@
{:value parsed-value
:unit unit}))))
(defn token-identifier [{:keys [name] :as _token}]
;; FIXME: looks very redundant function
(defn token-identifier
[{:keys [name] :as _token}]
name)
(defn attributes-map

View file

@ -142,7 +142,6 @@
(contains? active-tokens match)))
(mf/defc token-pill*
{::mf/wrap-props false}
[{:keys [on-click token full-applied on-context-menu half-applied selected-shapes token-type-props active-theme-tokens]}]
(let [{:keys [name value errors]} token
@ -167,11 +166,11 @@
on-click
(mf/use-fn
(mf/deps errors? on-click)
(mf/deps errors? on-click token)
(fn [event]
(dom/stop-propagation event)
(when (and (not (seq errors)) on-click)
(on-click event))))
(on-click event token))))
token-status-id
(cond
@ -184,11 +183,11 @@
on-context-menu
(mf/use-fn
(mf/deps can-edit? on-context-menu)
(mf/deps can-edit? on-context-menu token)
(fn [e]
(dom/stop-propagation e)
(when can-edit?
(on-context-menu e))))
(on-context-menu e token))))
on-click
(mf/use-fn