🐛 Fix problems with gradient and libraries

This commit is contained in:
alonso.torres 2022-01-14 11:14:58 +01:00 committed by Alonso Torres
parent a4c45942c9
commit 363b0ba997
2 changed files with 20 additions and 13 deletions

View file

@ -14,7 +14,7 @@
(case type (case type
:linear (tr "workspace.gradients.linear") :linear (tr "workspace.gradients.linear")
:radial (tr "workspace.gradients.radial") :radial (tr "workspace.gradients.radial")
(str "???" type))) nil))
(mf/defc color-bullet [{:keys [color on-click]}] (mf/defc color-bullet [{:keys [color on-click]}]
(if (uc/multiple? color) (if (uc/multiple? color)

View file

@ -133,11 +133,17 @@
handle-change-color handle-change-color
(fn [changes] (fn [changes]
(let [editing-stop (:editing-stop @state) (let [editing-stop (:editing-stop @state)]
_ (println "handle-change-color" changes)]
(swap! state #(cond-> % (swap! state #(cond-> %
true (update :current-color merge changes) :always
editing-stop (update-in [:stops editing-stop] merge changes))) (update :current-color merge changes)
(not editing-stop)
(-> (assoc :type :color)
(dissoc :gradient-data :stops :editing-stops))
editing-stop
(update-in [:stops editing-stop] merge changes)))
(reset! dirty? true))) (reset! dirty? true)))
handle-click-picker handle-click-picker
@ -159,14 +165,15 @@
on-select-library-color on-select-library-color
(fn [color] (fn [color]
;; TODO: FIXME (let [editing-stop (:editing-stop @state)
(on-change color)) is-gradient? (some? (:gradient color))]
;; (let [editing-stop (:editing-stop @state) (if (and (some? editing-stop) (not is-gradient?))
;; is-gradient? (some? (:gradient color))] (handle-change-color (color->components (:color color) (:opacity color)))
;; (if (and (some? editing-stop) (not is-gradient?)) (do (reset! dirty? false)
;; (handle-change-color (color->components (:color color) (:opacity color))) (reset! state (-> (data->state color)
;; (do (reset! state (data->state color)) (assoc :editing-stop nil)))
;; (on-change color))))) (on-change color)))))
on-add-library-color on-add-library-color
(fn [_] (fn [_]