From b7e266e3509c84e64bf44dcad60128ab31ec18f4 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 3 Feb 2021 17:27:08 +0100 Subject: [PATCH] Revert ":bug: Fixes problems with multiple values in fill and stroke" This reverts commit 8fd8bc453701775719b3bd1107477eddafa675f5. --- frontend/src/app/main/data/colors.cljs | 55 ++++++------------- .../ui/workspace/sidebar/options/fill.cljs | 9 +-- .../sidebar/options/rows/color_row.cljs | 9 +-- .../ui/workspace/sidebar/options/stroke.cljs | 4 +- frontend/src/app/util/color.cljs | 4 +- 5 files changed, 24 insertions(+), 57 deletions(-) diff --git a/frontend/src/app/main/data/colors.cljs b/frontend/src/app/main/data/colors.cljs index 1d9cd64b1..493e8b573 100644 --- a/frontend/src/app/main/data/colors.cljs +++ b/frontend/src/app/main/data/colors.cljs @@ -116,21 +116,11 @@ text-ids (filter is-text? ids) shape-ids (filter (comp not is-text?) ids) - attrs (cond-> {} - (contains? color :color) - (assoc :fill-color (:color color)) - - (contains? color :id) - (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))) + attrs {:fill-color (:color color) + :fill-color-ref-id (:id color) + :fill-color-ref-file (:file-id color) + :fill-color-gradient (:gradient color) + :fill-opacity (:opacity color)} update-fn (fn [shape] (merge shape attrs)) editors (get-in state [:workspace-local :editors]) @@ -148,30 +138,19 @@ (let [pid (:current-page-id state) objects (get-in state [:workspace-data :pages-index pid :objects]) 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-> {} - (contains? color :color) - (assoc :stroke-color (:color color)) - - (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))))] + (= (:stroke-style s) :none) + (assoc :stroke-style :solid + :stroke-width 1 + :stroke-opacity 1)))] (rx/of (dwc/update-shapes ids update-fn)))))) (defn picker-for-selected-shape [] diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/fill.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/fill.cljs index 9852c68b4..4c07e1cc2 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/fill.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/fill.cljs @@ -63,18 +63,13 @@ (mf/use-callback (mf/deps ids) (fn [color] - (let [remove-multiple (fn [[key value]] (not= value :multiple)) - color (into {} (filter remove-multiple) color)] - (st/emit! (dc/change-fill ids color))))) + (st/emit! (dc/change-fill ids color)))) on-detach (mf/use-callback (mf/deps ids) (fn [] - (let [remove-multiple (fn [[key value]] (not= value :multiple)) - color (-> (into {} (filter remove-multiple) color) - (assoc :id nil :file-id nil))] - (st/emit! (dc/change-fill ids color))))) + (st/emit! (dc/change-fill ids (dissoc color :id :file-id))))) on-open-picker (mf/use-callback diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs index 2015cf8d1..473ae5377 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs @@ -82,13 +82,10 @@ (dissoc :gradient))))) change-opacity (fn [new-opacity] - (when on-change (on-change (assoc color - :opacity new-opacity - :id nil - :file-id nil)))) + (when on-change (on-change (assoc color :opacity new-opacity)))) 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))) @@ -136,7 +133,7 @@ (cond ;; Rendering a color with ID - (and (:id color) (not (uc/multiple? color))) + (:id color) [:* [:div.color-info [:div.color-name (str (get-color-name color))]] diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/stroke.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/stroke.cljs index 8b1c9124f..eb5441a8e 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/stroke.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/stroke.cljs @@ -66,9 +66,7 @@ (mf/use-callback (mf/deps ids) (fn [color] - (let [remove-multiple (fn [[key value]] (not= value :multiple)) - color (into {} (filter remove-multiple) color)] - (st/emit! (dc/change-stroke ids color))))) + (st/emit! (dc/change-stroke ids color)))) handle-detach (mf/use-callback diff --git a/frontend/src/app/util/color.cljs b/frontend/src/app/util/color.cljs index 6c3ecb4d6..c5d4237a2 100644 --- a/frontend/src/app/util/color.cljs +++ b/frontend/src/app/util/color.cljs @@ -109,12 +109,10 @@ :else "transparent"))) -(defn multiple? [{:keys [id file-id value color gradient]}] +(defn multiple? [{:keys [value color gradient]}] (or (= value :multiple) (= color :multiple) (= gradient :multiple) - (= id :multiple) - (= file-id :multiple) (and gradient color))) (defn parse-color [^string color-str]