0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 23:49:45 -05:00

:fix: Problem with opacity fill

This commit is contained in:
alonso.torres 2020-09-16 21:36:07 +02:00 committed by Andrey Antukh
parent 0f5ce3b836
commit 50ef7a8c73
2 changed files with 27 additions and 23 deletions

View file

@ -166,31 +166,35 @@
(assoc-in [:workspace-local :picked-shift?] shift?)))))
(defn change-fill [ids color id file-id]
(ptk/reify ::change-fill
ptk/WatchEvent
(watch [_ state s]
(let [pid (:current-page-id state)
objects (get-in state [:workspace-data :pages-index pid :objects])
children (mapcat #(cph/get-children % objects) ids)
ids (into ids children)
(defn change-fill
([ids color id file-id]
(change-fill ids color 1 id file-id))
([ids color opacity id file-id]
(ptk/reify ::change-fill
ptk/WatchEvent
(watch [_ state s]
(let [pid (:current-page-id state)
objects (get-in state [:workspace-data :pages-index pid :objects])
children (mapcat #(cph/get-children % objects) ids)
ids (into ids children)
is-text? #(= :text (:type (get objects %)))
text-ids (filter is-text? ids)
shape-ids (filter (comp not is-text?) ids)
update-fn (fn [shape] (assoc shape
:fill-color color
:fill-color-ref-id id
:fill-color-ref-file file-id))
editor (get-in state [:workspace-local :editor])
converted-attrs {:fill color}
is-text? #(= :text (:type (get objects %)))
text-ids (filter is-text? ids)
shape-ids (filter (comp not is-text?) ids)
update-fn (fn [shape] (assoc shape
:fill-color color
:fill-opacity opacity
:fill-color-ref-id id
:fill-color-ref-file file-id))
editor (get-in state [:workspace-local :editor])
converted-attrs {:fill color}
reduce-fn (fn [state id]
(update-in state [:workspace-data :pages-index pid :objects id] update-fn))]
reduce-fn (fn [state id]
(update-in state [:workspace-data :pages-index pid :objects id] update-fn))]
(rx/from (conj
(map #(dwt/update-text-attrs {:id % :editor editor :attrs converted-attrs}) text-ids)
(dwc/update-shapes shape-ids update-fn)))))))
(rx/from (conj
(map #(dwt/update-text-attrs {:id % :editor editor :attrs converted-attrs}) text-ids)
(dwc/update-shapes shape-ids update-fn))))))))
(defn change-stroke [ids color id file-id]
(ptk/reify ::change-stroke

View file

@ -71,7 +71,7 @@
(mf/use-callback
(mf/deps ids)
(fn [value opacity id file-id]
(st/emit! (dc/change-fill ids value id file-id))))
(st/emit! (dc/change-fill ids value opacity id file-id))))
on-open-picker
(mf/use-callback