views.cljs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. (ns lineup.views
  2. (:require
  3. [lineup.events :as events]
  4. [lineup.subs :as subs]
  5. [re-com.core :as re-com]
  6. [re-frame.core :as re-frame]))
  7. (defn- top-bar [mode]
  8. [re-com/h-box
  9. :style {:padding-right "10px"}
  10. :justify :between
  11. :align :center
  12. :children
  13. [[re-com/title
  14. :label "Schedule"
  15. :level :level2]
  16. [re-com/hyperlink
  17. :label (if (= mode :edit) "done" "edit")
  18. :on-click #(re-frame/dispatch [::events/toggle-mode (if (= mode :edit) :normal :edit)])]]])
  19. (defn- slot [index task]
  20. [re-com/box
  21. :width "300px"
  22. :height "300px"
  23. :style {:padding "10px"
  24. :border "3px solid black"
  25. :border-radius "10px"
  26. :background-color "white"}
  27. :child
  28. [:div
  29. {:style {:width "100%"
  30. :height "100%"
  31. :cursor "pointer"}
  32. :on-click #(re-frame/dispatch [::events/toggle-task-complete index])}
  33. "BOX"
  34. (when (:complete? task)
  35. "COMPLETE!")]])
  36. (defn- schedule []
  37. (let [task-list (re-frame/subscribe [::subs/schedule])
  38. list-complete? (re-frame/subscribe [::subs/complete])]
  39. [re-com/scroller
  40. :v-scroll :off
  41. :h-scroll :auto
  42. :style {:padding "20px 10px"}
  43. :width "100%"
  44. :child
  45. [re-com/h-box
  46. :gap "10px"
  47. :align :center
  48. :children
  49. (concat
  50. [[re-com/box
  51. :height "150px"
  52. :width "150px"
  53. :child
  54. [:img
  55. {:src "go.png"}]]]
  56. (map-indexed
  57. (fn [index task]
  58. ^{:key (str "slot-" index)}
  59. [slot index task])
  60. @task-list)
  61. [[re-com/box
  62. :height "150px"
  63. :width "150px"
  64. :child
  65. [:img
  66. {:src (if @list-complete? "clapping.gif" "clapping.png")}]]])]]))
  67. (defn main-panel []
  68. (let [mode (re-frame/subscribe [::subs/mode])]
  69. [re-com/v-box
  70. :gap "10px"
  71. :height "100%"
  72. :children
  73. [[top-bar @mode]
  74. (if (= @mode :edit)
  75. [:div "EDITING!"]
  76. [schedule])]]))