0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-04 11:01:20 -05:00

Improve sorting of nav items on icons page.

This commit is contained in:
Andrey Antukh 2016-10-19 18:37:58 +02:00
parent c8846f7cbf
commit 204a3fe68a
2 changed files with 11 additions and 13 deletions

View file

@ -25,7 +25,6 @@
rs/UpdateEvent
(-apply-update [_ state]
(let [type (or type :own)
id (or id (if (= type :builtin) 1 nil))
data {:type type :id id :selected #{}}]
(-> state
(assoc-in [:dashboard :icons] data)

View file

@ -147,10 +147,10 @@
[type selected colls]
(let [own? (= type :own)
builtin? (= type :builtin)
collections (cond->> (vals colls)
own? (filter #(= :own (:type %)))
builtin? (filter #(= :builtin (:type %)))
own? (sort-by :name))]
colls (cond->> (vals colls)
own? (filter #(= :own (:type %)))
builtin? (filter #(= :builtin (:type %))))
colls (sort-by :name colls)]
[:ul.library-elements
(when own?
[:li
@ -159,7 +159,7 @@
"+ New collection"]])
(when own?
(nav-item nil (nil? selected)))
(for [coll collections
(for [coll colls
:let [selected? (= (:id coll) selected)
key (str (:id coll))]]
(-> (nav-item coll selected?)
@ -171,13 +171,12 @@
(let [own? (= type :own)
builtin? (= type :builtin)]
(letfn [(select-tab [type]
(let [xf (comp (map second)
(filter #(= type (:type %))))
colls (->> (into [] xf colls)
(sort-by :name))]
(if-let [item (first colls)]
(rs/emit! (di/select-collection type (:id item)))
(rs/emit! (di/select-collection type)))))]
(if (= type :builtin)
(let [colls (->> (map second colls)
(filter #(= :builtin (:type %)))
(sort-by :name))]
(rs/emit! (di/select-collection type (:id (first colls)))))
(rs/emit! (di/select-collection type))))]
[:div.library-bar
[:div.library-bar-inside
[:ul.library-tabs