🐛 Fix incorrect handling of opacity change on gradient stop

This commit is contained in:
Andrey Antukh 2025-06-17 16:13:26 +02:00
parent c5b0206bf0
commit 332bbc71c3
2 changed files with 8 additions and 3 deletions

View file

@ -22,7 +22,7 @@
;; 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
attrs listed in this set."
#{:image :gradient :color})
@ -31,7 +31,7 @@
"Check if color has correct color attrs"
[color]
(let [attrs (set (keys color))
result (set/intersection attrs valid-color-attrs)]
result (set/intersection attrs required-color-attrs)]
(= 1 (count result))))
(def ^:private hex-color-rx
@ -126,6 +126,9 @@
(sm/optional-keys schema:image-color)]
[:fn has-valid-color-attrs?]])
(def color-attrs
(into required-color-attrs (sm/keys schema:color-attrs)))
(def schema:library-color-attrs
[:map {:title "ColorAttrs" :closed true}
[:id ::sm/uuid]

View file

@ -10,6 +10,7 @@
[app.common.colors :as cc]
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.types.color :as types.color]
[app.common.types.shape.attrs :refer [default-color]]
[app.main.data.modal :as modal]
[app.main.data.workspace.colors :as dwc]
@ -125,7 +126,8 @@
(fn [value]
(let [color (-> color
(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)
(on-change color)))))