Add navigation to dashboard.

This commit is contained in:
Andrey Antukh 2015-12-16 13:57:42 +02:00
parent feb00d83f8
commit 61b05613f3
4 changed files with 44 additions and 20 deletions

View file

@ -1,32 +1,48 @@
(ns uxbox.ui.dashboard.header
(:require [sablono.core :as html :refer-macros [html]]
[rum.core :as rum]
[cats.labs.lens :as l]
[uxbox.util :as util]
[uxbox.router :as r]
[uxbox.rstore :as rs]
[uxbox.state :as s]
[uxbox.data.projects :as dp]
[uxbox.ui.navigation :as nav]
[uxbox.ui.icons :as i]
[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
[own]
(let [local (:rum/local own)
projects? (= (:section local) :projects)
elements? (= (:section local) :elements)
icons? (= (:section local) :icons)
colors? (= (:section local) :colores)]
(let [local (rum/react header-state)
projects? (= (:section local) :dashboard/projects)
elements? (= (:section local) :dashboard/elements)
icons? (= (:section local) :dashboard/icons)
colors? (= (:section local) :dashboard/colors)]
(html
[:header#main-bar.main-bar
[:div.main-logo
(nav/link "/" i/logo)]
(header-link :dashboard/projects i/logo)]
[:ul.main-nav
[:li {:class (when projects? "current")}
(nav/link (r/route-for :dashboard/projects) "PROJECTS")]
(header-link :dashboard/projects "PROJECTS")]
[:li {:class (when elements? "current")}
(nav/link (r/route-for :dashboard/elements) "ELEMENTS")]
(header-link :dashboard/elements "ELEMENTS")]
[:li {:class (when icons? "current")}
(nav/link (r/route-for :dashboard/icons) "ICONS")]
(header-link :dashboard/icons "ICONS")]
[:li {:class (when colors? "current")}
(nav/link (r/route-for :dashboard/colors) "COLORS")]]
(header-link :dashboard/colors "COLORS")]]
(ui.u/user)])))
(def ^:static header
@ -34,4 +50,4 @@
{:render header-render
:name "header"
:mixins [rum/static
(rum/local {:section :projects})]}))
rum/reactive]}))