mirror of
https://github.com/penpot/penpot.git
synced 2025-08-07 14:38:33 +02:00
⚡ Don't create function references for token-pill callbacks
This commit is contained in:
parent
333cc5996c
commit
a53c37bc3c
3 changed files with 11 additions and 12 deletions
|
@ -133,13 +133,11 @@
|
||||||
[:& cmm/asset-section-block {:role :content}
|
[:& cmm/asset-section-block {:role :content}
|
||||||
[:div {:class (stl/css :token-pills-wrapper)}
|
[:div {:class (stl/css :token-pills-wrapper)}
|
||||||
(for [token (sort-by :name tokens)]
|
(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))
|
multiple-selection (< 1 (count selected-shapes))
|
||||||
full-applied (:all-selected? (attribute-actions token selected-shapes (or all-attributes attributes)))
|
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))
|
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))]
|
|
||||||
[:> token-pill*
|
[:> token-pill*
|
||||||
{:key (:name token)
|
{:key (:name token)
|
||||||
:token-type-props token-type-props
|
:token-type-props token-type-props
|
||||||
|
@ -151,7 +149,7 @@
|
||||||
:full-applied (if multiple-selection
|
:full-applied (if multiple-selection
|
||||||
false
|
false
|
||||||
applied)
|
applied)
|
||||||
:on-click on-token-click
|
:on-click on-token-pill-click
|
||||||
:on-context-menu on-context-menu}]))]])]]))
|
:on-context-menu on-context-menu}]))]])]]))
|
||||||
|
|
||||||
(defn sorted-token-groups
|
(defn sorted-token-groups
|
||||||
|
|
|
@ -21,7 +21,9 @@
|
||||||
{:value parsed-value
|
{:value parsed-value
|
||||||
:unit unit}))))
|
:unit unit}))))
|
||||||
|
|
||||||
(defn token-identifier [{:keys [name] :as _token}]
|
;; FIXME: looks very redundant function
|
||||||
|
(defn token-identifier
|
||||||
|
[{:keys [name] :as _token}]
|
||||||
name)
|
name)
|
||||||
|
|
||||||
(defn attributes-map
|
(defn attributes-map
|
||||||
|
|
|
@ -142,7 +142,6 @@
|
||||||
(contains? active-tokens match)))
|
(contains? active-tokens match)))
|
||||||
|
|
||||||
(mf/defc token-pill*
|
(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]}]
|
[{: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
|
(let [{:keys [name value errors]} token
|
||||||
|
|
||||||
|
@ -167,11 +166,11 @@
|
||||||
|
|
||||||
on-click
|
on-click
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps errors? on-click)
|
(mf/deps errors? on-click token)
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(when (and (not (seq errors)) on-click)
|
(when (and (not (seq errors)) on-click)
|
||||||
(on-click event))))
|
(on-click event token))))
|
||||||
|
|
||||||
token-status-id
|
token-status-id
|
||||||
(cond
|
(cond
|
||||||
|
@ -184,11 +183,11 @@
|
||||||
|
|
||||||
on-context-menu
|
on-context-menu
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps can-edit? on-context-menu)
|
(mf/deps can-edit? on-context-menu token)
|
||||||
(fn [e]
|
(fn [e]
|
||||||
(dom/stop-propagation e)
|
(dom/stop-propagation e)
|
||||||
(when can-edit?
|
(when can-edit?
|
||||||
(on-context-menu e))))
|
(on-context-menu e token))))
|
||||||
|
|
||||||
on-click
|
on-click
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue