Revert "🐛 Fixes problems with multiple values in fill and stroke"

This reverts commit 8fd8bc4537.
This commit is contained in:
Andrey Antukh 2021-02-03 17:27:08 +01:00
parent b056cc35e4
commit b7e266e350
5 changed files with 24 additions and 57 deletions

View file

@ -116,21 +116,11 @@
text-ids (filter is-text? ids) text-ids (filter is-text? ids)
shape-ids (filter (comp not is-text?) ids) shape-ids (filter (comp not is-text?) ids)
attrs (cond-> {} attrs {:fill-color (:color color)
(contains? color :color) :fill-color-ref-id (:id color)
(assoc :fill-color (:color color)) :fill-color-ref-file (:file-id color)
:fill-color-gradient (:gradient color)
(contains? color :id) :fill-opacity (:opacity color)}
(assoc :fill-color-ref-id (:id color))
(contains? color :file-id)
(assoc :fill-color-ref-file (:file-id color))
(contains? color :gradient)
(assoc :fill-color-gradient (:gradient color))
(contains? color :opacity)
(assoc :fill-opacity (:opacity color)))
update-fn (fn [shape] (merge shape attrs)) update-fn (fn [shape] (merge shape attrs))
editors (get-in state [:workspace-local :editors]) editors (get-in state [:workspace-local :editors])
@ -148,30 +138,19 @@
(let [pid (:current-page-id state) (let [pid (:current-page-id state)
objects (get-in state [:workspace-data :pages-index pid :objects]) objects (get-in state [:workspace-data :pages-index pid :objects])
not-frame (fn [shape-id] (not= (get-in objects [shape-id :type]) :frame)) not-frame (fn [shape-id] (not= (get-in objects [shape-id :type]) :frame))
update-fn (fn [s]
(cond-> s
true
(assoc :stroke-color (:color color)
:stroke-opacity (:opacity color)
:stroke-color-gradient (:gradient color)
:stroke-color-ref-id (:id color)
:stroke-color-ref-file (:file-id color))
color-attrs (cond-> {} (= (:stroke-style s) :none)
(contains? color :color) (assoc :stroke-style :solid
(assoc :stroke-color (:color color)) :stroke-width 1
:stroke-opacity 1)))]
(contains? color :id)
(assoc :stroke-color-ref-id (:id color))
(contains? color :file-id)
(assoc :stroke-color-ref-file (:file-id color))
(contains? color :gradient)
(assoc :stroke-color-gradient (:gradient color))
(contains? color :opacity)
(assoc :stroke-opacity (:opacity color)))
update-fn (fn [shape]
(-> shape
(merge color-attrs)
(cond-> (= (:stroke-style s) :none)
(assoc :stroke-style :solid
:stroke-width 1
:stroke-opacity 1))))]
(rx/of (dwc/update-shapes ids update-fn)))))) (rx/of (dwc/update-shapes ids update-fn))))))
(defn picker-for-selected-shape [] (defn picker-for-selected-shape []

View file

@ -63,18 +63,13 @@
(mf/use-callback (mf/use-callback
(mf/deps ids) (mf/deps ids)
(fn [color] (fn [color]
(let [remove-multiple (fn [[key value]] (not= value :multiple)) (st/emit! (dc/change-fill ids color))))
color (into {} (filter remove-multiple) color)]
(st/emit! (dc/change-fill ids color)))))
on-detach on-detach
(mf/use-callback (mf/use-callback
(mf/deps ids) (mf/deps ids)
(fn [] (fn []
(let [remove-multiple (fn [[key value]] (not= value :multiple)) (st/emit! (dc/change-fill ids (dissoc color :id :file-id)))))
color (-> (into {} (filter remove-multiple) color)
(assoc :id nil :file-id nil))]
(st/emit! (dc/change-fill ids color)))))
on-open-picker on-open-picker
(mf/use-callback (mf/use-callback

View file

@ -82,13 +82,10 @@
(dissoc :gradient))))) (dissoc :gradient)))))
change-opacity (fn [new-opacity] change-opacity (fn [new-opacity]
(when on-change (on-change (assoc color (when on-change (on-change (assoc color :opacity new-opacity))))
:opacity new-opacity
:id nil
:file-id nil))))
handle-pick-color (fn [color] handle-pick-color (fn [color]
(when on-change (on-change (merge {:id nil :file-id nil} color)))) (when on-change (on-change color)))
handle-open (fn [] (when on-open (on-open))) handle-open (fn [] (when on-open (on-open)))
@ -136,7 +133,7 @@
(cond (cond
;; Rendering a color with ID ;; Rendering a color with ID
(and (:id color) (not (uc/multiple? color))) (:id color)
[:* [:*
[:div.color-info [:div.color-info
[:div.color-name (str (get-color-name color))]] [:div.color-name (str (get-color-name color))]]

View file

@ -66,9 +66,7 @@
(mf/use-callback (mf/use-callback
(mf/deps ids) (mf/deps ids)
(fn [color] (fn [color]
(let [remove-multiple (fn [[key value]] (not= value :multiple)) (st/emit! (dc/change-stroke ids color))))
color (into {} (filter remove-multiple) color)]
(st/emit! (dc/change-stroke ids color)))))
handle-detach handle-detach
(mf/use-callback (mf/use-callback

View file

@ -109,12 +109,10 @@
:else "transparent"))) :else "transparent")))
(defn multiple? [{:keys [id file-id value color gradient]}] (defn multiple? [{:keys [value color gradient]}]
(or (= value :multiple) (or (= value :multiple)
(= color :multiple) (= color :multiple)
(= gradient :multiple) (= gradient :multiple)
(= id :multiple)
(= file-id :multiple)
(and gradient color))) (and gradient color)))
(defn parse-color [^string color-str] (defn parse-color [^string color-str]