mirror of
https://github.com/penpot/penpot.git
synced 2025-01-08 16:00:19 -05:00
Add navigation to dashboard.
This commit is contained in:
parent
feb00d83f8
commit
61b05613f3
4 changed files with 44 additions and 20 deletions
|
@ -132,6 +132,17 @@
|
||||||
(-pr-writer [mv writer _]
|
(-pr-writer [mv writer _]
|
||||||
(-write writer "#<event:u.s.p/initialize-workspace>"))))
|
(-write writer "#<event:u.s.p/initialize-workspace>"))))
|
||||||
|
|
||||||
|
(defn set-dashboard-section
|
||||||
|
[section]
|
||||||
|
(reify
|
||||||
|
rs/UpdateEvent
|
||||||
|
(-apply-update [_ state]
|
||||||
|
(assoc-in state [:dashboard :section] section))
|
||||||
|
|
||||||
|
IPrintWithWriter
|
||||||
|
(-pr-writer [mv writer _]
|
||||||
|
(-write writer "#<event:u.s.p/go-to-project"))))
|
||||||
|
|
||||||
(defn go-to-project
|
(defn go-to-project
|
||||||
"A shortcut event that redirects the user to the
|
"A shortcut event that redirects the user to the
|
||||||
first page of the project."
|
first page of the project."
|
||||||
|
|
|
@ -57,8 +57,8 @@
|
||||||
|
|
||||||
(def ^:static
|
(def ^:static
|
||||||
routes ["/" [["auth/login" :auth/login]
|
routes ["/" [["auth/login" :auth/login]
|
||||||
["auth/register" :auth/register]
|
;; ["auth/register" :auth/register]
|
||||||
["auth/recover" :auth/recover-password]
|
;; ["auth/recover" :auth/recover-password]
|
||||||
["dashboard/" [["projects" :dashboard/projects]
|
["dashboard/" [["projects" :dashboard/projects]
|
||||||
["elements" :dashboard/elements]
|
["elements" :dashboard/elements]
|
||||||
["icons" :dashboard/icons]
|
["icons" :dashboard/icons]
|
||||||
|
@ -66,13 +66,10 @@
|
||||||
["workspace/" [[project-route :main/project]
|
["workspace/" [[project-route :main/project]
|
||||||
[page-route :main/page]]]]])
|
[page-route :main/page]]]]])
|
||||||
|
|
||||||
(defn- on-navigate
|
|
||||||
[data]
|
|
||||||
(rs/emit! (update-location data)))
|
|
||||||
|
|
||||||
(defonce +router+
|
(defonce +router+
|
||||||
(bidi.router/start-router! routes {:on-navigate on-navigate
|
(let [opts {:on-navigate #(rs/emit! (update-location %))
|
||||||
:default-location {:handler :auth/login}}))
|
:default-location {:handler :dashboard/projects}}]
|
||||||
|
(bidi.router/start-router! routes opts)))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Public Api
|
;; Public Api
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
(defonce stream
|
(defonce stream
|
||||||
(rs/init {:user {:fullname "Cirilla"
|
(rs/init {:user {:fullname "Cirilla"
|
||||||
:avatar "http://lorempixel.com/50/50/"}
|
:avatar "http://lorempixel.com/50/50/"}
|
||||||
:workspace nil
|
:dashboard {:section :dashboard/projects}
|
||||||
:projects-by-id {}
|
:projects-by-id {}
|
||||||
:pages-by-id {}}))
|
:pages-by-id {}}))
|
||||||
|
|
||||||
|
|
|
@ -1,32 +1,48 @@
|
||||||
(ns uxbox.ui.dashboard.header
|
(ns uxbox.ui.dashboard.header
|
||||||
(:require [sablono.core :as html :refer-macros [html]]
|
(:require [sablono.core :as html :refer-macros [html]]
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
|
[cats.labs.lens :as l]
|
||||||
[uxbox.util :as util]
|
[uxbox.util :as util]
|
||||||
[uxbox.router :as r]
|
[uxbox.router :as r]
|
||||||
|
[uxbox.rstore :as rs]
|
||||||
|
[uxbox.state :as s]
|
||||||
|
[uxbox.data.projects :as dp]
|
||||||
[uxbox.ui.navigation :as nav]
|
[uxbox.ui.navigation :as nav]
|
||||||
[uxbox.ui.icons :as i]
|
[uxbox.ui.icons :as i]
|
||||||
[uxbox.ui.users :as ui.u]))
|
[uxbox.ui.users :as ui.u]))
|
||||||
|
|
||||||
|
(def ^:static header-state
|
||||||
|
(as-> (l/in [:dashboard]) $
|
||||||
|
(l/focus-atom $ s/state)))
|
||||||
|
|
||||||
|
|
||||||
|
(defn- header-link
|
||||||
|
[section content]
|
||||||
|
(let [link (r/route-for section)
|
||||||
|
on-click #(rs/emit! (dp/set-dashboard-section section))]
|
||||||
|
(html
|
||||||
|
[:a {:href (str "/#" link) :on-click on-click} content])))
|
||||||
|
|
||||||
(defn header-render
|
(defn header-render
|
||||||
[own]
|
[own]
|
||||||
(let [local (:rum/local own)
|
(let [local (rum/react header-state)
|
||||||
projects? (= (:section local) :projects)
|
projects? (= (:section local) :dashboard/projects)
|
||||||
elements? (= (:section local) :elements)
|
elements? (= (:section local) :dashboard/elements)
|
||||||
icons? (= (:section local) :icons)
|
icons? (= (:section local) :dashboard/icons)
|
||||||
colors? (= (:section local) :colores)]
|
colors? (= (:section local) :dashboard/colors)]
|
||||||
(html
|
(html
|
||||||
[:header#main-bar.main-bar
|
[:header#main-bar.main-bar
|
||||||
[:div.main-logo
|
[:div.main-logo
|
||||||
(nav/link "/" i/logo)]
|
(header-link :dashboard/projects i/logo)]
|
||||||
[:ul.main-nav
|
[:ul.main-nav
|
||||||
[:li {:class (when projects? "current")}
|
[:li {:class (when projects? "current")}
|
||||||
(nav/link (r/route-for :dashboard/projects) "PROJECTS")]
|
(header-link :dashboard/projects "PROJECTS")]
|
||||||
[:li {:class (when elements? "current")}
|
[:li {:class (when elements? "current")}
|
||||||
(nav/link (r/route-for :dashboard/elements) "ELEMENTS")]
|
(header-link :dashboard/elements "ELEMENTS")]
|
||||||
[:li {:class (when icons? "current")}
|
[:li {:class (when icons? "current")}
|
||||||
(nav/link (r/route-for :dashboard/icons) "ICONS")]
|
(header-link :dashboard/icons "ICONS")]
|
||||||
[:li {:class (when colors? "current")}
|
[:li {:class (when colors? "current")}
|
||||||
(nav/link (r/route-for :dashboard/colors) "COLORS")]]
|
(header-link :dashboard/colors "COLORS")]]
|
||||||
(ui.u/user)])))
|
(ui.u/user)])))
|
||||||
|
|
||||||
(def ^:static header
|
(def ^:static header
|
||||||
|
@ -34,4 +50,4 @@
|
||||||
{:render header-render
|
{:render header-render
|
||||||
:name "header"
|
:name "header"
|
||||||
:mixins [rum/static
|
:mixins [rum/static
|
||||||
(rum/local {:section :projects})]}))
|
rum/reactive]}))
|
||||||
|
|
Loading…
Reference in a new issue