mirror of
https://github.com/penpot/penpot.git
synced 2025-02-11 01:28:30 -05:00
🐛 problem with palettes
This commit is contained in:
parent
55c85c0d5c
commit
07fb644e07
1 changed files with 62 additions and 60 deletions
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
(defn selected-items-ref
|
(defn selected-items-ref
|
||||||
[library-id]
|
[library-id]
|
||||||
(->> #(get-in % [:library-items :palettes library-id])
|
(-> #(get-in % [:library-items :palettes library-id])
|
||||||
(l/derived st/state)))
|
(l/derived st/state)))
|
||||||
|
|
||||||
(def selected-library-ref
|
(def selected-library-ref
|
||||||
|
@ -56,14 +56,15 @@
|
||||||
(mf/defc palette
|
(mf/defc palette
|
||||||
[{:keys [libraries left-sidebar?] :as props}]
|
[{:keys [libraries left-sidebar?] :as props}]
|
||||||
|
|
||||||
(when (and libraries (-> libraries count (> 0)))
|
|
||||||
(let [current-selection (or (mf/deref selected-library-ref) (-> libraries first :id))
|
(let [current-selection (or (mf/deref selected-library-ref) (-> libraries first :id))
|
||||||
state (mf/use-state {:show-menu false })]
|
state (mf/use-state {:show-menu false })]
|
||||||
|
|
||||||
(mf/use-effect
|
(mf/use-effect
|
||||||
(mf/deps current-selection)
|
(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)
|
doc-width (.. js/document -documentElement -clientWidth)
|
||||||
width (:width @state (* doc-width 0.84))
|
width (:width @state (* doc-width 0.84))
|
||||||
offset (:offset @state 0)
|
offset (:offset @state 0)
|
||||||
|
@ -124,7 +125,8 @@
|
||||||
(for [item items]
|
(for [item items]
|
||||||
[:& palette-item {:color (:content item) :key (:id item)}])]]
|
[:& 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
|
(mf/defc colorpalette
|
||||||
[{:keys [left-sidebar?]}]
|
[{:keys [left-sidebar?]}]
|
||||||
|
|
Loading…
Add table
Reference in a new issue