From 3bb99e8f7cffb3f2a8bb5fca755ac0a5aca8d245 Mon Sep 17 00:00:00 2001 From: Florian Schroedl Date: Tue, 27 Aug 2024 14:37:24 +0200 Subject: [PATCH] Remove default theme name, disable empty themen name submit --- .../main/ui/workspace/tokens/modals/themes.cljs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 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 b72831efa..c5dded93e 100644 --- a/frontend/src/app/main/ui/workspace/tokens/modals/themes.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/modals/themes.cljs @@ -112,6 +112,9 @@ (let [edit? (some? (:id theme)) theme-state (mf/use-state {:token-sets token-sets :theme theme}) + disabled? (-> (get-in @theme-state [:theme :name]) + (str/trim) + (str/empty?)) token-set-active? (mf/use-callback (mf/deps theme-state) (fn [id] @@ -135,10 +138,10 @@ final-group (-> (:group theme) (str/trim) (str/lower))] - (cond-> theme - (empty final-name) (assoc :name "Theme") - (empty final-group) (dissoc :group) - :always on-submit)) + (when-not (str/empty? final-name) + (cond-> theme + (empty final-group) (dissoc :group) + :always on-submit))) (on-back)))] [:form {:on-submit on-save-form} [:div {:class (stl/css :edit-theme-wrapper)} @@ -178,7 +181,8 @@ "Cancel"] [:button {:class (stl/css :button-primary) :type "submit" - :on-click on-save-form} + :on-click on-save-form + :disabled disabled?} "Save theme"]]]]])) (mf/defc controlled-edit-theme @@ -195,7 +199,7 @@ (mf/defc create-theme [{:keys [set-state]}] (let [token-sets (mf/deref refs/workspace-ordered-token-sets) - theme {:name "Theme" :sets #{}}] + theme {:name "" :sets #{}}] [:& edit-theme {:token-sets token-sets :theme theme