0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-09 08:38:15 -05:00
penpot/frontend/uxbox/ui/dashboard/header.cljs

52 lines
1.6 KiB
Text
Raw Normal View History

2015-12-16 13:02:15 +02:00
(ns uxbox.ui.dashboard.header
(:require [sablono.core :as html :refer-macros [html]]
[rum.core :as rum]
2015-12-16 13:57:42 +02:00
[cats.labs.lens :as l]
2015-12-16 13:02:15 +02:00
[uxbox.router :as r]
2015-12-16 13:57:42 +02:00
[uxbox.rstore :as rs]
[uxbox.state :as s]
[uxbox.data.projects :as dp]
2015-12-16 13:02:15 +02:00
[uxbox.ui.navigation :as nav]
[uxbox.ui.icons :as i]
2015-12-17 16:43:58 +02:00
[uxbox.ui.users :as ui.u]
[uxbox.ui.util :as util]))
2015-12-16 13:02:15 +02:00
2015-12-16 13:57:42 +02:00
(def ^:static header-state
(as-> (l/in [:dashboard]) $
(l/focus-atom $ s/state)))
(defn- header-link
[section content]
(let [link (r/route-for section)]
2015-12-16 13:57:42 +02:00
(html
[:a {:href (str "/#" link)} content])))
2015-12-16 13:57:42 +02:00
2015-12-16 13:02:15 +02:00
(defn header-render
[own]
2015-12-16 13:57:42 +02:00
(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)]
2015-12-16 13:02:15 +02:00
(html
[:header#main-bar.main-bar
[:div.main-logo
2015-12-16 13:57:42 +02:00
(header-link :dashboard/projects i/logo)]
2015-12-16 13:02:15 +02:00
[:ul.main-nav
[:li {:class (when projects? "current")}
2015-12-16 13:57:42 +02:00
(header-link :dashboard/projects "PROJECTS")]
2015-12-16 13:02:15 +02:00
[:li {:class (when elements? "current")}
2015-12-16 13:57:42 +02:00
(header-link :dashboard/elements "ELEMENTS")]
2015-12-16 13:02:15 +02:00
[:li {:class (when icons? "current")}
2015-12-16 13:57:42 +02:00
(header-link :dashboard/icons "ICONS")]
2015-12-16 13:02:15 +02:00
[:li {:class (when colors? "current")}
2015-12-16 13:57:42 +02:00
(header-link :dashboard/colors "COLORS")]]
2015-12-16 13:02:15 +02:00
(ui.u/user)])))
(def ^:static header
(util/component
{:render header-render
:name "header"
:mixins [rum/static
2015-12-16 13:57:42 +02:00
rum/reactive]}))