mirror of
https://github.com/penpot/penpot.git
synced 2025-12-11 22:14:05 +01:00
♻️ Refactor state locality
The main purpose of this refactor is reduce a custom state from different pages and unify them under common access patterns
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
(ns frontend-tests.tokens.helpers.state
|
||||
(:require
|
||||
[app.common.types.tokens-lib :as ctob]
|
||||
[app.main.data.helpers :as dsh]
|
||||
[app.main.ui.workspace.tokens.style-dictionary :as sd]
|
||||
[beicon.v2.core :as rx]
|
||||
[potok.v2.core :as ptk]))
|
||||
@@ -22,10 +23,11 @@
|
||||
(ptk/reify ::end+
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(->> (rx/from (-> (get-in state [:workspace-data :tokens-lib])
|
||||
(ctob/get-active-themes-set-tokens)
|
||||
(sd/resolve-tokens+)))
|
||||
(rx/mapcat #(rx/of (end)))))))
|
||||
(let [data (dsh/lookup-file-data state)]
|
||||
(->> (rx/from (-> (get data :tokens-lib)
|
||||
(ctob/get-active-themes-set-tokens)
|
||||
(sd/resolve-tokens+)))
|
||||
(rx/mapcat #(rx/of (end))))))))
|
||||
|
||||
(defn stop-on
|
||||
"Helper function to be used with async version of run-store.
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
(ctob/get-active-themes-set-tokens)
|
||||
(get name)))
|
||||
|
||||
(defn apply-token-to-shape [file shape-label token-label attributes]
|
||||
(defn apply-token-to-shape
|
||||
[file shape-label token-label attributes]
|
||||
(let [first-page-id (get-in file [:data :pages 0])
|
||||
shape-id (thi/id shape-label)
|
||||
token (get-token file token-label)
|
||||
|
||||
Reference in New Issue
Block a user