🐛 Fix applying color tokens on a row from colorpicker (#7524)

This commit is contained in:
Eva Marco
2025-10-17 11:10:10 +02:00
committed by GitHub
parent 2f27a78bc0
commit bbc6709943
20 changed files with 58 additions and 110 deletions

View File

@@ -466,6 +466,7 @@
(ptk/reify ::apply-token (ptk/reify ::apply-token
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [_ state _]
(prn "apply token" token attributes shape-ids)
;; We do not allow to apply tokens while text editor is open. ;; We do not allow to apply tokens while text editor is open.
(when (empty? (get state :workspace-editor-state)) (when (empty? (get state :workspace-editor-state))
(let [attributes-to-remove (let [attributes-to-remove
@@ -560,13 +561,23 @@
(update shape :applied-tokens remove-token)))))))) (update shape :applied-tokens remove-token))))))))
(defn toggle-token (defn toggle-token
[{:keys [token shapes attrs]}] [{:keys [token attrs shape-ids expand-with-children]}]
(ptk/reify ::on-toggle-token (ptk/reify ::on-toggle-token
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ _] (watch [_ state _]
(let [{:keys [attributes all-attributes on-update-shape]} (let [objects (dsh/lookup-page-objects state)
shapes (into [] (keep (d/getf objects)) shape-ids)
shapes
(if expand-with-children
(into []
(mapcat (fn [shape]
(if (= (:type shape) :group)
(keep objects (:shapes shape))
[shape])))
shapes)
shapes)
{:keys [attributes all-attributes on-update-shape]}
(get token-properties (:type token)) (get token-properties (:type token))
unapply-tokens? unapply-tokens?
(cft/shapes-token-applied? token shapes (or attrs all-attributes attributes)) (cft/shapes-token-applied? token shapes (or attrs all-attributes attributes))
shape-ids (map :id shapes)] shape-ids (map :id shapes)]

View File

@@ -41,6 +41,7 @@
(mf/use-fn (mf/use-fn
(mf/deps token on-token-pill-click) (mf/deps token on-token-pill-click)
(fn [event] (fn [event]
(prn "entro en el on-click")
(on-token-pill-click event token))) (on-token-pill-click event token)))
id-tooltip (mf/use-id) id-tooltip (mf/use-id)
resolved (:resolved-value token) resolved (:resolved-value token)
@@ -138,6 +139,7 @@
(fn [event token] (fn [event token]
(dom/stop-propagation event) (dom/stop-propagation event)
(when (seq selected-shapes) (when (seq selected-shapes)
(prn "entro en on-token-pill-click")
(on-token-change event token)))) (on-token-change event token))))
create-token-on-set create-token-on-set

View File

@@ -143,7 +143,6 @@
edit-grid? edit-grid?
[:& layout-container/grid-layout-edition [:& layout-container/grid-layout-edition
{:ids [edition] {:ids [edition]
:shapes shapes
:values (get objects edition)}] :values (get objects edition)}]
(some? sp-panel) (some? sp-panel)

View File

@@ -56,20 +56,17 @@
n-vals (unchecked-get n-props "values") n-vals (unchecked-get n-props "values")
o-fills (get o-vals :fills) o-fills (get o-vals :fills)
n-fills (get n-vals :fills) n-fills (get n-vals :fills)
o-objects (get o-vals :objects)
n-objects (get n-vals :objects)
o-applied-tokens (get o-vals :applied-tokens) o-applied-tokens (get o-vals :applied-tokens)
n-applied-tokens (get n-vals :applied-tokens) n-applied-tokens (get n-vals :applied-tokens)
o-hide (get o-vals :hide-fill-on-export) o-hide (get o-vals :hide-fill-on-export)
n-hide (get n-vals :hide-fill-on-export)] n-hide (get n-vals :hide-fill-on-export)]
(and (identical? o-hide n-hide) (and (identical? o-hide n-hide)
(identical? o-applied-tokens n-applied-tokens) (identical? o-applied-tokens n-applied-tokens)
(identical? o-fills n-fills) (identical? o-fills n-fills)))))
(identical? o-objects n-objects)))))
(mf/defc fill-menu* (mf/defc fill-menu*
{::mf/wrap [#(mf/memo' % check-props)]} {::mf/wrap [#(mf/memo' % check-props)]}
[{:keys [ids type values applied-tokens shapes objects]}] [{:keys [ids type values applied-tokens]}]
(let [fills (get values :fills) (let [fills (get values :fills)
hide-on-export (get values :hide-fill-on-export false) hide-on-export (get values :hide-fill-on-export false)
@@ -175,25 +172,13 @@
on-token-change on-token-change
(mf/use-fn (mf/use-fn
(mf/deps shapes objects) (mf/deps ids)
(fn [_ token] (fn [_ token]
(let [expanded-shapes (st/emit!
(if (= 1 (count shapes)) (dwta/toggle-token {:token token
(let [shape (first shapes)] :attrs #{:fill}
(if (= (:type shape) :group) :shape-ids ids
(keep objects (:shapes shape)) :expand-with-children true}))))
[shape]))
(mapcat (fn [shape]
(if (= (:type shape) :group)
(keep objects (:shapes shape))
[shape]))
shapes))]
(st/emit!
(dwta/toggle-token {:token token
:attrs #{:fill}
:shapes expanded-shapes})))))
on-detach-token on-detach-token
(mf/use-fn (mf/use-fn

View File

@@ -340,7 +340,7 @@
(select-padding false false false false)) (select-padding false false false false))
(mf/defc simple-padding-selection* (mf/defc simple-padding-selection*
[{:keys [value on-change shapes applied-tokens ids]}] [{:keys [value on-change applied-tokens ids]}]
(let [token-numeric-inputs (let [token-numeric-inputs
(features/use-feature "tokens/numeric-input") (features/use-feature "tokens/numeric-input")
@@ -373,7 +373,7 @@
nil) nil)
on-change' on-change'
(mf/use-fn (mf/use-fn
(mf/deps on-change shapes) (mf/deps on-change ids)
(fn [value attr event] (fn [value attr event]
(if (or (string? value) (int? value)) (if (or (string? value) (int? value))
(on-change :simple attr value event) (on-change :simple attr value event)
@@ -381,7 +381,7 @@
(let [resolved-value (:resolved-value (first value))] (let [resolved-value (:resolved-value (first value))]
(st/emit! (dwta/toggle-token {:token (first value) (st/emit! (dwta/toggle-token {:token (first value)
:attrs #{attr} :attrs #{attr}
:shapes shapes})) :shape-ids ids}))
(on-change :simple attr resolved-value event)))))) (on-change :simple attr resolved-value event))))))
on-detach-token on-detach-token
@@ -474,7 +474,7 @@
:value p2}]])])) :value p2}]])]))
(mf/defc multiple-padding-selection* (mf/defc multiple-padding-selection*
[{:keys [value on-change shapes applied-tokens ids]}] [{:keys [value on-change applied-tokens ids]}]
(let [token-numeric-inputs (let [token-numeric-inputs
(features/use-feature "tokens/numeric-input") (features/use-feature "tokens/numeric-input")
@@ -485,7 +485,7 @@
on-change' on-change'
(mf/use-fn (mf/use-fn
(mf/deps on-change shapes) (mf/deps on-change ids)
(fn [value attr event] (fn [value attr event]
(if (or (string? value) (int? value)) (if (or (string? value) (int? value))
(on-change :multiple attr value event) (on-change :multiple attr value event)
@@ -493,7 +493,7 @@
(let [resolved-value (:resolved-value (first value))] (let [resolved-value (:resolved-value (first value))]
(st/emit! (dwta/toggle-token {:token (first value) (st/emit! (dwta/toggle-token {:token (first value)
:attrs #{attr} :attrs #{attr}
:shapes shapes})) :shape-ids ids}))
(on-change :multiple attr resolved-value event)))))) (on-change :multiple attr resolved-value event))))))
on-focus on-focus
@@ -701,7 +701,7 @@
(select-gap! nil)) (select-gap! nil))
(mf/defc gap-section* (mf/defc gap-section*
[{:keys [is-column wrap-type on-change value applied-tokens shapes ids] [{:keys [is-column wrap-type on-change value applied-tokens ids]
:as props}] :as props}]
(let [token-numeric-inputs (let [token-numeric-inputs
(features/use-feature "tokens/numeric-input") (features/use-feature "tokens/numeric-input")
@@ -718,7 +718,7 @@
on-change' on-change'
(mf/use-fn (mf/use-fn
(mf/deps on-change wrap-type) (mf/deps on-change wrap-type ids)
(fn [value attr event] (fn [value attr event]
(if (or (string? value) (int? value)) (if (or (string? value) (int? value))
@@ -727,7 +727,7 @@
(let [resolved-value (:resolved-value (first value))] (let [resolved-value (:resolved-value (first value))]
(st/emit! (dwta/toggle-token {:token (first value) (st/emit! (dwta/toggle-token {:token (first value)
:attrs #{attr} :attrs #{attr}
:shapes shapes})) :shape-ids ids}))
(on-change (= "nowrap" wrap-type) attr resolved-value event)))))) (on-change (= "nowrap" wrap-type) attr resolved-value event))))))
on-detach-token on-detach-token
@@ -1083,7 +1083,7 @@
(mf/defc layout-container-menu (mf/defc layout-container-menu
{::mf/memo #{:ids :values :multiple :shapes :applied-tokens}} {::mf/memo #{:ids :values :multiple :shapes :applied-tokens}}
[{:keys [ids values multiple shapes applied-tokens]}] [{:keys [ids values multiple applied-tokens]}]
(let [;; Display (let [;; Display
layout-type (:layout values) layout-type (:layout values)
has-layout? (some? layout-type) has-layout? (some? layout-type)
@@ -1339,14 +1339,12 @@
[:> gap-section* {:is-column is-column [:> gap-section* {:is-column is-column
:wrap-type wrap-type :wrap-type wrap-type
:on-change on-gap-change :on-change on-gap-change
:shapes shapes
:ids ids :ids ids
:applied-tokens applied-tokens :applied-tokens applied-tokens
:value (:layout-gap values)}] :value (:layout-gap values)}]
[:> padding-section* {:value (:layout-padding values) [:> padding-section* {:value (:layout-padding values)
:type (:layout-padding-type values) :type (:layout-padding-type values)
:on-type-change on-padding-type-change :on-type-change on-padding-type-change
:shapes shapes
:ids ids :ids ids
:applied-tokens applied-tokens :applied-tokens applied-tokens
:on-change on-padding-change}]]] :on-change on-padding-change}]]]
@@ -1384,14 +1382,12 @@
[:div {:class (stl/css :gap-row)} [:div {:class (stl/css :gap-row)}
[:> gap-section* {:on-change on-gap-change [:> gap-section* {:on-change on-gap-change
:shapes shapes
:ids ids :ids ids
:applied-tokens applied-tokens :applied-tokens applied-tokens
:value (:layout-gap values)}]] :value (:layout-gap values)}]]
[:div {:class (stl/css :padding-row)} [:div {:class (stl/css :padding-row)}
[:> padding-section* {:value (:layout-padding values) [:> padding-section* {:value (:layout-padding values)
:type (:layout-padding-type values) :type (:layout-padding-type values)
:shapes shapes
:applied-tokens applied-tokens :applied-tokens applied-tokens
:on-type-change on-padding-type-change :on-type-change on-padding-type-change
:on-change on-padding-change}]]] :on-change on-padding-change}]]]
@@ -1399,8 +1395,8 @@
nil))])) nil))]))
(mf/defc grid-layout-edition (mf/defc grid-layout-edition
{::mf/memo #{:ids :values :shapes :applied-tokens}} {::mf/memo #{:ids :values :applied-tokens}}
[{:keys [ids values shapes applied-tokens]}] [{:keys [ids values applied-tokens]}]
(let [;; Gap (let [;; Gap
saved-grid-dir (:layout-grid-dir values) saved-grid-dir (:layout-grid-dir values)
@@ -1584,7 +1580,6 @@
[:div {:class (stl/css :gap-row)} [:div {:class (stl/css :gap-row)}
[:> gap-section* {:on-change on-gap-change [:> gap-section* {:on-change on-gap-change
:shapes shapes
:ids ids :ids ids
:applied-tokens applied-tokens :applied-tokens applied-tokens
:value (:layout-gap values)}]] :value (:layout-gap values)}]]

View File

@@ -313,7 +313,7 @@
(st/emit! (udw/trigger-bounding-box-cloaking ids) (st/emit! (udw/trigger-bounding-box-cloaking ids)
(dwta/toggle-token {:token (first value) (dwta/toggle-token {:token (first value)
:attrs #{attr} :attrs #{attr}
:shapes shapes})) :shape-ids ids}))
(binding [cts/*wasm-sync* true] (binding [cts/*wasm-sync* true]
(run! #(do-size-change resolved-value attr) shapes))))))) (run! #(do-size-change resolved-value attr) shapes)))))))
@@ -344,7 +344,7 @@
(st/emit! (udw/trigger-bounding-box-cloaking ids) (st/emit! (udw/trigger-bounding-box-cloaking ids)
(dwta/toggle-token {:token (first value) (dwta/toggle-token {:token (first value)
:attrs #{attr} :attrs #{attr}
:shapes shapes})) :shape-ids ids}))
(binding [cts/*wasm-sync* true] (binding [cts/*wasm-sync* true]
(run! #(do-position-change %1 resolved-value attr) shapes))))))) (run! #(do-position-change %1 resolved-value attr) shapes)))))))
@@ -369,7 +369,7 @@
(st/emit! (udw/trigger-bounding-box-cloaking ids) (st/emit! (udw/trigger-bounding-box-cloaking ids)
(dwta/toggle-token {:token (first value) (dwta/toggle-token {:token (first value)
:attrs #{:rotation} :attrs #{:rotation}
:shapes shapes})) :shape-ids ids}))
(binding [cts/*wasm-sync* true] (binding [cts/*wasm-sync* true]
(run! #(do-rotation-change resolved-value) shapes))))))) (run! #(do-rotation-change resolved-value) shapes)))))))

View File

@@ -38,8 +38,8 @@
:stroke-cap-end]) :stroke-cap-end])
(mf/defc stroke-menu (mf/defc stroke-menu
{::mf/wrap [#(mf/memo' % (mf/check-props ["ids" "values" "type" "show-caps" "applied-tokens" "shapes" "objects"]))]} {::mf/wrap [#(mf/memo' % (mf/check-props ["ids" "values" "type" "show-caps" "applied-tokens"]))]}
[{:keys [ids type values show-caps disable-stroke-style applied-tokens shapes objects] :as props}] [{:keys [ids type values show-caps disable-stroke-style applied-tokens] :as props}]
(let [label (case type (let [label (case type
:multiple (tr "workspace.options.selection-stroke") :multiple (tr "workspace.options.selection-stroke")
:group (tr "workspace.options.group-stroke") :group (tr "workspace.options.group-stroke")
@@ -209,8 +209,7 @@
:stroke value :stroke value
:title (tr "workspace.options.stroke-color") :title (tr "workspace.options.stroke-color")
:index index :index index
:shapes shapes :ids ids
:objects objects
:show-caps show-caps :show-caps show-caps
:on-color-change on-color-change :on-color-change on-color-change
:on-color-detach on-color-detach :on-color-detach on-color-detach

View File

@@ -43,8 +43,7 @@
on-detach-token on-detach-token
disable-stroke-style disable-stroke-style
select-on-focus select-on-focus
shapes ids]}]
objects]}]
(let [on-drop (let [on-drop
(fn [_ data] (fn [_ data]
@@ -105,25 +104,13 @@
on-token-change on-token-change
(mf/use-fn (mf/use-fn
(mf/deps shapes objects) (mf/deps ids)
(fn [_ token] (fn [_ token]
(let [expanded-shapes (st/emit!
(if (= 1 (count shapes)) (dwta/toggle-token {:token token
(let [shape (first shapes)] :attrs #{:stroke-color}
(if (= (:type shape) :group) :shape-ids ids
(keep objects (:shapes shape)) :expand-with-children true}))))
[shape]))
(mapcat (fn [shape]
(if (= (:type shape) :group)
(keep objects (:shapes shape))
[shape]))
shapes))]
(st/emit!
(dwta/toggle-token {:token token
:attrs #{:stroke-color}
:shapes expanded-shapes})))))
stroke-style (or (:stroke-style stroke) :solid) stroke-style (or (:stroke-style stroke) :solid)

View File

@@ -98,7 +98,6 @@
:ids [(:id shape)] :ids [(:id shape)]
:values layout-container-values :values layout-container-values
:applied-tokens applied-tokens :applied-tokens applied-tokens
:shapes shapes
:multiple false}] :multiple false}]
(when (and (= (count ids) 1) is-layout-child? is-grid-parent?) (when (and (= (count ids) 1) is-layout-child? is-grid-parent?)
@@ -124,14 +123,12 @@
{:ids ids {:ids ids
:type type :type type
:values shape :values shape
:shapes shapes
:applied-tokens applied-tokens}] :applied-tokens applied-tokens}]
[:& stroke-menu {:ids ids [:& stroke-menu {:ids ids
:type type :type type
:show-caps true :show-caps true
:values stroke-values :values stroke-values
:shapes shapes
:applied-tokens applied-tokens}] :applied-tokens applied-tokens}]
[:> shadow-menu* {:ids ids :values (get shape :shadow)}] [:> shadow-menu* {:ids ids :values (get shape :shadow)}]

View File

@@ -97,7 +97,6 @@
:ids [(:id shape)] :ids [(:id shape)]
:values layout-container-values :values layout-container-values
:applied-tokens applied-tokens :applied-tokens applied-tokens
:shapes shapes
:multiple false}] :multiple false}]
(when (and (= (count ids) 1) is-layout-child? is-grid-parent?) (when (and (= (count ids) 1) is-layout-child? is-grid-parent?)
@@ -123,13 +122,11 @@
{:ids ids {:ids ids
:type type :type type
:values shape :values shape
:shapes shapes
:applied-tokens applied-tokens}] :applied-tokens applied-tokens}]
[:& stroke-menu {:ids ids [:& stroke-menu {:ids ids
:type type :type type
:values stroke-values :values stroke-values
:shapes shapes
:applied-tokens applied-tokens}] :applied-tokens applied-tokens}]
[:> shadow-menu* {:ids ids :values (get shape :shadow)}] [:> shadow-menu* {:ids ids :values (get shape :shadow)}]
[:& blur-menu {:ids ids [:& blur-menu {:ids ids

View File

@@ -115,7 +115,6 @@
[:& layout-container-menu [:& layout-container-menu
{:type shape-type {:type shape-type
:ids ids :ids ids
:shapes shapes
:applied-tokens applied-tokens :applied-tokens applied-tokens
:values layout-container-values :values layout-container-values
:multiple false}] :multiple false}]
@@ -146,13 +145,11 @@
{:ids ids {:ids ids
:type shape-type :type shape-type
:values shape :values shape
:shapes shapes
:applied-tokens applied-tokens}] :applied-tokens applied-tokens}]
[:& stroke-menu {:ids ids [:& stroke-menu {:ids ids
:type shape-type :type shape-type
:values stroke-values :values stroke-values
:shapes shapes
:applied-tokens applied-tokens}] :applied-tokens applied-tokens}]
[:> color-selection-menu* {:type shape-type [:> color-selection-menu* {:type shape-type
:shapes shapes-with-children :shapes shapes-with-children

View File

@@ -123,7 +123,6 @@
:ids [(:id shape)] :ids [(:id shape)]
:values layout-container-values :values layout-container-values
:applied-tokens applied-tokens :applied-tokens applied-tokens
:shapes shapes
:multiple false}] :multiple false}]
(when (and (= (count ids) 1) is-layout-child? is-grid-parent?) (when (and (= (count ids) 1) is-layout-child? is-grid-parent?)
@@ -149,16 +148,12 @@
{:type type {:type type
:ids fill-ids :ids fill-ids
:values fill-values :values fill-values
:shapes shapes
:objects objects
:applied-tokens fill-tokens}]) :applied-tokens fill-tokens}])
(when-not (empty? stroke-ids) (when-not (empty? stroke-ids)
[:& stroke-menu {:type type [:& stroke-menu {:type type
:ids stroke-ids :ids stroke-ids
:values stroke-values :values stroke-values
:shapes shapes
:objects objects
:applied-tokens stroke-tokens}]) :applied-tokens stroke-tokens}])
[:> color-selection-menu* [:> color-selection-menu*

View File

@@ -462,7 +462,6 @@
:ids layout-container-ids :ids layout-container-ids
:values layout-container-values :values layout-container-values
:applied-tokens layout-contianer-tokens :applied-tokens layout-contianer-tokens
:shapes shapes
:multiple true}] :multiple true}]
(when (or is-layout-child? has-flex-layout-container?) (when (or is-layout-child? has-flex-layout-container?)
@@ -485,8 +484,6 @@
[:> fill/fill-menu* {:type type [:> fill/fill-menu* {:type type
:ids fill-ids :ids fill-ids
:values fill-values :values fill-values
:shapes shapes
:objects objects
:applied-tokens fill-tokens}]) :applied-tokens fill-tokens}])
(when-not (empty? stroke-ids) (when-not (empty? stroke-ids)
@@ -494,8 +491,6 @@
:ids stroke-ids :ids stroke-ids
:show-caps show-caps? :show-caps show-caps?
:values stroke-values :values stroke-values
:shapes shapes
:objects objects
:disable-stroke-style has-text? :disable-stroke-style has-text?
:applied-tokens stroke-tokens}]) :applied-tokens stroke-tokens}])

View File

@@ -97,7 +97,6 @@
:ids [(:id shape)] :ids [(:id shape)]
:values layout-container-values :values layout-container-values
:applied-tokens applied-tokens :applied-tokens applied-tokens
:shapes shapes
:multiple false}] :multiple false}]
(when (and (= (count ids) 1) is-layout-child? is-grid-parent?) (when (and (= (count ids) 1) is-layout-child? is-grid-parent?)
@@ -123,14 +122,12 @@
{:ids ids {:ids ids
:type type :type type
:values shape :values shape
:shapes shapes
:applied-tokens applied-tokens}] :applied-tokens applied-tokens}]
[:& stroke-menu {:ids ids [:& stroke-menu {:ids ids
:type type :type type
:show-caps true :show-caps true
:values stroke-values :values stroke-values
:shapes shapes
:applied-tokens applied-tokens}] :applied-tokens applied-tokens}]
[:> shadow-menu* {:ids ids :values (get shape :shadow)}] [:> shadow-menu* {:ids ids :values (get shape :shadow)}]
[:& blur-menu {:ids ids [:& blur-menu {:ids ids

View File

@@ -97,7 +97,6 @@
:ids ids :ids ids
:values layout-container-values :values layout-container-values
:applied-tokens applied-tokens :applied-tokens applied-tokens
:shapes shapes
:multiple false}] :multiple false}]
(when (and (= (count ids) 1) is-layout-child? is-grid-parent?) (when (and (= (count ids) 1) is-layout-child? is-grid-parent?)
@@ -122,13 +121,11 @@
[:> fill/fill-menu* [:> fill/fill-menu*
{:ids ids {:ids ids
:type type :type type
:shapes shapes
:values shape :values shape
:applied-tokens applied-tokens}] :applied-tokens applied-tokens}]
[:& stroke-menu {:ids ids [:& stroke-menu {:ids ids
:type type :type type
:shapes shapes
:values stroke-values :values stroke-values
:applied-tokens applied-tokens}] :applied-tokens applied-tokens}]

View File

@@ -165,7 +165,6 @@
:ids [(:id shape)] :ids [(:id shape)]
:values layout-container-values :values layout-container-values
:applied-tokens applied-tokens :applied-tokens applied-tokens
:shapes shapes
:multiple false}] :multiple false}]
(when (and (= (count ids) 1) is-layout-child? is-grid-parent?) (when (and (= (count ids) 1) is-layout-child? is-grid-parent?)
@@ -191,13 +190,11 @@
{:ids ids {:ids ids
:type type :type type
:values fill-values :values fill-values
:shapes shapes
:applied-tokens applied-tokens}] :applied-tokens applied-tokens}]
[:& stroke-menu {:ids ids [:& stroke-menu {:ids ids
:type type :type type
:values stroke-values :values stroke-values
:shapes shapes
:applied-tokens applied-tokens}] :applied-tokens applied-tokens}]
[:> shadow-menu* {:ids ids :values (get shape :shadow)}] [:> shadow-menu* {:ids ids :values (get shape :shadow)}]

View File

@@ -138,7 +138,6 @@
:ids ids :ids ids
:values layout-container-values :values layout-container-values
:applied-tokens applied-tokens :applied-tokens applied-tokens
:shapes shapes
:multiple false}] :multiple false}]
(when (and (= (count ids) 1) is-layout-child? is-grid-parent?) (when (and (= (count ids) 1) is-layout-child? is-grid-parent?)
@@ -170,13 +169,11 @@
{:ids ids {:ids ids
:type type :type type
:values fill-values :values fill-values
:shapes shapes
:applied-tokens applied-tokens}] :applied-tokens applied-tokens}]
[:& stroke-menu {:ids ids [:& stroke-menu {:ids ids
:type type :type type
:values stroke-values :values stroke-values
:shapes shapes
:disable-stroke-style true :disable-stroke-style true
:applied-tokens applied-tokens}] :applied-tokens applied-tokens}]

View File

@@ -145,6 +145,7 @@
[:> token-group* {:key (name type) [:> token-group* {:key (name type)
:is-open (get open-status type false) :is-open (get open-status type false)
:type type :type type
:selected-ids selected
:selected-shapes selected-shapes :selected-shapes selected-shapes
:is-selected-inside-layout is-selected-inside-layout :is-selected-inside-layout is-selected-inside-layout
:active-theme-tokens resolved-active-tokens :active-theme-tokens resolved-active-tokens

View File

@@ -47,7 +47,7 @@
(mf/defc token-group* (mf/defc token-group*
{::mf/private true} {::mf/private true}
[{:keys [type tokens selected-shapes is-selected-inside-layout active-theme-tokens is-open]}] [{:keys [type tokens selected-shapes is-selected-inside-layout active-theme-tokens is-open selected-ids]}]
(let [{:keys [modal title]} (let [{:keys [modal title]}
(get dwta/token-properties type) (get dwta/token-properties type)
editing-ref (mf/deref refs/workspace-editor-state) editing-ref (mf/deref refs/workspace-editor-state)
@@ -93,12 +93,12 @@
on-token-pill-click on-token-pill-click
(mf/use-fn (mf/use-fn
(mf/deps selected-shapes not-editing?) (mf/deps not-editing? selected-ids)
(fn [event token] (fn [event token]
(dom/stop-propagation event) (dom/stop-propagation event)
(when (and not-editing? (seq selected-shapes) (not= (:type token) :number)) (when (and not-editing? (seq selected-shapes) (not= (:type token) :number))
(st/emit! (dwta/toggle-token {:token token (st/emit! (dwta/toggle-token {:token token
:shapes selected-shapes})))))] :shape-ids selected-ids})))))]
[:div {:on-click on-toggle-open-click :class (stl/css :token-section-wrapper)} [:div {:on-click on-toggle-open-click :class (stl/css :token-section-wrapper)}
[:> cmm/asset-section* {:icon (token-section-icon type) [:> cmm/asset-section* {:icon (token-section-icon type)

View File

@@ -722,7 +722,7 @@
store (ths/setup-store file) store (ths/setup-store file)
rect-1 (cths/get-shape file :rect-1) rect-1 (cths/get-shape file :rect-1)
rect-2 (cths/get-shape file :rect-2) rect-2 (cths/get-shape file :rect-2)
events [(dwta/toggle-token {:shapes [rect-1 rect-2] events [(dwta/toggle-token {:shape-ids [(:id rect-1) (:id rect-2)]
:token-type-props {:attributes #{:r1 :r2 :r3 :r4} :token-type-props {:attributes #{:r1 :r2 :r3 :r4}
:on-update-shape dwta/update-shape-radius-all} :on-update-shape dwta/update-shape-radius-all}
:token (toht/get-token file "borderRadius.md")})]] :token (toht/get-token file "borderRadius.md")})]]
@@ -753,7 +753,7 @@
rect-without-token (cths/get-shape file :rect-2) rect-without-token (cths/get-shape file :rect-2)
rect-with-other-token (cths/get-shape file :rect-3) rect-with-other-token (cths/get-shape file :rect-3)
events [(dwta/toggle-token {:shapes [rect-with-token rect-without-token rect-with-other-token] events [(dwta/toggle-token {:shape-ids [(:id rect-with-token) (:id rect-without-token) (:id rect-with-other-token)]
:token (toht/get-token file "borderRadius.sm") :token (toht/get-token file "borderRadius.sm")
:token-type-props {:attributes #{:r1 :r2 :r3 :r4}}})]] :token-type-props {:attributes #{:r1 :r2 :r3 :r4}}})]]
(tohs/run-store-async (tohs/run-store-async
@@ -786,7 +786,7 @@
rect-without-token (cths/get-shape file :rect-2) rect-without-token (cths/get-shape file :rect-2)
rect-with-other-token-2 (cths/get-shape file :rect-3) rect-with-other-token-2 (cths/get-shape file :rect-3)
events [(dwta/toggle-token {:shapes [rect-with-other-token-1 rect-without-token rect-with-other-token-2] events [(dwta/toggle-token {:shape-ids [(:id rect-with-other-token-1) (:id rect-without-token) (:id rect-with-other-token-2)]
:token (toht/get-token file "borderRadius.sm") :token (toht/get-token file "borderRadius.sm")
:token-type-props {:attributes #{:r1 :r2 :r3 :r4}}})]] :token-type-props {:attributes #{:r1 :r2 :r3 :r4}}})]]
(tohs/run-store-async (tohs/run-store-async
@@ -822,7 +822,7 @@
rect-in-layout (cths/get-shape file :rect-in-layout) rect-in-layout (cths/get-shape file :rect-in-layout)
rect-regular (cths/get-shape file :rect-regular) rect-regular (cths/get-shape file :rect-regular)
events [(dwta/toggle-token {:token (toht/get-token file "spacing.md") events [(dwta/toggle-token {:token (toht/get-token file "spacing.md")
:shapes [frame-layout rect-in-layout rect-regular]})]] :shape-ids [(:id frame-layout) (:id rect-in-layout) (:id rect-regular)]})]]
(tohs/run-store-async (tohs/run-store-async
store done events store done events
(fn [new-state] (fn [new-state]