0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-13 16:21:57 -05:00

Add defaults for theme form

This commit is contained in:
Florian Schroedl 2024-08-26 14:31:34 +02:00
parent 84b5be5547
commit f37cf8be5e

View file

@ -17,7 +17,8 @@
[app.main.ui.workspace.tokens.sets :as wts]
[app.main.ui.workspace.tokens.token-set :as wtts]
[app.util.dom :as dom]
[rumext.v2 :as mf]))
[rumext.v2 :as mf]
[cuerdas.core :as str]))
(def ^:private chevron-icon
(i/icon-xref :arrow (stl/css :chevron-icon)))
@ -118,7 +119,15 @@
(mf/deps theme-state on-submit)
(fn [e]
(dom/prevent-default e)
(on-submit (:theme @theme-state))
(let [theme (:theme @theme-state)
final-name (str/trim (:name theme))
final-group (-> (:group theme)
(str/trim)
(str/lower))]
(cond-> theme
(empty final-name) (assoc :name "Theme")
(empty final-group) (dissoc :group)
:always on-submit))
(on-back)))]
[:form {:on-submit on-save-form}
[:div {:class (stl/css :edit-theme-wrapper)}