From 3b7432a859796d0a5421df3801e5eeca021567ef Mon Sep 17 00:00:00 2001 From: Florian Schroedl Date: Tue, 27 Aug 2024 14:32:26 +0200 Subject: [PATCH] Use non editable context in form --- .../src/app/main/ui/workspace/tokens/modals/themes.cljs | 6 ++++-- frontend/src/app/main/ui/workspace/tokens/sets.cljs | 5 +++-- .../src/app/main/ui/workspace/tokens/sets_context.cljs | 7 +++++++ 3 files changed, 14 insertions(+), 4 deletions(-) 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 f4cb4da8c..b72831efa 100644 --- a/frontend/src/app/main/ui/workspace/tokens/modals/themes.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/modals/themes.cljs @@ -18,7 +18,8 @@ [app.main.ui.workspace.tokens.token-set :as wtts] [app.util.dom :as dom] [rumext.v2 :as mf] - [cuerdas.core :as str])) + [cuerdas.core :as str] + [app.main.ui.workspace.tokens.sets-context :as sets-context])) (def ^:private chevron-icon (i/icon-xref :arrow (stl/css :chevron-icon))) @@ -159,7 +160,8 @@ :token-set-selected? (constantly false) :token-set-active? token-set-active? :on-select on-toggle-token-set - :on-toggle on-toggle-token-set}]] + :on-toggle on-toggle-token-set + :context sets-context/static-context}]] [:div {:class (stl/css :edit-theme-footer)} (if edit? [:button {:class (stl/css :button-secondary) diff --git a/frontend/src/app/main/ui/workspace/tokens/sets.cljs b/frontend/src/app/main/ui/workspace/tokens/sets.cljs index 9f9c6daa9..9f5603efb 100644 --- a/frontend/src/app/main/ui/workspace/tokens/sets.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/sets.cljs @@ -128,9 +128,10 @@ token-set-selected? token-set-active? on-create-token-set - on-select] + on-select + context] :as _props}] - (let [{:keys [editing? new? on-edit on-create on-reset]} (sets-context/use-context)] + (let [{:keys [editing? new? on-edit on-create on-reset]} (or context (sets-context/use-context))] [:ul {:class (stl/css :sets-list)} (for [[id token-set] token-sets] [:& sets-tree {:key id diff --git a/frontend/src/app/main/ui/workspace/tokens/sets_context.cljs b/frontend/src/app/main/ui/workspace/tokens/sets_context.cljs index 0d08ab297..b5920f335 100644 --- a/frontend/src/app/main/ui/workspace/tokens/sets_context.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/sets_context.cljs @@ -7,6 +7,13 @@ (def context (mf/create-context initial)) +(def static-context + {:editing? (constantly false) + :new? false + :on-edit (constantly nil) + :on-create (constantly nil) + :on-reset (constantly nil)}) + (mf/defc provider {::mf/wrap-props false} [props]