Render properly the builtin collections.

This commit is contained in:
Andrey Antukh 2015-12-22 20:03:06 +02:00
parent 31bcce2668
commit 3748d3c7b4
2 changed files with 46 additions and 26 deletions

View file

@ -24,6 +24,16 @@
:3fe705 :3fe705
:30ffab :30ffab
:352105 :352105
:209f20
:207820
:205e20
:290020
:350220
:3fe720
:30ff20
:352120
:352140
}}]) }}])
(def ^:static +color-collections-by-id+ (def ^:static +color-collections-by-id+

View file

@ -57,18 +57,26 @@
(defn page-title-render (defn page-title-render
[] []
(html (let [dashboard (rum/react dashboard-state)
[:div.dashboard-title own? (= (:collection-type dashboard) :own)
[:h2 "Colors library name"] coll (get-collection {}
[:div.edition (:collection-type dashboard)
[:span i/pencil] (:collection-id dashboard))]
[:span i/trash]]])) (html
[:div.dashboard-title
(if coll
[:h2 (str "Library: " (:name coll))]
[:h2 "No library selected"])
(when (and own? coll)
[:div.edition
[:span i/pencil]
[:span i/trash]])])))
(def ^:static page-title (def ^:static page-title
(util/component (util/component
{:render page-title-render {:render page-title-render
:name "page-title" :name "page-title"
:mixins [mx/static]})) :mixins [mx/static rum/reactive]}))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Nav ;; Nav
@ -95,9 +103,9 @@
:on-click #(rs/emit! (dd/set-collection-type :own))} :on-click #(rs/emit! (dd/set-collection-type :own))}
"YOUR LIBRARIES"]] "YOUR LIBRARIES"]]
[:ul.library-elements [:ul.library-elements
;; (when own? (when own?
;; [:li [:li
;; [:a.btn-primary {:href "#"} "+ New library"]]) [:a.btn-primary {:href "#"} "+ New library"]])
(for [props collections] (for [props collections]
[:li {:key (str (:id props)) [:li {:key (str (:id props))
:on-click #(rs/emit! (dd/set-collection (:id props))) :on-click #(rs/emit! (dd/set-collection (:id props)))
@ -123,23 +131,25 @@
coll (get-collection {} coll (get-collection {}
(:collection-type dashboard) (:collection-type dashboard)
(:collection-id dashboard))] (:collection-id dashboard))]
(html (when coll
[:div.dashboard-grid-content (html
(when own? [:div.dashboard-grid-content
[:div.grid-item.small-item.add-project (when own?
{:on-click #(lightbox/set! :new-color)} [:div.grid-item.small-item.add-project
[:span "+ New color"]]) {:on-click #(lightbox/set! :new-color)}
(for [color (:colors coll) [:span "+ New color"]])
:let [color-str (name color) (for [color (:colors coll)
:let [color-str (name color)
color-hex (str "#" color-str) color-hex (str "#" color-str)
color-rgb (util/hex->rgb color-hex)]] color-rgb (util/hex->rgb color-hex)]]
[:div.grid-item.small-item.project-th {:key color-str} [:div.grid-item.small-item.project-th {:key color-str}
[:span.color-swatch {:style {:background-color color-hex}}] [:span.color-swatch {:style {:background-color color-hex}}]
[:span.color-data (str "#" color-str)] [:span.color-data (str "#" color-str)]
[:span.color-data (apply str "RGB " (interpose ", " color-rgb))] [:span.color-data (apply str "RGB " (interpose ", " color-rgb))]
[:div.project-th-actions (when own?
[:div.project-th-icon.edit i/pencil] [:div.project-th-actions
[:div.project-th-icon.delete i/trash]]])]))) [:div.project-th-icon.edit i/pencil]
[:div.project-th-icon.delete i/trash]])])]))))
(def grid (def grid
(util/component (util/component