From 80e89037549266f5d29f7cfc09bf7f59da701eec Mon Sep 17 00:00:00 2001 From: Florian Schroedl Date: Thu, 19 Sep 2024 10:26:17 +0200 Subject: [PATCH] Refactor: Use tokens-lib for getting tokens theme --- frontend/src/app/main/refs.cljs | 10 ++++++++-- .../app/main/ui/workspace/tokens/modals/themes.cljs | 8 +++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/main/refs.cljs b/frontend/src/app/main/refs.cljs index 3e8994e36..422a7b2d5 100644 --- a/frontend/src/app/main/refs.cljs +++ b/frontend/src/app/main/refs.cljs @@ -250,8 +250,14 @@ (l/derived #(some-> % ctob/get-theme-groups) tokens-lib)) (defn workspace-token-theme - [id] - (l/derived #(wtts/get-workspace-theme id %) st/state)) + [group name] + (l/derived + (fn [lib] + (when lib + (ctob/get-theme lib group name))) + tokens-lib)) + +;; Old (def workspace-active-theme-ids (l/derived wtts/get-active-theme-ids st/state)) diff --git a/frontend/src/app/main/ui/workspace/tokens/modals/themes.cljs b/frontend/src/app/main/ui/workspace/tokens/modals/themes.cljs index 47e00588d..9923c51d7 100644 --- a/frontend/src/app/main/ui/workspace/tokens/modals/themes.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/modals/themes.cljs @@ -62,7 +62,8 @@ (dom/prevent-default e) (dom/stop-propagation e) (set-state (fn [_] {:type :edit-theme - :theme-id (:id theme)})))] + :theme-id (:id theme) + :theme-path [(:id theme) (:group theme) (:name theme)]})))] [:div [:ul {:class (stl/css :theme-group-wrapper)} (for [[group themes] themes] @@ -212,9 +213,10 @@ (mf/defc controlled-edit-theme [{:keys [state set-state]}] - (let [{:keys [theme-id]} @state + (let [{:keys [theme-path]} @state + [_ theme-group theme-name] theme-path token-sets (mf/deref refs/workspace-ordered-token-sets) - theme (mf/deref (refs/workspace-token-theme theme-id)) + theme (mf/deref (refs/workspace-token-theme theme-group theme-name)) theme-groups (mf/deref refs/workspace-token-theme-groups)] [:& edit-theme {:token-sets token-sets