Advertisement
dredder_gun

todo-app

Jul 18th, 2017
582
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defn todo-app [& props]
  2.   (let [filt (r/atom :all)]
  3.     (init)
  4.     (fn []
  5.       (let [items (vals @todos)
  6.             done (->> items (filter :done) count)
  7.             active (- (count items) done)]
  8.         [:div
  9.           [:div.form-group
  10.             {:style {:margin-top "20px"}}
  11.             [:button.btn.btn-default
  12.               ; { :type "button" :on-click do-logout}
  13.               { :type "button" :on-click #(do-logout)}
  14.               [:b "Выйти"]]]
  15.          ;
  16.          [:section#todoapp
  17.           [:header#header
  18.            [:h1 "todos"]
  19.            [todo-input {:id "new-todo"
  20.                         :placeholder "What needs to be done?"
  21.                         :on-save add-todo}]]
  22.           (when (-> items count pos?)
  23.             [:div
  24.              [:section#main
  25.               [:input#toggle-all {:type "checkbox" :checked (zero? active)
  26.                                   :on-change #(complete-all (pos? active))}]
  27.               [:label {:for "toggle-all"} "Mark all as complete"]
  28.               [:ul#todo-list
  29.                (for [todo (filter (case @filt
  30.                                     :active (complement :done)
  31.                                     :done :done
  32.                                     :all identity) items)]
  33.                  ^{:key (:id todo)} [todo-item todo])]]
  34.              [:footer#footer
  35.               [todo-stats {:active active :done done :filt filt}]]])]
  36.          [:footer#info
  37.           [:p "Double-click to edit a todo"]]
  38.         ;
  39.         ]))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement