0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 17:00:36 -05:00

Merge pull request #3268 from penpot/superalex-file-libraries-colors-order

 Improve file libraries colors order
This commit is contained in:
Aitor Moreno 2023-06-06 10:43:52 +02:00 committed by GitHub
commit 4947169a7c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View file

@ -118,7 +118,7 @@
:on-close #(swap! state assoc :show-menu false)}
[:ul.workspace-context-menu.palette-menu
(for [{:keys [data id] :as library} (vals shared-libs)]
(let [colors (-> data :colors vals)]
(let [colors (->> data :colors vals (sort-by :name))]
[:li.palette-library
{:key (dm/str "library-" id)
:on-click on-select-palette
@ -126,7 +126,7 @@
(when (= selected id) i/tick)
[:div.library-name (str (:name library) " " (str/ffmt "(%)" (count colors)))]
[:div.color-sample
(for [[i {:keys [color]}] (map-indexed vector (take 7 colors))]
(for [[i {:keys [color]}] (map-indexed vector colors)]
[:& cb/color-bullet {:key (dm/str "color-" i)
:color color}])]]))
@ -139,7 +139,7 @@
(tr "workspace.libraries.colors.file-library")
(str/ffmt " (%)" (count file-colors)))]
[:div.color-sample
(for [[i color] (map-indexed vector (take 7 (vals file-colors)))]
(for [[i color] (map-indexed vector (take 7 (->> (vals file-colors) (sort-by :name))))]
[:& cb/color-bullet {:key (dm/str "color-" i)
:color color}])]]

View file

@ -54,12 +54,13 @@
(map #(if (map? %) % {:color %}) (reverse (or recent-colors [])))
(= @selected :file)
(vals file-colors)
(->> (vals file-colors) (sort-by :name))
:else ;; Library UUID
(as-> @selected file-id
(->> (get-in shared-libs [file-id :data :colors])
(vals)
(sort-by :name)
(map #(assoc % :file-id file-id)))))]
(reset! current-colors (into [] (filter check-valid-color?) colors))))