From 957ad0dae32d3260923f2913bcfe8f77e8406fd0 Mon Sep 17 00:00:00 2001 From: Florian Schroedl Date: Wed, 24 Jul 2024 16:21:48 +0200 Subject: [PATCH] Always highlight if one of the attributes is active, but only apply minimal set on pill click --- frontend/src/app/main/ui/workspace/tokens/changes.cljs | 6 +++--- frontend/src/app/main/ui/workspace/tokens/sidebar.cljs | 4 ++-- frontend/src/app/main/ui/workspace/tokens/token_types.cljs | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/tokens/changes.cljs b/frontend/src/app/main/ui/workspace/tokens/changes.cljs index 5f1711675..b8c610d0a 100644 --- a/frontend/src/app/main/ui/workspace/tokens/changes.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/changes.cljs @@ -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 diff --git a/frontend/src/app/main/ui/workspace/tokens/sidebar.cljs b/frontend/src/app/main/ui/workspace/tokens/sidebar.cljs index 9c2218716..b15f37028 100644 --- a/frontend/src/app/main/ui/workspace/tokens/sidebar.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/sidebar.cljs @@ -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)}])]])]])) diff --git a/frontend/src/app/main/ui/workspace/tokens/token_types.cljs b/frontend/src/app/main/ui/workspace/tokens/token_types.cljs index d3bb2c0e5..01c4c528d 100644 --- a/frontend/src/app/main/ui/workspace/tokens/token_types.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/token_types.cljs @@ -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"