🐛 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
:linear (tr "workspace.gradients.linear")
:radial (tr "workspace.gradients.radial")
(str "???" type)))
nil))
(mf/defc color-bullet [{:keys [color on-click]}]
(if (uc/multiple? color)

View file

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