From feb00d83f85e36bcf230e3736a67f6bb34696b35 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 16 Dec 2015 13:02:15 +0200 Subject: [PATCH] WIP: restructure dashboard source. --- frontend/uxbox/router.cljs | 10 ++--- frontend/uxbox/ui.cljs | 14 +++---- .../uxbox/ui/{ => dashboard}/elements.cljs | 10 ++--- frontend/uxbox/ui/dashboard/header.cljs | 37 +++++++++++++++++++ .../projects.cljs} | 14 +++---- frontend/uxbox/ui/header.cljs | 31 ---------------- frontend/uxbox/ui/users.cljs | 6 +-- frontend/uxbox/ui/workspace.cljs | 2 +- 8 files changed, 65 insertions(+), 59 deletions(-) rename frontend/uxbox/ui/{ => dashboard}/elements.cljs (99%) create mode 100644 frontend/uxbox/ui/dashboard/header.cljs rename frontend/uxbox/ui/{dashboard.cljs => dashboard/projects.cljs} (97%) delete mode 100644 frontend/uxbox/ui/header.cljs diff --git a/frontend/uxbox/router.cljs b/frontend/uxbox/router.cljs index 8d72a43f1..3dcb03105 100644 --- a/frontend/uxbox/router.cljs +++ b/frontend/uxbox/router.cljs @@ -59,10 +59,10 @@ routes ["/" [["auth/login" :auth/login] ["auth/register" :auth/register] ["auth/recover" :auth/recover-password] - ["dashboard" :main/dashboard] - ["elements" :main/elements] - ["icons" :main/icons] - ["colors" :main/colors] + ["dashboard/" [["projects" :dashboard/projects] + ["elements" :dashboard/elements] + ["icons" :dashboard/icons] + ["colors" :dashboard/colors]]] ["workspace/" [[project-route :main/project] [page-route :main/page]]]]]) @@ -72,7 +72,7 @@ (defonce +router+ (bidi.router/start-router! routes {:on-navigate on-navigate - :default-location {:handler :main/dashboard}})) + :default-location {:handler :auth/login}})) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Public Api diff --git a/frontend/uxbox/ui.cljs b/frontend/uxbox/ui.cljs index baa40191f..d8fac57db 100644 --- a/frontend/uxbox/ui.cljs +++ b/frontend/uxbox/ui.cljs @@ -8,9 +8,9 @@ [uxbox.data.projects :as dp] [uxbox.ui.lightbox :as ui.lb] [uxbox.ui.users :as ui.users] - [uxbox.ui.elements :as ui.elements] - [uxbox.ui.workspace :as ui.w] - [uxbox.ui.dashboard :as ui.dashboard])) + [uxbox.ui.dashboard.projects :as ui.dashboard.projects] + [uxbox.ui.dashboard.elements :as ui.dashboard.elements] + [uxbox.ui.workspace :as ui.w])) (def ^:static state (as-> (l/select-keys [:location :location-params]) $ @@ -24,10 +24,10 @@ (ui.lb/lightbox) (case location :auth/login (ui.users/login) - :main/dashboard (ui.dashboard/dashboard) - :main/elements (ui.elements/elements) - :main/icons (ui.elements/icons) - :main/colors (ui.elements/colors) + :dashboard/projects (ui.dashboard.projects/projects) + :dashboard/elements (ui.dashboard.elements/elements) + :dashboard/icons (ui.dashboard.elements/icons) + :dashboard/colors (ui.dashboard.elements/colors) :main/page (let [projectid (:project-uuid location-params) pageid (:page-uuid location-params)] (ui.w/workspace projectid pageid)) diff --git a/frontend/uxbox/ui/elements.cljs b/frontend/uxbox/ui/dashboard/elements.cljs similarity index 99% rename from frontend/uxbox/ui/elements.cljs rename to frontend/uxbox/ui/dashboard/elements.cljs index 5064f360c..2c49cd42c 100644 --- a/frontend/uxbox/ui/elements.cljs +++ b/frontend/uxbox/ui/dashboard/elements.cljs @@ -1,7 +1,7 @@ -(ns uxbox.ui.elements +(ns uxbox.ui.dashboard.elements (:require [sablono.core :as html :refer-macros [html]] [rum.core :as rum] - [uxbox.ui.header :as ui.header] + [uxbox.ui.dashboard.header :as dsh.header] [uxbox.ui.library-bar :as ui.library-bar] [uxbox.ui.icons :as i] [uxbox.ui.lightbox :as lightbox] @@ -16,7 +16,7 @@ [own] (html [:main.dashboard-main - (ui.header/header) + (dsh.header/header) [:section.dashboard-content [:section#dashboard-bar.dashboard-bar.library-gap [:div.dashboard-info @@ -134,7 +134,7 @@ [own] (html [:main.dashboard-main - (ui.header/header) + (dsh.header/header) [:section.dashboard-content [:section#dashboard-bar.dashboard-bar.library-gap [:div.dashboard-info @@ -289,7 +289,7 @@ [own] (html [:main.dashboard-main - (ui.header/header) + (dsh.header/header) [:section.dashboard-content [:section#dashboard-bar.dashboard-bar.library-gap [:div.dashboard-info diff --git a/frontend/uxbox/ui/dashboard/header.cljs b/frontend/uxbox/ui/dashboard/header.cljs new file mode 100644 index 000000000..2a897638f --- /dev/null +++ b/frontend/uxbox/ui/dashboard/header.cljs @@ -0,0 +1,37 @@ +(ns uxbox.ui.dashboard.header + (:require [sablono.core :as html :refer-macros [html]] + [rum.core :as rum] + [uxbox.util :as util] + [uxbox.router :as r] + [uxbox.ui.navigation :as nav] + [uxbox.ui.icons :as i] + [uxbox.ui.users :as ui.u])) + +(defn header-render + [own] + (let [local (:rum/local own) + projects? (= (:section local) :projects) + elements? (= (:section local) :elements) + icons? (= (:section local) :icons) + colors? (= (:section local) :colores)] + (html + [:header#main-bar.main-bar + [:div.main-logo + (nav/link "/" i/logo)] + [:ul.main-nav + [:li {:class (when projects? "current")} + (nav/link (r/route-for :dashboard/projects) "PROJECTS")] + [:li {:class (when elements? "current")} + (nav/link (r/route-for :dashboard/elements) "ELEMENTS")] + [:li {:class (when icons? "current")} + (nav/link (r/route-for :dashboard/icons) "ICONS")] + [:li {:class (when colors? "current")} + (nav/link (r/route-for :dashboard/colors) "COLORS")]] + (ui.u/user)]))) + +(def ^:static header + (util/component + {:render header-render + :name "header" + :mixins [rum/static + (rum/local {:section :projects})]})) diff --git a/frontend/uxbox/ui/dashboard.cljs b/frontend/uxbox/ui/dashboard/projects.cljs similarity index 97% rename from frontend/uxbox/ui/dashboard.cljs rename to frontend/uxbox/ui/dashboard/projects.cljs index 2f7d320ad..b0297ea9f 100644 --- a/frontend/uxbox/ui/dashboard.cljs +++ b/frontend/uxbox/ui/dashboard/projects.cljs @@ -1,4 +1,4 @@ -(ns uxbox.ui.dashboard +(ns uxbox.ui.dashboard.projects (:require [sablono.core :as html :refer-macros [html]] [rum.core :as rum] [cats.labs.lens :as l] @@ -11,7 +11,7 @@ [uxbox.ui.icons.dashboard :as icons] [uxbox.ui.icons :as i] [uxbox.ui.dom :as dom] - [uxbox.ui.header :as ui.h] + [uxbox.ui.dashboard.header :as dsh.header] [uxbox.ui.lightbox :as lightbox] [uxbox.time :refer [ago]])) @@ -256,16 +256,16 @@ ;; Main ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defn dashboard-render +(defn projects-render [own] (html [:main.dashboard-main - (ui.h/header) + (dsh.header/header) [:section.dashboard-content (menu) (grid)]])) -(def dashboard - (util/component {:render dashboard-render +(def projects + (util/component {:render projects-render :mixins [rum/static] - :name "dashboard"})) + :name "projects"})) diff --git a/frontend/uxbox/ui/header.cljs b/frontend/uxbox/ui/header.cljs deleted file mode 100644 index 3d4ee4cde..000000000 --- a/frontend/uxbox/ui/header.cljs +++ /dev/null @@ -1,31 +0,0 @@ -(ns uxbox.ui.header - (:require [sablono.core :as html :refer-macros [html]] - [rum.core :as rum] - [uxbox.util :as util] - [uxbox.router :as r] - [uxbox.ui.navigation :as nav] - [uxbox.ui.icons :as i] - [uxbox.ui.users :as ui.u])) - -(defn header-render - [own] - (html - [:header#main-bar.main-bar - [:div.main-logo - (nav/link "/" i/logo)] - [:ul.main-nav - [:li.current - [:a {:href "/#/"} "PROJECTS"]] - [:li - [:a {:href "/#/elements"} "ELEMENTS"]] - [:li - [:a {:href "/#/icons"} "ICONS"]] - [:li - [:a {:href "/#/colors"} "COLORS"]]] - (ui.u/user)])) - -(def ^:static header - (util/component - {:render header-render - :name "header" - :mixins [rum/static]})) diff --git a/frontend/uxbox/ui/users.cljs b/frontend/uxbox/ui/users.cljs index 1e5602fb3..48fe371c7 100644 --- a/frontend/uxbox/ui/users.cljs +++ b/frontend/uxbox/ui/users.cljs @@ -93,7 +93,7 @@ {:name "login" :value "Continue" :type "submit" - :on-click #(r/go :main/dashboard)}] + :on-click #(r/go :dashboard/projects)}] [:div.login-links [:a {:on-click #(r/go :auth/login)} @@ -117,7 +117,7 @@ {:name "login" :value "Continue" :type "submit" - :on-click #(r/go :main/dashboard)}] + :on-click #(r/go :dashboard/projects)}] [:div.login-links [:a {:on-click #(r/go :auth/login)} @@ -156,7 +156,7 @@ {:name "login" :value "Continue" :type "submit" - :on-click #(r/go :main/dashboard)}] + :on-click #(r/go :dashboard/projects)}] [:div.login-links [:a {:on-click #(r/go :auth/recover-password)} "Forgot your password?"] [:a {:on-click #(r/go :auth/register)} "Don't have an account?"]]]) diff --git a/frontend/uxbox/ui/workspace.cljs b/frontend/uxbox/ui/workspace.cljs index c8ff56d29..f2b4e5df0 100644 --- a/frontend/uxbox/ui/workspace.cljs +++ b/frontend/uxbox/ui/workspace.cljs @@ -49,7 +49,7 @@ (html [:header#workspace-bar.workspace-bar [:div.main-icon - (nav/link (r/route-for :main/dashboard) i/logo-icon)] + (nav/link (r/route-for :dashboard/projects) i/logo-icon)] [:div.project-tree-btn {:on-click (constantly nil)} i/project-tree