0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-27 00:49:28 -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 on-change
(mf/use-fn (mf/use-fn
(fn [new-color old-color] (fn [new-color old-color]
(let [old-color (-> (or old-color @prev-color*) (let [old-color (-> old-color
(dissoc :name) (dissoc :name)
(dissoc :path) (dissoc :path)
(d/without-nils)) (d/without-nils))
shapes-by-color (get @grouped-colors* old-color)] 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))))) (st/emit! (dc/change-color-in-selected new-color shapes-by-color old-color)))))
on-open (mf/use-fn on-open (mf/use-fn

View file

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