From b5e08c5b8b3fa6f8c89b0ff2adbdefbb86e3a15a Mon Sep 17 00:00:00 2001 From: Florian Schroedl Date: Mon, 26 Aug 2024 14:32:01 +0200 Subject: [PATCH] Add theme creation form --- .../ui/workspace/tokens/modals/themes.cljs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 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 58aa16c50..5d6431c33 100644 --- a/frontend/src/app/main/ui/workspace/tokens/modals/themes.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/modals/themes.cljs @@ -92,7 +92,11 @@ (st/emit! (wdt/delete-token-theme id)))} i/delete]]]])]])] [:div {:class (stl/css :button-footer)} - [:button {:class (stl/css :create-theme-button)} + [:button {:class (stl/css :create-theme-button) + :on-click (fn [e] + (dom/prevent-default e) + (dom/stop-propagation e) + (set-state (fn [_] {:type :create-theme})))} i/add "Create theme"]]])) @@ -176,6 +180,16 @@ :on-back #(set-state (constantly {:type :themes-overview})) :on-submit #(st/emit! (wdt/update-token-theme %))}])) +(mf/defc create-theme + [{:keys [set-state]}] + (let [token-sets (mf/deref refs/workspace-token-sets) + theme {:name "Theme" :sets #{}}] + [:& edit-theme + {:token-sets token-sets + :theme theme + :on-back #(set-state (constantly {:type :themes-overview})) + :on-submit #(st/emit! (wdt/create-token-theme %))}])) + (mf/defc themes [{:keys [] :as _args}] (let [themes (mf/deref refs/workspace-ordered-token-themes) @@ -189,7 +203,8 @@ component (case (:type @state) :empty-themes empty-themes :themes-overview themes-overview - :edit-theme controlled-edit-theme)] + :edit-theme controlled-edit-theme + :create-theme create-theme)] [:div [:div {:class (stl/css :modal-title)} title]