mirror of
https://github.com/penpot/penpot.git
synced 2025-02-03 21:09:00 -05:00
Integrate the login page ui with the backend.
This commit is contained in:
parent
6a3e0b7743
commit
7494d4936d
1 changed files with 32 additions and 3 deletions
|
@ -1,11 +1,13 @@
|
||||||
(ns uxbox.ui.auth
|
(ns uxbox.ui.auth
|
||||||
(:require [sablono.core :as html :refer-macros [html]]
|
(:require [sablono.core :as html :refer-macros [html]]
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
|
[cuerdas.core :as str]
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[uxbox.router :as r]
|
[uxbox.router :as r]
|
||||||
[uxbox.state :as s]
|
[uxbox.state :as s]
|
||||||
[uxbox.rstore :as rs]
|
[uxbox.rstore :as rs]
|
||||||
[uxbox.data.auth :as da]
|
[uxbox.data.auth :as da]
|
||||||
|
[uxbox.util.dom :as dom]
|
||||||
[uxbox.ui.icons :as i]
|
[uxbox.ui.icons :as i]
|
||||||
[uxbox.ui.messages :as uum]
|
[uxbox.ui.messages :as uum]
|
||||||
[uxbox.ui.navigation :as nav]
|
[uxbox.ui.navigation :as nav]
|
||||||
|
@ -15,11 +17,30 @@
|
||||||
;; Login
|
;; Login
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
(defn- login-submit
|
||||||
|
[local]
|
||||||
|
(let [form (:form @local)]
|
||||||
|
(rs/emit! (da/login {:username (:email form)
|
||||||
|
:password (:password form)}))))
|
||||||
|
|
||||||
|
(defn- login-submit-enabled?
|
||||||
|
[local]
|
||||||
|
(let [form (:form @local)]
|
||||||
|
(and (not (str/empty? (:email form "")))
|
||||||
|
(not (str/empty? (:password form ""))))))
|
||||||
|
|
||||||
|
(defn- login-field-change
|
||||||
|
[local field event]
|
||||||
|
(let [value (str/trim (dom/event->value event))]
|
||||||
|
(println @local value)
|
||||||
|
(swap! local assoc-in [:form field] value)))
|
||||||
|
|
||||||
(defn- login-render
|
(defn- login-render
|
||||||
[own local]
|
[own local]
|
||||||
(letfn [(on-submit []
|
(let [on-submit #(login-submit local)
|
||||||
(rs/emit! (da/login {:username "cirilla"
|
submit-enabled? (login-submit-enabled? local)
|
||||||
:password "secret"})))]
|
form (:form @local)]
|
||||||
|
(println "submit-enabled?" submit-enabled?)
|
||||||
(html
|
(html
|
||||||
[:div.login
|
[:div.login
|
||||||
[:div.login-body
|
[:div.login-body
|
||||||
|
@ -28,10 +49,16 @@
|
||||||
[:div.login-content
|
[:div.login-content
|
||||||
[:input.input-text
|
[:input.input-text
|
||||||
{:name "email"
|
{:name "email"
|
||||||
|
:ref "email"
|
||||||
|
:value (:email form "")
|
||||||
|
:on-change #(login-field-change local :email %)
|
||||||
:placeholder "Email or Username"
|
:placeholder "Email or Username"
|
||||||
:type "text"}]
|
:type "text"}]
|
||||||
[:input.input-text
|
[:input.input-text
|
||||||
{:name "password"
|
{:name "password"
|
||||||
|
:ref "password"
|
||||||
|
:value (:password form "")
|
||||||
|
:on-change #(login-field-change local :password %)
|
||||||
:placeholder "Password"
|
:placeholder "Password"
|
||||||
:type "password"}]
|
:type "password"}]
|
||||||
#_[:div.input-checkbox.check-primary
|
#_[:div.input-checkbox.check-primary
|
||||||
|
@ -40,6 +67,8 @@
|
||||||
[:label {:for "checkbox1"} "Keep Me Signed in"]]
|
[:label {:for "checkbox1"} "Keep Me Signed in"]]
|
||||||
[:input.btn-primary
|
[:input.btn-primary
|
||||||
{:name "login"
|
{:name "login"
|
||||||
|
:class (when-not submit-enabled? "btn-disabled")
|
||||||
|
:disabled (not submit-enabled?)
|
||||||
:value "Continue"
|
:value "Continue"
|
||||||
:type "submit"
|
:type "submit"
|
||||||
:on-click on-submit}]
|
:on-click on-submit}]
|
||||||
|
|
Loading…
Add table
Reference in a new issue