0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 08:50:57 -05:00
penpot/frontend/uxbox/ui/dashboard/header.cljs

54 lines
1.7 KiB
Text
Raw Normal View History

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