From 88d1030e12a25b0f00000e539bebf5176cb8d13f Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Sun, 27 Dec 2015 15:28:34 +0200 Subject: [PATCH] Add icons toolbox. --- frontend/uxbox/ui/workspace/toolboxes.cljs | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/frontend/uxbox/ui/workspace/toolboxes.cljs b/frontend/uxbox/ui/workspace/toolboxes.cljs index 9dd6d1e13..b3f053031 100644 --- a/frontend/uxbox/ui/workspace/toolboxes.cljs +++ b/frontend/uxbox/ui/workspace/toolboxes.cljs @@ -102,3 +102,45 @@ :name "layers" :mixins [rum/reactive]})) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Icons +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defn icons-render + [own] + (let [local (:rum/local own) + collid (:collid @local) + icons (get-in library/+icon-collections-by-id+ [collid :icons]) + on-close #(rs/emit! (dw/toggle-toolbox :icons)) + on-change (fn [e] + (let [value (dom/event->value e) + value (read-string value)] + (swap! local assoc :collid value)))] + (html + [:div#form-figures.tool-window + [:div.tool-window-bar + [:div.tool-window-icon i/window] + [:span "Icons"] + [:div.tool-window-close + {:on-click on-close} i/close]] + [:div.tool-window-content + [:div.figures-catalog + ;; extract component: set selector + [:select.input-select.small + {:on-change on-change :value collid} ; TODO: maybe missing pr-str + (for [icon-coll library/+icon-collections+] + [:option {:key (str "icon-coll" (:id icon-coll)) + :value (pr-str (:id icon-coll))} + (:name icon-coll)])]] + (for [icon icons] + [:div.figure-btn {:key (str "icon" (:id icon)) + :class nil #_"selected" + :on-click (constantly nil)} + (shapes/render icon)])]]))) + +(def ^:static icons + (util/component + {:render icons-render + :name "icons-toolbox" + :mixins [rum/reactive + (mx/local {:collid 1 :builtin true})]}))