Use form-2 please

This commit is contained in:
kagel 2016-08-23 15:07:35 +03:00
parent 601465ad39
commit 58a66236e7
1 changed files with 39 additions and 32 deletions

View File

@ -13,40 +13,45 @@
(:import goog.History)) (:import goog.History))
(defn nav-link [uri title page collapsed?] (defn nav-link [uri title page collapsed?]
(let [selected-page (rf/subscribe [:page])] [:li.nav-item (let [selected-page (rf/subscribe [:page])]
{:class (when (= page @selected-page) "active")} (fn []
[:a.nav-link [:li.nav-item
{:href uri {:class (when (= page @selected-page) "active")}
:on-click #(reset! collapsed? true)} title]])) [:a.nav-link
{:href uri
:on-click #(reset! collapsed? true)} title]])))
(defn login-link [] (defn login-link []
(let [user (rf/subscribe [:user])] (let [user (rf/subscribe [:user])]
(if-let [login (:login @user)] (fn []
[:li.pull-right.p (if-let [login (:login @user)]
[:span.profile-link "Logged in as " [:li.pull-right.p
[:a {:href "/#/profile"} login]] [:span.profile-link "Logged in as "
[:a.btn.btn-primary.btn-sm {:href "/logout"} "Logout"]] [:a {:href "/#/profile"} login]]
[:li.pull-right [:a.btn.btn-primary.btn-sm {:href "/logout"} "Logout"]]
[:a.btn.btn-social.btn-github [:li.pull-right
{:href js/authorizeUrl} [:a.btn.btn-social.btn-github
[:i.fa.fa-github] {:href js/authorizeUrl}
"Sign in with GitHub"]]))) [:i.fa.fa-github]
"Sign in with GitHub"]]))))
(defn navbar [] (defn navbar []
(r/with-let [collapsed? (r/atom true)] (r/with-let [collapsed? (r/atom true)]
[:nav.navbar.navbar-light.bg-faded (fn []
[:button.navbar-toggler.hidden-sm-up [:nav.navbar.navbar-light.bg-faded
{:on-click #(swap! collapsed? not)} "☰"] [:button.navbar-toggler.hidden-sm-up
[:div.collapse.navbar-toggleable-xs {:on-click #(swap! collapsed? not)} "☰"]
(when-not @collapsed? {:class "in"}) [:div.collapse.navbar-toggleable-xs
[:a.navbar-brand {:href "#/"} "commiteth"] (when-not @collapsed? {:class "in"})
[:ul.nav.navbar-nav [:a.navbar-brand {:href "#/"} "commiteth"]
[nav-link "#/" "Home" :home collapsed?] [:ul.nav.navbar-nav
[login-link]]]])) [nav-link "#/" "Home" :home collapsed?]
[login-link]]]])))
(defn home-page [] (defn home-page []
[:div (fn []
[:h3 "Welcome to commitETH"]]) [:div
[:h3 "Welcome to commitETH"]]))
(defn input [{:keys [value-path]}] (defn input [{:keys [value-path]}]
(let [val (reagent/atom nil) (let [val (reagent/atom nil)
@ -80,18 +85,20 @@
"Save"]]))) "Save"]])))
(defn profile-page [] (defn profile-page []
[:div.profile-settings (fn []
[:h1 "Profile"] [:div.profile-settings
[address-settings]]) [:h1 "Profile"]
[address-settings]]))
(def pages (def pages
{:home #'home-page {:home #'home-page
:profile #'profile-page}) :profile #'profile-page})
(defn page [] (defn page []
[:div.app (fn []
[navbar] [:div.app
[:div.container [(pages @(rf/subscribe [:page]))]]]) [navbar]
[:div.container [(pages @(rf/subscribe [:page]))]]]))
;; ------------------------- ;; -------------------------
;; Routes ;; Routes