0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-25 07:58:49 -05:00

Merge pull request #2038 from penpot/eva-bugfix-3

🐛 Fix color change in a row
This commit is contained in:
Alejandro 2022-06-24 13:12:45 +02:00 committed by GitHub
commit 248ab953b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View file

@ -125,12 +125,11 @@
on-change
(mf/use-fn
(fn [new-color old-color]
(let [old-color (-> (or old-color @prev-color*)
(let [old-color (-> old-color
(dissoc :name)
(dissoc :path)
(d/without-nils))
shapes-by-color (get @grouped-colors* old-color)]
(reset! prev-color* new-color)
(st/emit! (dc/change-color-in-selected new-color shapes-by-color old-color)))))
on-open (mf/use-fn

View file

@ -69,6 +69,8 @@
shared-libs (mf/deref refs/workspace-libraries)
hover-detach (mf/use-state false)
on-change-var (h/use-update-var {:fn on-change})
src-colors (if (= (:file-id color) current-file-id)
file-colors
(get-in shared-libs [(:file-id color) :data :colors]))
@ -83,18 +85,18 @@
(when on-detach (on-detach color)))
change-value (fn [new-value]
(when on-change (on-change (-> color
(assoc :color new-value)
(dissoc :gradient)))))
(when (:fn @on-change-var) ((:fn @on-change-var) (-> color
(assoc :color new-value)
(dissoc :gradient)))))
change-opacity (fn [new-opacity]
(when on-change (on-change (assoc color
(when (:fn @on-change-var) ((:fn @on-change-var) (assoc color
:opacity new-opacity
:id nil
:file-id nil))))
handle-pick-color (fn [color]
(when on-change (on-change (merge uc/empty-color color))))
(when (:fn @on-change-var) ((:fn @on-change-var) (merge uc/empty-color color))))
handle-select (fn []
(select-only color))