Skip to content

Commit

Permalink
Split up room component
Browse files Browse the repository at this point in the history
  • Loading branch information
deciduously committed Mar 4, 2018
1 parent 8fe7ddd commit 3ef0d0e
Showing 1 changed file with 28 additions and 18 deletions.
46 changes: 28 additions & 18 deletions src/cljs/attendance/ui.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,37 @@
[:li.kid
[button status (str name " - " status) #(s/toggle-kid! idx)]]))

(defn kidlist
"Render a list of attendance toggles from a list of kids"
[max enrolled]
(let [kids (map s/get-kid enrolled)]
[:ul.kidlist
[:li.capacity
(str (count (filter :here kids)) "/" (count kids)
" Max: " max)]
(for [k kids]
^{:key (:idx k)}
[kid k])]))

(defn absentlist
"Render a list of the absent kids in the given room letter"
[letter]
[:ul.absentlist
[:li [:h4 "Out"]]
(doall
(for [out (s/absent letter)]
(let [n (:name out)]
^{:key n}
[:li.absent n])))])

(defn room
"Render a class of children"
[{:keys [letter max enrolled]} r]
(let [kids (map s/get-kid enrolled)]
[:li.room
[:div.roomContent
[:h4.roomletter (str "Room " letter)]
[:ul.kidlist
[:li.capacity
(str (count (filter :here kids)) "/" (count kids)
" Max: " max)]
(for [k kids]
^{:key (:idx k)}
[kid k])]
[:ul.absentlist
[:li [:h4 "Out"]]
(doall
(for [out (s/absent letter)]
(let [n (:name out)]
^{:key n}
[:li.absent n])))]]]))
[:li.room
[:div.roomContent
[:h4.roomletter (str "Room " letter)]
[kidlist max enrolled]
[absentlist letter]]])

(defn core-roster
"Render all core rooms"
Expand Down

0 comments on commit 3ef0d0e

Please sign in to comment.