Merge pull request #4540 from penpot/azazeln28-fix-color-palette-sorting-by-hue-and-value

🐛  Color palette sorting
This commit is contained in:
Alejandro 2024-05-10 10:26:42 +02:00 committed by GitHub
commit c616e3c932
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 7 deletions

View file

@ -54,13 +54,7 @@
get-sorted-colors
(mf/use-fn
(fn [colors]
(sort (fn [a b]
(let [[ah _ al] (c/hex->hsl (:color a))
[bh _ bl] (c/hex->hsl (:color b))
a (+ (* ah 100) (* al 99))
b (+ (* bh 100) (* bl 99))]
(compare a b)))
(into [] (filter check-valid-color?) colors))))
(sort c/sort-colors (into [] (filter check-valid-color?) colors))))
toggle-palette
(mf/use-fn