mirror of
https://github.com/penpot/penpot.git
synced 2025-05-15 22:36:38 +02:00
misc(frontend): minor code reorganization
This commit is contained in:
parent
c2bdede29a
commit
9a313752c5
2 changed files with 25 additions and 25 deletions
|
@ -12,7 +12,7 @@
|
||||||
[uxbox.main.locales.en :as en]
|
[uxbox.main.locales.en :as en]
|
||||||
[uxbox.main.locales.fr :as fr]
|
[uxbox.main.locales.fr :as fr]
|
||||||
[uxbox.main.store :as st]
|
[uxbox.main.store :as st]
|
||||||
[uxbox.main.ui :refer [app]]
|
[uxbox.main.ui :as ui]
|
||||||
[uxbox.main.ui.lightbox :refer [lightbox]]
|
[uxbox.main.ui.lightbox :refer [lightbox]]
|
||||||
[uxbox.main.ui.loader :refer [loader]]
|
[uxbox.main.ui.loader :refer [loader]]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
|
@ -65,24 +65,6 @@
|
||||||
|
|
||||||
(set! st/*on-error* on-error)
|
(set! st/*on-error* on-error)
|
||||||
|
|
||||||
(def routes
|
|
||||||
[["/auth"
|
|
||||||
["/login" :auth/login]
|
|
||||||
["/register" :auth/register]
|
|
||||||
["/recovery/request" :auth/recovery-request]
|
|
||||||
["/recovery/token/:token" :auth/recovery]]
|
|
||||||
["/settings"
|
|
||||||
["/profile" :settings/profile]
|
|
||||||
["/password" :settings/password]
|
|
||||||
["/notifications" :settings/notifications]]
|
|
||||||
["/dashboard"
|
|
||||||
["/projects" :dashboard/projects]
|
|
||||||
["/elements" :dashboard/elements]
|
|
||||||
["/icons" :dashboard/icons]
|
|
||||||
["/images" :dashboard/images]
|
|
||||||
["/colors" :dashboard/colors]]
|
|
||||||
["/workspace/:project/:page" :workspace/page]])
|
|
||||||
|
|
||||||
(defn- on-navigate
|
(defn- on-navigate
|
||||||
[router path]
|
[router path]
|
||||||
(let [match (rt/match router path)]
|
(let [match (rt/match router path)]
|
||||||
|
@ -99,7 +81,7 @@
|
||||||
|
|
||||||
(defn init-ui
|
(defn init-ui
|
||||||
[]
|
[]
|
||||||
(let [router (rt/init routes)
|
(let [router (rt/init ui/routes)
|
||||||
cpath (deref html-history/path)]
|
cpath (deref html-history/path)]
|
||||||
|
|
||||||
(st/emit! #(assoc % :router router))
|
(st/emit! #(assoc % :router router))
|
||||||
|
@ -107,7 +89,7 @@
|
||||||
|
|
||||||
(st/emit! (udu/fetch-profile))
|
(st/emit! (udu/fetch-profile))
|
||||||
|
|
||||||
(mx/mount (app) (dom/get-element "app"))
|
(mx/mount (ui/app) (dom/get-element "app"))
|
||||||
(mx/mount (lightbox) (dom/get-element "lightbox"))
|
(mx/mount (lightbox) (dom/get-element "lightbox"))
|
||||||
(mx/mount (loader) (dom/get-element "loader"))
|
(mx/mount (loader) (dom/get-element "loader"))
|
||||||
|
|
||||||
|
|
|
@ -30,20 +30,38 @@
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
[rumext.core :as mx :include-macros true]))
|
[rumext.core :as mx :include-macros true]))
|
||||||
|
|
||||||
;; --- Constants
|
;; --- Refs
|
||||||
|
|
||||||
(def route-ref
|
(def route-ref
|
||||||
(-> (l/key :route)
|
(-> (l/key :route)
|
||||||
(l/derive st/state)))
|
(l/derive st/state)))
|
||||||
|
|
||||||
|
;; --- Routes
|
||||||
|
|
||||||
|
(def routes
|
||||||
|
[["/auth"
|
||||||
|
["/login" :auth/login]
|
||||||
|
["/register" :auth/register]
|
||||||
|
["/recovery/request" :auth/recovery-request]
|
||||||
|
["/recovery/token/:token" :auth/recovery]]
|
||||||
|
["/settings"
|
||||||
|
["/profile" :settings/profile]
|
||||||
|
["/password" :settings/password]
|
||||||
|
["/notifications" :settings/notifications]]
|
||||||
|
["/dashboard"
|
||||||
|
["/projects" :dashboard/projects]
|
||||||
|
["/elements" :dashboard/elements]
|
||||||
|
["/icons" :dashboard/icons]
|
||||||
|
["/images" :dashboard/images]
|
||||||
|
["/colors" :dashboard/colors]]
|
||||||
|
["/workspace/:project/:page" :workspace/page]])
|
||||||
|
|
||||||
;; --- Main App (Component)
|
;; --- Main App (Component)
|
||||||
|
|
||||||
(mx/defc app
|
(mx/defc app
|
||||||
{:mixins [mx/reactive]}
|
{:mixins [mx/reactive]}
|
||||||
[]
|
[]
|
||||||
(let [route (mx/react route-ref)
|
(let [route (mx/react route-ref)]
|
||||||
auth (mx/react st/auth-ref)]
|
|
||||||
(prn "main$app" route)
|
|
||||||
(case (get-in route [:data :name])
|
(case (get-in route [:data :name])
|
||||||
:auth/login (auth/login-page)
|
:auth/login (auth/login-page)
|
||||||
:auth/register (auth/register-page)
|
:auth/register (auth/register-page)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue