mirror of
https://github.com/penpot/penpot.git
synced 2025-05-20 22:16:10 +02:00
Preselect first icons collection with content on the workspace
This commit is contained in:
parent
c6d60b5fbf
commit
19a98e6586
1 changed files with 13 additions and 4 deletions
|
@ -52,6 +52,16 @@
|
||||||
(remove-watch local ::key)
|
(remove-watch local ::key)
|
||||||
own))
|
own))
|
||||||
|
|
||||||
|
(defn- get-or-select-coll
|
||||||
|
[local colls-map]
|
||||||
|
(if (:id @local)
|
||||||
|
(get colls-map (:id @local))
|
||||||
|
(let [colls (->> (vals colls-map)
|
||||||
|
(sort-by :name))
|
||||||
|
selected-coll (first (filter #(> (:num-icons %) 0) colls))]
|
||||||
|
(swap! local assoc :id (:id selected-coll)
|
||||||
|
selected-coll))))
|
||||||
|
|
||||||
(mx/defcs icons-toolbox
|
(mx/defcs icons-toolbox
|
||||||
{:mixins [(mx/local) mx/reactive]
|
{:mixins [(mx/local) mx/reactive]
|
||||||
:will-mount icons-toolbox-will-mount
|
:will-mount icons-toolbox-will-mount
|
||||||
|
@ -62,11 +72,10 @@
|
||||||
colls-map (mx/react icons/collections-ref)
|
colls-map (mx/react icons/collections-ref)
|
||||||
colls (->> (vals colls-map)
|
colls (->> (vals colls-map)
|
||||||
(sort-by :name))
|
(sort-by :name))
|
||||||
coll (get colls-map (:id @local))
|
selected-coll (get-or-select-coll local colls-map)
|
||||||
|
|
||||||
icons (mx/react icons/icons-ref)
|
icons (mx/react icons/icons-ref)
|
||||||
icons (->> (vals icons)
|
icons (->> (vals icons)
|
||||||
(filter #(= (:id coll) (:collection %))))]
|
(filter #(= (:id selected-coll) (:collection %))))]
|
||||||
|
|
||||||
(letfn [(on-close [event]
|
(letfn [(on-close [event]
|
||||||
(st/emit! (dw/toggle-flag :icons)))
|
(st/emit! (dw/toggle-flag :icons)))
|
||||||
|
@ -86,7 +95,7 @@
|
||||||
[:div.figures-catalog
|
[:div.figures-catalog
|
||||||
;; extract component: set selector
|
;; extract component: set selector
|
||||||
[:select.input-select.small {:on-change on-change
|
[:select.input-select.small {:on-change on-change
|
||||||
:value (pr-str (:id coll))}
|
:value (pr-str (:id selected-coll))}
|
||||||
[:option {:value (pr-str nil)} "Storage"]
|
[:option {:value (pr-str nil)} "Storage"]
|
||||||
(for [coll colls]
|
(for [coll colls]
|
||||||
[:option {:key (str "icon-coll" (:id coll))
|
[:option {:key (str "icon-coll" (:id coll))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue