mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 14:12:36 -05:00
Fix property applying
This commit is contained in:
parent
a59e391b38
commit
5d61ddb385
1 changed files with 21 additions and 18 deletions
|
@ -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,21 +35,23 @@
|
||||||
(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])
|
||||||
(rx/mapcat
|
(ctob/get-active-themes-set-tokens))]
|
||||||
(fn [resolved-tokens]
|
(->> (rx/from (sd/resolve-tokens+ tokens))
|
||||||
(let [undo-id (js/Symbol)
|
(rx/mapcat
|
||||||
resolved-value (get-in resolved-tokens [(wtt/token-identifier token) :resolved-value])
|
(fn [resolved-tokens]
|
||||||
tokenized-attributes (wtt/attributes-map attributes token)]
|
(let [undo-id (js/Symbol)
|
||||||
(rx/of
|
resolved-value (get-in resolved-tokens [(wtt/token-identifier token) :resolved-value])
|
||||||
(dwu/start-undo-transaction undo-id)
|
tokenized-attributes (wtt/attributes-map attributes token)]
|
||||||
(dwsh/update-shapes shape-ids (fn [shape]
|
(rx/of
|
||||||
(cond-> shape
|
(dwu/start-undo-transaction undo-id)
|
||||||
attributes-to-remove (update :applied-tokens #(apply (partial dissoc %) attributes-to-remove))
|
(dwsh/update-shapes shape-ids (fn [shape]
|
||||||
:always (update :applied-tokens merge tokenized-attributes))))
|
(cond-> shape
|
||||||
(when on-update-shape
|
attributes-to-remove (update :applied-tokens #(apply (partial dissoc %) attributes-to-remove))
|
||||||
(on-update-shape resolved-value shape-ids attributes))
|
:always (update :applied-tokens merge tokenized-attributes))))
|
||||||
(dwu/commit-undo-transaction undo-id)))))))))
|
(when on-update-shape
|
||||||
|
(on-update-shape resolved-value shape-ids attributes))
|
||||||
|
(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`.
|
||||||
|
|
Loading…
Add table
Reference in a new issue