Parametrize recent colors component.

This commit is contained in:
Andrey Antukh 2016-01-21 00:13:43 +02:00
parent e3ebdb68b2
commit f786b8acab

View File

@ -42,19 +42,18 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn- recent-colors-render (defn- recent-colors-render
[own {:keys [page id] :as shape}] [own {:keys [page id] :as shape} callback]
(let [shapes-by-id (rum/react shapes-by-id) (let [shapes-by-id (rum/react shapes-by-id)
shapes (->> (vals shapes-by-id) shapes (->> (vals shapes-by-id)
(filter #(= (:page %) page))) (filter #(= (:page %) page)))
colors (calculate-colors shapes) colors (calculate-colors shapes)]
on-click #(rs/emit! (dw/update-shape-fill id {:fill %}))]
(html (html
[:div [:div
[:span "Recent colors"] [:span "Recent colors"]
[:div.row-flex [:div.row-flex
(for [color colors] (for [color colors]
[:span.color-th {:style {:background color} [:span.color-th {:style {:background color}
:on-click (partial on-click color)}]) :on-click (partial callback color)}])
(for [i (range (- 5 (count colors)))] (for [i (range (- 5 (count colors)))]
[:span.color-th]) [:span.color-th])