Merge pull request #6706 from penpot/niwinz-staging-opacity-fix

🐛 Fix incorrect handling of opacity change on gradient stop
This commit is contained in:
Alejandro Alonso 2025-06-18 07:32:34 +02:00 committed by GitHub
commit 9930f54558
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 3 deletions

View file

@ -22,7 +22,7 @@
;; SCHEMAS & TYPES ;; SCHEMAS & TYPES
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def valid-color-attrs (def ^:private required-color-attrs
"A set used for proper check if color should contain only one of the "A set used for proper check if color should contain only one of the
attrs listed in this set." attrs listed in this set."
#{:image :gradient :color}) #{:image :gradient :color})
@ -31,7 +31,7 @@
"Check if color has correct color attrs" "Check if color has correct color attrs"
[color] [color]
(let [attrs (set (keys color)) (let [attrs (set (keys color))
result (set/intersection attrs valid-color-attrs)] result (set/intersection attrs required-color-attrs)]
(= 1 (count result)))) (= 1 (count result))))
(def ^:private hex-color-rx (def ^:private hex-color-rx
@ -126,6 +126,9 @@
(sm/optional-keys schema:image-color)] (sm/optional-keys schema:image-color)]
[:fn has-valid-color-attrs?]]) [:fn has-valid-color-attrs?]])
(def color-attrs
(into required-color-attrs (sm/keys schema:color-attrs)))
(def schema:library-color-attrs (def schema:library-color-attrs
[:map {:title "ColorAttrs" :closed true} [:map {:title "ColorAttrs" :closed true}
[:id ::sm/uuid] [:id ::sm/uuid]

View file

@ -10,6 +10,7 @@
[app.common.colors :as cc] [app.common.colors :as cc]
[app.common.data :as d] [app.common.data :as d]
[app.common.data.macros :as dm] [app.common.data.macros :as dm]
[app.common.types.color :as types.color]
[app.common.types.shape.attrs :refer [default-color]] [app.common.types.shape.attrs :refer [default-color]]
[app.main.data.modal :as modal] [app.main.data.modal :as modal]
[app.main.data.workspace.colors :as dwc] [app.main.data.workspace.colors :as dwc]
@ -125,7 +126,8 @@
(fn [value] (fn [value]
(let [color (-> color (let [color (-> color
(assoc :opacity (/ value 100)) (assoc :opacity (/ value 100))
(dissoc :ref-id :ref-file))] (dissoc :ref-id :ref-file)
(select-keys types.color/color-attrs))]
(st/emit! (dwc/add-recent-color color) (st/emit! (dwc/add-recent-color color)
(on-change color))))) (on-change color)))))