0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-15 09:11:21 -05:00
penpot/src/uxbox/ui.cljs

61 lines
1.8 KiB
Text
Raw Normal View History

2015-06-18 19:35:50 +02:00
(ns uxbox.ui
2015-12-14 10:48:50 +02:00
(:require [sablono.core :as html :refer-macros [html]]
[promesa.core :as p]
2015-12-17 12:51:36 +02:00
[goog.dom :as gdom]
2015-12-14 10:48:50 +02:00
[rum.core :as rum]
[lentes.core :as l]
2015-06-18 19:35:50 +02:00
[uxbox.state :as s]
[uxbox.router :as r]
2015-12-14 20:31:21 +02:00
[uxbox.rstore :as rs]
[uxbox.data.projects :as dp]
[uxbox.ui.lightbox :as ui-lightbox]
[uxbox.ui.auth :as ui-auth]
[uxbox.ui.dashboard :as ui-dashboard]
2015-12-20 14:41:38 +02:00
[uxbox.ui.workspace :refer (workspace)]
[uxbox.ui.mixins :as mx]
[uxbox.ui.shapes]))
2015-12-17 16:43:58 +02:00
(def ^:const auth-data
(as-> (l/key :auth) $
2015-06-18 19:35:50 +02:00
(l/focus-atom $ s/state)))
(def ^:const +unrestricted+
#{:auth/login})
(def ^:const restricted?
(complement +unrestricted+))
2015-06-18 19:35:50 +02:00
(defn app-render
[own]
(let [route (rum/react r/route-l)
auth (rum/react auth-data)
location (:id route)
params (:params route)]
(if (and (restricted? location) (not auth))
(do (p/schedule 0 #(r/go :auth/login)) nil)
(case location
:auth/login (ui-auth/login)
:dashboard/projects (ui-dashboard/projects-page)
:dashboard/elements (ui-dashboard/elements-page)
:dashboard/icons (ui-dashboard/icons-page)
:dashboard/colors (ui-dashboard/colors-page)
:workspace/page (let [projectid (:project-uuid params)
pageid (:page-uuid params)]
(workspace projectid pageid))
nil
))))
2015-06-18 19:35:50 +02:00
(def app
(mx/component
{:render app-render
:mixins [rum/reactive]
:name "app"}))
2015-12-17 12:51:36 +02:00
(defn init
[]
2016-01-17 23:32:55 +02:00
(println "ui/init")
2015-12-17 12:51:36 +02:00
(let [app-dom (gdom/getElement "app")
lb-dom (gdom/getElement "lightbox")]
(rum/mount (app) app-dom)
(rum/mount (ui-lightbox/lightbox) lb-dom)))