0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-06 14:50:20 -05:00

Always highlight if one of the attributes is active, but only apply minimal set on pill click

This commit is contained in:
Florian Schroedl 2024-07-24 16:21:48 +02:00
parent b9b4abf1e0
commit 957ad0dae3
3 changed files with 6 additions and 5 deletions

View file

@ -71,12 +71,12 @@
(ptk/reify ::on-toggle-token
ptk/WatchEvent
(watch [_ _ _]
(let [{:keys [attributes on-update-shape]} token-type-props
unapply-tokens? (wtt/shapes-token-applied? token shapes (:attributes token-type-props))
(let [{:keys [attributes all-attributes on-update-shape]} token-type-props
unapply-tokens? (wtt/shapes-token-applied? token shapes (or all-attributes attributes))
shape-ids (map :id shapes)]
(if unapply-tokens?
(rx/of
(unapply-token {:attributes attributes
(unapply-token {:attributes (or all-attributes attributes)
:token token
:shape-ids shape-ids}))
(rx/of

View file

@ -72,7 +72,7 @@
[{:keys [type tokens selected-shapes token-type-props]}]
(let [open? (mf/deref (-> (l/key type)
(l/derived lens:token-type-open-status)))
{:keys [modal attributes title]} token-type-props
{:keys [modal attributes all-attributes title]} token-type-props
on-context-menu (mf/use-fn
(fn [event token]
@ -124,7 +124,7 @@
[:& token-pill
{:key (:id token)
:token token
:highlighted? (wtt/shapes-token-applied? token selected-shapes attributes)
:highlighted? (wtt/shapes-token-applied? token selected-shapes (or all-attributes attributes))
:on-click #(on-token-pill-click % token)
:on-context-menu #(on-context-menu % token)}])]])]]))

View file

@ -24,6 +24,7 @@
[:sizing
{:title "Sizing"
:attributes #{:width :height}
:all-attributes ctt/sizing-keys
:on-update-shape wtch/update-shape-dimensions
:modal {:key :tokens/sizing
:fields [{:label "Sizing"