0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-08 07:50:43 -05:00

misc(frontend): minor code reorganization

This commit is contained in:
Andrey Antukh 2019-07-03 17:57:29 +02:00
parent c2bdede29a
commit 9a313752c5
2 changed files with 25 additions and 25 deletions

View file

@ -12,7 +12,7 @@
[uxbox.main.locales.en :as en]
[uxbox.main.locales.fr :as fr]
[uxbox.main.store :as st]
[uxbox.main.ui :refer [app]]
[uxbox.main.ui :as ui]
[uxbox.main.ui.lightbox :refer [lightbox]]
[uxbox.main.ui.loader :refer [loader]]
[uxbox.util.dom :as dom]
@ -65,24 +65,6 @@
(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
[router path]
(let [match (rt/match router path)]
@ -99,7 +81,7 @@
(defn init-ui
[]
(let [router (rt/init routes)
(let [router (rt/init ui/routes)
cpath (deref html-history/path)]
(st/emit! #(assoc % :router router))
@ -107,7 +89,7 @@
(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 (loader) (dom/get-element "loader"))

View file

@ -30,20 +30,38 @@
[uxbox.util.dom :as dom]
[rumext.core :as mx :include-macros true]))
;; --- Constants
;; --- Refs
(def route-ref
(-> (l/key :route)
(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)
(mx/defc app
{:mixins [mx/reactive]}
[]
(let [route (mx/react route-ref)
auth (mx/react st/auth-ref)]
(prn "main$app" route)
(let [route (mx/react route-ref)]
(case (get-in route [:data :name])
:auth/login (auth/login-page)
:auth/register (auth/register-page)