🐛 problem with palettes

This commit is contained in:
alonso.torres 2020-04-15 09:34:02 +02:00
parent 55c85c0d5c
commit 07fb644e07

View file

@ -30,7 +30,7 @@
(defn selected-items-ref
[library-id]
(->> #(get-in % [:library-items :palettes library-id])
(-> #(get-in % [:library-items :palettes library-id])
(l/derived st/state)))
(def selected-library-ref
@ -56,14 +56,15 @@
(mf/defc palette
[{:keys [libraries left-sidebar?] :as props}]
(when (and libraries (-> libraries count (> 0)))
(let [current-selection (or (mf/deref selected-library-ref) (-> libraries first :id))
state (mf/use-state {:show-menu false })]
(mf/use-effect
(mf/deps current-selection)
#(st/emit! (dlib/retrieve-library-data :palettes current-selection)))
#(when current-selection
(st/emit! (dlib/retrieve-library-data :palettes current-selection))))
(let [items (-> current-selection selected-items-ref mf/deref)
(let [items (or (mf/deref (selected-items-ref current-selection)) [])
doc-width (.. js/document -documentElement -clientWidth)
width (:width @state (* doc-width 0.84))
offset (:offset @state 0)
@ -124,7 +125,8 @@
(for [item items]
[:& palette-item {:color (:content item) :key (:id item)}])]]
[:span.right-arrow {:on-click on-right-arrow-click} i/arrow-slide]]))))
[:span.right-arrow {:on-click on-right-arrow-click} i/arrow-slide]]))
)
(mf/defc colorpalette
[{:keys [left-sidebar?]}]