0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-21 22:22:43 -05:00

Fix property applying

This commit is contained in:
Florian Schroedl 2024-09-30 09:33:35 +02:00
parent a59e391b38
commit 5d61ddb385

View file

@ -8,19 +8,20 @@
(:require (:require
[app.common.types.shape.radius :as ctsr] [app.common.types.shape.radius :as ctsr]
[app.common.types.token :as ctt] [app.common.types.token :as ctt]
[app.main.data.workspace.colors :as wdc] [app.common.types.tokens-lib :as ctob]
[app.main.data.workspace :as udw] [app.main.data.workspace :as udw]
[app.main.data.workspace.colors :as wdc]
[app.main.data.workspace.shape-layout :as dwsl] [app.main.data.workspace.shape-layout :as dwsl]
[app.main.data.workspace.shapes :as dwsh] [app.main.data.workspace.shapes :as dwsh]
[app.main.data.workspace.state-helpers :as wsh] [app.main.data.workspace.state-helpers :as wsh]
[app.main.data.workspace.transforms :as dwt] [app.main.data.workspace.transforms :as dwt]
[app.main.data.workspace.undo :as dwu] [app.main.data.workspace.undo :as dwu]
[app.main.ui.workspace.tokens.style-dictionary :as sd] [app.main.ui.workspace.tokens.style-dictionary :as sd]
[app.main.ui.workspace.tokens.tinycolor :as tinycolor]
[app.main.ui.workspace.tokens.token :as wtt] [app.main.ui.workspace.tokens.token :as wtt]
[beicon.v2.core :as rx] [beicon.v2.core :as rx]
[clojure.set :as set] [clojure.set :as set]
[potok.v2.core :as ptk] [potok.v2.core :as ptk]))
[app.main.ui.workspace.tokens.tinycolor :as tinycolor]))
;; Token Updates --------------------------------------------------------------- ;; Token Updates ---------------------------------------------------------------
@ -34,7 +35,9 @@
(ptk/reify ::apply-token (ptk/reify ::apply-token
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [_ state _]
(->> (rx/from (sd/resolve-tokens+ (get-in state [:workspace-data :tokens]))) (when-let [tokens (some-> (get-in state [:workspace-data :tokens-lib])
(ctob/get-active-themes-set-tokens))]
(->> (rx/from (sd/resolve-tokens+ tokens))
(rx/mapcat (rx/mapcat
(fn [resolved-tokens] (fn [resolved-tokens]
(let [undo-id (js/Symbol) (let [undo-id (js/Symbol)
@ -48,7 +51,7 @@
:always (update :applied-tokens merge tokenized-attributes)))) :always (update :applied-tokens merge tokenized-attributes))))
(when on-update-shape (when on-update-shape
(on-update-shape resolved-value shape-ids attributes)) (on-update-shape resolved-value shape-ids attributes))
(dwu/commit-undo-transaction undo-id))))))))) (dwu/commit-undo-transaction undo-id))))))))))
(defn unapply-token (defn unapply-token
"Removes `attributes` that match `token` for `shape-ids`. "Removes `attributes` that match `token` for `shape-ids`.