diff --git a/frontend/uxbox/data/projects.cljs b/frontend/uxbox/data/projects.cljs index 71fe2cce3..5fee97a16 100644 --- a/frontend/uxbox/data/projects.cljs +++ b/frontend/uxbox/data/projects.cljs @@ -132,6 +132,17 @@ (-pr-writer [mv writer _] (-write writer "#")))) +(defn set-dashboard-section + [section] + (reify + rs/UpdateEvent + (-apply-update [_ state] + (assoc-in state [:dashboard :section] section)) + + IPrintWithWriter + (-pr-writer [mv writer _] + (-write writer "# (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]}))