mirror of
https://github.com/penpot/penpot.git
synced 2026-05-31 04:38:08 +00:00
Add main loader in ui ns.
This commit is contained in:
parent
2887b5c0e1
commit
55025d12fa
@ -16,6 +16,7 @@
|
|||||||
[uxbox.rstore :as rs]
|
[uxbox.rstore :as rs]
|
||||||
[uxbox.data.projects :as dp]
|
[uxbox.data.projects :as dp]
|
||||||
[uxbox.data.users :as udu]
|
[uxbox.data.users :as udu]
|
||||||
|
[uxbox.ui.icons :as i]
|
||||||
[uxbox.ui.lightbox :as ui-lightbox]
|
[uxbox.ui.lightbox :as ui-lightbox]
|
||||||
[uxbox.ui.auth :as ui-auth]
|
[uxbox.ui.auth :as ui-auth]
|
||||||
[uxbox.ui.dashboard :as ui-dashboard]
|
[uxbox.ui.dashboard :as ui-dashboard]
|
||||||
@ -24,20 +25,27 @@
|
|||||||
[uxbox.ui.mixins :as mx]
|
[uxbox.ui.mixins :as mx]
|
||||||
[uxbox.ui.shapes]))
|
[uxbox.ui.shapes]))
|
||||||
|
|
||||||
(def ^:const auth-data
|
;; --- Lentes
|
||||||
(as-> (l/key :auth) $
|
|
||||||
(l/focus-atom $ s/state)))
|
|
||||||
|
|
||||||
(def ^:const +unrestricted+
|
(def ^:const auth-data-l
|
||||||
#{:auth/login})
|
(-> (l/key :auth)
|
||||||
|
(l/focus-atom s/state)))
|
||||||
|
|
||||||
(def ^:const restricted?
|
(def ^:const loader-l
|
||||||
(complement +unrestricted+))
|
(-> (l/key :loader)
|
||||||
|
(l/focus-atom s/state)))
|
||||||
|
|
||||||
|
;; --- Constants
|
||||||
|
|
||||||
|
(def ^:const +unrestricted+ #{:auth/login})
|
||||||
|
(def ^:const restricted? (complement +unrestricted+))
|
||||||
|
|
||||||
|
;; --- Main App (Component)
|
||||||
|
|
||||||
(defn app-render
|
(defn app-render
|
||||||
[own]
|
[own]
|
||||||
(let [route (rum/react r/route-l)
|
(let [route (rum/react r/route-l)
|
||||||
auth (rum/react auth-data)
|
auth (rum/react auth-data-l)
|
||||||
location (:id route)
|
location (:id route)
|
||||||
params (:params route)]
|
params (:params route)]
|
||||||
(if (and (restricted? location) (not auth))
|
(if (and (restricted? location) (not auth))
|
||||||
@ -59,9 +67,8 @@
|
|||||||
|
|
||||||
(defn app-will-mount
|
(defn app-will-mount
|
||||||
[own]
|
[own]
|
||||||
(when @auth-data
|
(when @auth-data-l
|
||||||
(rs/emit! (udu/fetch-profile)
|
(rs/emit! (udu/fetch-profile)))
|
||||||
(dp/fetch-projects)))
|
|
||||||
own)
|
own)
|
||||||
|
|
||||||
(def app
|
(def app
|
||||||
@ -71,10 +78,27 @@
|
|||||||
:mixins [rum/reactive]
|
:mixins [rum/reactive]
|
||||||
:name "app"}))
|
:name "app"}))
|
||||||
|
|
||||||
|
;; --- Loader
|
||||||
|
|
||||||
|
(defn loader-render
|
||||||
|
[own]
|
||||||
|
(when (rum/react loader-l)
|
||||||
|
(html
|
||||||
|
[:div.loader-content i/loader])))
|
||||||
|
|
||||||
|
(def loader
|
||||||
|
(mx/component
|
||||||
|
{:render loader-render
|
||||||
|
:name "loader"
|
||||||
|
:mixins [rum/reactive mx/static]}))
|
||||||
|
|
||||||
|
;; --- Main Entry Point
|
||||||
|
|
||||||
(defn init
|
(defn init
|
||||||
[]
|
[]
|
||||||
(println "ui/init")
|
|
||||||
(let [app-dom (gdom/getElement "app")
|
(let [app-dom (gdom/getElement "app")
|
||||||
lb-dom (gdom/getElement "lightbox")]
|
lightbox-dom (gdom/getElement "lightbox")
|
||||||
|
loader-dom (gdom/getElement "loader")]
|
||||||
(rum/mount (app) app-dom)
|
(rum/mount (app) app-dom)
|
||||||
(rum/mount (ui-lightbox/lightbox) lb-dom)))
|
(rum/mount (ui-lightbox/lightbox) lightbox-dom)
|
||||||
|
(rum/mount (loader) loader-dom)))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user