0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 08:50:57 -05:00

🐛 Fixes add fill to text shapes

This commit is contained in:
alonso.torres 2020-09-11 12:44:07 +02:00
parent 5abc6e3252
commit 1bb056cbdb

View file

@ -42,8 +42,9 @@
[{:keys [ids type values editor] :as props}]
(let [locale (mf/deref i18n/locale)
shapes (deref (refs/objects-by-id ids))
text-ids (map :id (filter #(= (:type %) :text) shapes))
other-ids (map :id (filter #(not= (:type %) :text) shapes))
is-text? #(= (:type %) :text)
text-ids (map :id (filter is-text? shapes))
other-ids (map :id (filter (comp not is-text?) shapes))
show? (not (nil? (:fill-color values)))
label (case type
@ -60,14 +61,29 @@
(mf/use-callback
(mf/deps ids)
(fn [event]
(st/emit! (dwc/update-shapes ids #(assoc % :fill-color cp/default-color)))))
(when-not (empty? other-ids)
(st/emit! (dwc/update-shapes other-ids #(assoc % :fill-color cp/default-color))))
(when-not (empty? text-ids)
(run! #(st/emit! (dwt/update-text-attrs
{:id %
:editor editor
:attrs {:fill cp/default-color}}))
text-ids))))
on-delete
(mf/use-callback
(mf/deps ids)
(fn [event]
(st/emit! (dwc/update-shapes ids #(dissoc % :fill-color)))))
(when-not (empty? other-ids)
(st/emit! (dwc/update-shapes other-ids #(dissoc % :fill-color))))
(when-not (empty? text-ids)
(run! #(st/emit! (dwt/update-text-attrs
{:id %
:editor editor
:attrs {:fill nil}}))
text-ids))))
on-change
(mf/use-callback