mirror of
https://github.com/penpot/penpot.git
synced 2025-08-07 14:38:33 +02:00
Enable login submit with enter key.
This commit is contained in:
parent
e7697258e4
commit
95263402b7
1 changed files with 28 additions and 33 deletions
|
@ -18,7 +18,8 @@
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(defn- login-submit
|
(defn- login-submit
|
||||||
[local]
|
[event local]
|
||||||
|
(dom/prevent-default event)
|
||||||
(let [form (:form @local)]
|
(let [form (:form @local)]
|
||||||
(rs/emit! (da/login {:username (:email form)
|
(rs/emit! (da/login {:username (:email form)
|
||||||
:password (:password form)}))))
|
:password (:password form)}))))
|
||||||
|
@ -32,49 +33,43 @@
|
||||||
(defn- login-field-change
|
(defn- login-field-change
|
||||||
[local field event]
|
[local field event]
|
||||||
(let [value (str/trim (dom/event->value event))]
|
(let [value (str/trim (dom/event->value event))]
|
||||||
(println @local value)
|
|
||||||
(swap! local assoc-in [:form field] value)))
|
(swap! local assoc-in [:form field] value)))
|
||||||
|
|
||||||
(defn- login-render
|
(defn- login-render
|
||||||
[own local]
|
[own local]
|
||||||
(let [on-submit #(login-submit local)
|
(let [on-submit #(login-submit % local)
|
||||||
submit-enabled? (login-submit-enabled? local)
|
submit-enabled? (login-submit-enabled? local)
|
||||||
form (:form @local)]
|
form (:form @local)]
|
||||||
(println "submit-enabled?" submit-enabled?)
|
|
||||||
(html
|
(html
|
||||||
[:div.login
|
[:div.login
|
||||||
[:div.login-body
|
[:div.login-body
|
||||||
(uum/messages)
|
(uum/messages)
|
||||||
[:a i/logo]
|
[:a i/logo]
|
||||||
[:div.login-content
|
[:form {:on-submit on-submit}
|
||||||
[:input.input-text
|
[:div.login-content
|
||||||
{:name "email"
|
[:input.input-text
|
||||||
:ref "email"
|
{:name "email"
|
||||||
:value (:email form "")
|
:ref "email"
|
||||||
:on-change #(login-field-change local :email %)
|
:value (:email form "")
|
||||||
:placeholder "Email or Username"
|
:on-change #(login-field-change local :email %)
|
||||||
:type "text"}]
|
:placeholder "Email or Username"
|
||||||
[:input.input-text
|
:type "text"}]
|
||||||
{:name "password"
|
[:input.input-text
|
||||||
:ref "password"
|
{:name "password"
|
||||||
:value (:password form "")
|
:ref "password"
|
||||||
:on-change #(login-field-change local :password %)
|
:value (:password form "")
|
||||||
:placeholder "Password"
|
:on-change #(login-field-change local :password %)
|
||||||
:type "password"}]
|
:placeholder "Password"
|
||||||
#_[:div.input-checkbox.check-primary
|
:type "password"}]
|
||||||
[:input#checkbox1 {:value "1"
|
[:input.btn-primary
|
||||||
:type "checkbox"}]
|
{:name "login"
|
||||||
[:label {:for "checkbox1"} "Keep Me Signed in"]]
|
:class (when-not submit-enabled? "btn-disabled")
|
||||||
[:input.btn-primary
|
:disabled (not submit-enabled?)
|
||||||
{:name "login"
|
:value "Continue"
|
||||||
:class (when-not submit-enabled? "btn-disabled")
|
:type "submit"}]
|
||||||
:disabled (not submit-enabled?)
|
[:div.login-links
|
||||||
:value "Continue"
|
[:a {:on-click #(r/go :auth/recover-password)} "Forgot your password?"]
|
||||||
:type "submit"
|
[:a {:on-click #(r/go :auth/register)} "Don't have an account?"]]]]]])))
|
||||||
:on-click on-submit}]
|
|
||||||
[:div.login-links
|
|
||||||
[:a {:on-click #(r/go :auth/recover-password)} "Forgot your password?"]
|
|
||||||
[:a {:on-click #(r/go :auth/register)} "Don't have an account?"]]]]])))
|
|
||||||
|
|
||||||
(def ^:const login
|
(def ^:const login
|
||||||
(mx/component
|
(mx/component
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue