mirror of
https://github.com/penpot/penpot.git
synced 2025-01-09 16:30:37 -05:00
Sort colors in the colors dashboard page by color.
This commit is contained in:
parent
df2ac51698
commit
cc53ba68b5
1 changed files with 21 additions and 18 deletions
|
@ -155,14 +155,17 @@
|
||||||
(mx/defc grid
|
(mx/defc grid
|
||||||
{:mixins [mx/static]}
|
{:mixins [mx/static]}
|
||||||
[selected coll]
|
[selected coll]
|
||||||
(let [own? (= (:type coll) :own)]
|
(let [own? (= (:type coll) :own)
|
||||||
|
colors (->> (:data coll)
|
||||||
|
(remove nil?)
|
||||||
|
(sort-by identity))]
|
||||||
[:div.dashboard-grid-content
|
[:div.dashboard-grid-content
|
||||||
[:div.dashboard-grid-row
|
[:div.dashboard-grid-row
|
||||||
(when own?
|
(when own?
|
||||||
[:div.grid-item.small-item.add-project
|
[:div.grid-item.small-item.add-project
|
||||||
{:on-click #(udl/open! :color-form {:coll coll})}
|
{:on-click #(udl/open! :color-form {:coll coll})}
|
||||||
[:span "+ New color"]])
|
[:span "+ New color"]])
|
||||||
(for [color (remove nil? (:data coll))
|
(for [color colors
|
||||||
:let [selected? (contains? selected color)]]
|
:let [selected? (contains? selected color)]]
|
||||||
(-> (grid-item color selected?)
|
(-> (grid-item color selected?)
|
||||||
(mx/with-key (str color))))]]))
|
(mx/with-key (str color))))]]))
|
||||||
|
@ -185,53 +188,53 @@
|
||||||
|
|
||||||
;; --- Nav
|
;; --- Nav
|
||||||
|
|
||||||
(mx/defc nav-collection
|
(mx/defc nav-item
|
||||||
{:mixins [mx/static]}
|
{:mixins [mx/static]}
|
||||||
[collection selected?]
|
[coll selected?]
|
||||||
(letfn [(on-click [event]
|
(letfn [(on-click [event]
|
||||||
(let [type (:type collection)
|
(let [type (:type coll)
|
||||||
id (:id collection)]
|
id (:id coll)]
|
||||||
(rs/emit! (dc/select-collection type id))))]
|
(rs/emit! (dc/select-collection type id))))]
|
||||||
(let [colors (count (:data collection))]
|
(let [colors (count (:data coll))]
|
||||||
[:li {:on-click on-click
|
[:li {:on-click on-click
|
||||||
:class-name (when selected? "current")}
|
:class-name (when selected? "current")}
|
||||||
[:span.element-title (:name collection)]
|
[:span.element-title (:name coll)]
|
||||||
[:span.element-subtitle
|
[:span.element-subtitle
|
||||||
(tr "ds.num-elements" (t/c colors))]])))
|
(tr "ds.num-elements" (t/c colors))]])))
|
||||||
|
|
||||||
(mx/defc nav-collections
|
(mx/defc nav-section
|
||||||
{:mixins [mx/static mx/reactive]}
|
{:mixins [mx/static mx/reactive]}
|
||||||
[type selected]
|
[type selected]
|
||||||
(let [own? (= type :own)
|
(let [own? (= type :own)
|
||||||
builtin? (= type :builtin)
|
builtin? (= type :builtin)
|
||||||
collections (cond->> (mx/react collections-ref)
|
colls (cond->> (mx/react collections-ref)
|
||||||
own? (filter #(= :own (:type %)))
|
own? (filter #(= :own (:type %)))
|
||||||
builtin? (filter #(= :builtin (:type %)))
|
builtin? (filter #(= :builtin (:type %)))
|
||||||
own? (sort-by :id))]
|
own? (sort-by :id))]
|
||||||
[:ul.library-elements
|
[:ul.library-elements
|
||||||
(when own?
|
(when own?
|
||||||
[:li
|
[:li
|
||||||
[:a.btn-primary
|
[:a.btn-primary
|
||||||
{:on-click #(rs/emit! (dc/create-collection))}
|
{:on-click #(rs/emit! (dc/create-collection))}
|
||||||
"+ New library"]])
|
"+ New library"]])
|
||||||
(for [coll collections
|
(for [coll colls
|
||||||
:let [selected? (= (:id coll) selected)
|
:let [selected? (= (:id coll) selected)
|
||||||
key (str (:id coll))]]
|
key (str (:id coll))]]
|
||||||
(-> (nav-collection coll selected?)
|
(-> (nav-item coll selected?)
|
||||||
(mx/with-key key)))]))
|
(mx/with-key key)))]))
|
||||||
|
|
||||||
(mx/defc nav
|
(mx/defc nav
|
||||||
{:mixins [mx/static mx/reactive]}
|
{:mixins [mx/static mx/reactive]}
|
||||||
[]
|
[]
|
||||||
(let [dashboard (mx/react dashboard-ref)
|
(let [dashboard (mx/react dashboard-ref)
|
||||||
collections (mx/react collections-ref)
|
colls (mx/react collections-ref)
|
||||||
selected (:id dashboard)
|
selected (:id dashboard)
|
||||||
type (:type dashboard)
|
type (:type dashboard)
|
||||||
own? (= type :own)
|
own? (= type :own)
|
||||||
builtin? (= type :builtin)]
|
builtin? (= type :builtin)]
|
||||||
(letfn [(select-tab [type]
|
(letfn [(select-tab [type]
|
||||||
(let [xf (filter #(= type (:type %)))
|
(let [xf (filter #(= type (:type %)))
|
||||||
colls (sequence xf collections)]
|
colls (sequence xf colls)]
|
||||||
(if-let [item (first colls)]
|
(if-let [item (first colls)]
|
||||||
(rs/emit! (dc/select-collection type (:id item)))
|
(rs/emit! (dc/select-collection type (:id item)))
|
||||||
(rs/emit! (dc/select-collection type)))))]
|
(rs/emit! (dc/select-collection type)))))]
|
||||||
|
@ -244,7 +247,7 @@
|
||||||
[:li {:class-name (when builtin? "current")
|
[:li {:class-name (when builtin? "current")
|
||||||
:on-click (partial select-tab :builtin)}
|
:on-click (partial select-tab :builtin)}
|
||||||
"COLORS STORE"]]
|
"COLORS STORE"]]
|
||||||
(nav-collections type selected)]])))
|
(nav-section type selected)]])))
|
||||||
|
|
||||||
;; --- Colors Page
|
;; --- Colors Page
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue