mirror of
https://github.com/penpot/penpot.git
synced 2025-03-15 01:01:30 -05:00
🐛 Fix library color selector
This commit is contained in:
parent
f3115f8f3a
commit
6e33d5b311
4 changed files with 23 additions and 25 deletions
|
@ -300,13 +300,13 @@
|
|||
[key default]
|
||||
(let [id (use-id)
|
||||
state (mf/use-state (get @storage key default))
|
||||
stream (mf/with-memo []
|
||||
stream (mf/with-memo [id]
|
||||
(->> mbc/stream
|
||||
(rx/filter #(= (:type %) key))
|
||||
(rx/filter #(not= (:id %) id))
|
||||
(rx/filter #(= (:type %) key))
|
||||
(rx/map deref)))]
|
||||
|
||||
(mf/with-effect [@state key]
|
||||
(mf/with-effect [@state key id]
|
||||
(mbc/emit! id key @state)
|
||||
(swap! storage assoc key @state))
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
(mf/defc palette
|
||||
[{:keys [current-colors recent-colors file-colors shared-libs selected on-select]}]
|
||||
(let [;; We had to do this due to a bug that leave some bugged colors
|
||||
current-colors (filter #(or (:gradient %) (:color %)) current-colors)
|
||||
current-colors (h/use-equal-memo (filter #(or (:gradient %) (:color %)) current-colors))
|
||||
state (mf/use-state {:show-menu false})
|
||||
|
||||
width (:width @state 0)
|
||||
|
@ -185,13 +185,11 @@
|
|||
on-select (mf/use-fn #(reset! selected %))]
|
||||
|
||||
(mf/with-effect [@selected]
|
||||
(fn []
|
||||
(reset! colors
|
||||
(into []
|
||||
(cond
|
||||
(let [colors' (cond
|
||||
(= @selected :recent) (reverse recent-colors)
|
||||
(= @selected :file) (->> (vals file-colors) (sort-by :name))
|
||||
:else (->> (library->colors shared-libs @selected) (sort-by :name)))))))
|
||||
:else (->> (library->colors shared-libs @selected) (sort-by :name)))]
|
||||
(reset! colors (into [] colors'))))
|
||||
|
||||
(mf/with-effect [recent-colors @selected]
|
||||
(when (= @selected :recent)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
(ns app.main.ui.workspace.colorpicker.libraries
|
||||
(:require
|
||||
[app.common.data.macros :as dm]
|
||||
[app.main.data.workspace.colors :as dc]
|
||||
[app.main.data.workspace.colors :as mdc]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.components.color-bullet :refer [color-bullet]]
|
||||
|
@ -19,13 +19,13 @@
|
|||
|
||||
(mf/defc libraries
|
||||
[{:keys [on-select-color on-add-library-color disable-gradient disable-opacity]}]
|
||||
(let [selected (h/use-shared-state dc/colorpicker-selected-broadcast-key :recent)
|
||||
(let [selected (h/use-shared-state mdc/colorpicker-selected-broadcast-key :recent)
|
||||
current-colors (mf/use-state [])
|
||||
|
||||
shared-libs (mf/deref refs/workspace-libraries)
|
||||
file-colors (mf/deref refs/workspace-file-colors)
|
||||
recent-colors (mf/deref refs/workspace-recent-colors)
|
||||
recent-colors (filter #(or (:gradient %) (:color %)) recent-colors)
|
||||
recent-colors (h/use-equal-memo (filter #(or (:gradient %) (:color %)) recent-colors))
|
||||
|
||||
on-library-change
|
||||
(mf/use-fn
|
||||
|
@ -81,7 +81,7 @@
|
|||
i/plus])
|
||||
|
||||
[:div.color-bullet.button {:style {:background-color "var(--color-white)"}
|
||||
:on-click #(st/emit! (dc/show-palette @selected))}
|
||||
:on-click #(st/emit! (mdc/show-palette @selected))}
|
||||
i/palette]
|
||||
|
||||
(for [[idx color] (map-indexed vector @current-colors)]
|
||||
|
|
Loading…
Add table
Reference in a new issue