diff --git a/frontend/uxbox/library.cljs b/frontend/uxbox/library.cljs new file mode 100644 index 000000000..4c6fa2260 --- /dev/null +++ b/frontend/uxbox/library.cljs @@ -0,0 +1,9 @@ +(ns uxbox.library + (:require [uxbox.library.colors :as colors] + [uxbox.util.data :refer (index-by-id)])) + +(def ^:static +color-collections+ + colors/+collections+) + +(def ^:static +color-collections-by-id+ + (index-by-id colors/+collections+)) diff --git a/frontend/uxbox/ui/dashboard/builtins.cljs b/frontend/uxbox/library/colors.cljs similarity index 69% rename from frontend/uxbox/ui/dashboard/builtins.cljs rename to frontend/uxbox/library/colors.cljs index acfe9d925..af0a52207 100644 --- a/frontend/uxbox/ui/dashboard/builtins.cljs +++ b/frontend/uxbox/library/colors.cljs @@ -1,6 +1,6 @@ -(ns uxbox.ui.dashboard.builtins) +(ns uxbox.library.colors) -(def ^:static +color-collections+ +(def ^:static +collections+ [{:name "Generic 1" :id 1 :builtin true @@ -12,8 +12,8 @@ "#7502f1" "#ffe705" "#00ffab" - "#f52105" - }} + "#f52105"}} + {:name "Generic 2" :id 2 :builtin true @@ -34,10 +34,4 @@ "#3fe720" "#30ff20" "#352120" - "#352140" - }}]) - -(def ^:static +color-collections-by-id+ - (let [data (transient {})] - (run! #(assoc! data (:id %) %) +color-collections+) - (persistent! data))) + "#352140"}}]) diff --git a/frontend/uxbox/ui/dashboard/colors.cljs b/frontend/uxbox/ui/dashboard/colors.cljs index a9cb84894..46eeb666c 100644 --- a/frontend/uxbox/ui/dashboard/colors.cljs +++ b/frontend/uxbox/ui/dashboard/colors.cljs @@ -6,11 +6,11 @@ [uxbox.state :as st] [uxbox.rstore :as rs] [uxbox.schema :as sc] + [uxbox.library :as library] [uxbox.data.dashboard :as dd] [uxbox.util.lens :as ul] [uxbox.ui.icons :as i] [uxbox.ui.form :as form] - [uxbox.ui.dashboard.builtins :as builtins] [uxbox.ui.lightbox :as lightbox] [uxbox.ui.colorpicker :refer (colorpicker)] [uxbox.ui.dom :as dom] @@ -40,7 +40,7 @@ (defn- get-collection [type id] (case type - :builtin (get builtins/+color-collections-by-id+ id) + :builtin (get library/+color-collections-by-id+ id) :own (get-in @st/state [:colors-by-id id]))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -110,7 +110,7 @@ builtin? (= (:collection-type dashboard) :builtin) collections (if own? (sort-by :id (vals colors)) - builtins/+color-collections+)] + library/+color-collections+)] (html [:div.library-bar [:div.library-bar-inside @@ -152,7 +152,7 @@ coll-id (:collection-id dashboard) own? (= coll-type :own) coll (case coll-type - :builtin (get builtins/+color-collections-by-id+ coll-id) + :builtin (get library/+color-collections-by-id+ coll-id) :own (rum/react collection-state)) edit-cb #(lightbox/open! :color-form {:coll coll :color %}) remove-cb #(rs/emit! (dd/remove-color {:id (:id coll) :color %}))]