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]]
|
2015-12-17 12:51:36 +02:00
|
|
|
[goog.dom :as gdom]
|
2015-12-14 10:48:50 +02:00
|
|
|
[rum.core :as rum]
|
2015-06-18 19:35:50 +02:00
|
|
|
[cats.labs.lens :as l]
|
|
|
|
[uxbox.state :as s]
|
2015-12-14 20:31:21 +02:00
|
|
|
[uxbox.rstore :as rs]
|
|
|
|
[uxbox.data.projects :as dp]
|
2015-12-14 10:48:50 +02:00
|
|
|
[uxbox.ui.lightbox :as ui.lb]
|
2015-12-15 11:22:04 +02:00
|
|
|
[uxbox.ui.users :as ui.users]
|
2015-12-16 13:02:15 +02:00
|
|
|
[uxbox.ui.dashboard.projects :as ui.dashboard.projects]
|
|
|
|
[uxbox.ui.dashboard.elements :as ui.dashboard.elements]
|
2015-12-17 16:43:58 +02:00
|
|
|
[uxbox.ui.workspace :as ui.w]
|
|
|
|
[uxbox.ui.util :as util]
|
|
|
|
[uxbox.ui.mixins :as mx]))
|
|
|
|
|
2015-06-18 19:35:50 +02:00
|
|
|
|
2015-12-14 14:17:18 +02:00
|
|
|
(def ^:static state
|
2015-12-13 22:57:14 +02:00
|
|
|
(as-> (l/select-keys [:location :location-params]) $
|
2015-06-18 19:35:50 +02:00
|
|
|
(l/focus-atom $ s/state)))
|
|
|
|
|
|
|
|
(defn app-render
|
|
|
|
[own]
|
2015-12-13 22:57:14 +02:00
|
|
|
(let [{:keys [location location-params] :as state} (rum/react state)]
|
2015-12-17 17:01:52 +02:00
|
|
|
(println "app-render" location state)
|
2015-12-17 12:51:36 +02:00
|
|
|
(case location
|
|
|
|
:auth/login (ui.users/login)
|
|
|
|
:dashboard/projects (ui.dashboard.projects/projects)
|
|
|
|
:dashboard/elements (ui.dashboard.elements/elements)
|
|
|
|
:dashboard/icons (ui.dashboard.elements/icons)
|
|
|
|
:dashboard/colors (ui.dashboard.elements/colors)
|
|
|
|
:workspace/page (let [projectid (:project-uuid location-params)
|
|
|
|
pageid (:page-uuid location-params)]
|
|
|
|
(ui.w/workspace projectid pageid))
|
|
|
|
nil
|
|
|
|
)))
|
2015-06-18 19:35:50 +02:00
|
|
|
|
|
|
|
(def app
|
|
|
|
(util/component {:render app-render
|
|
|
|
:mixins [rum/reactive]
|
|
|
|
:name "app"}))
|
2015-12-17 12:51:36 +02:00
|
|
|
(defn init
|
|
|
|
[]
|
|
|
|
(let [app-dom (gdom/getElement "app")
|
|
|
|
lb-dom (gdom/getElement "lightbox")]
|
2015-12-17 17:01:52 +02:00
|
|
|
(rum/mount (app) app-dom)
|
|
|
|
(rum/mount (ui.lb/lightbox) lb-dom)))
|