mirror of
https://github.com/penpot/penpot.git
synced 2025-05-23 05:16:13 +02:00
💄 Add cosmetic changes to shadow-add and reorder-shadow fns
This commit is contained in:
parent
1eb6e30369
commit
98a6c63ad6
1 changed files with 19 additions and 13 deletions
|
@ -10,6 +10,7 @@
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
[app.common.pages.helpers :as cph]
|
[app.common.pages.helpers :as cph]
|
||||||
|
[app.common.schema :as sm]
|
||||||
[app.main.broadcast :as mbc]
|
[app.main.broadcast :as mbc]
|
||||||
[app.main.data.modal :as md]
|
[app.main.data.modal :as md]
|
||||||
[app.main.data.workspace.changes :as dch]
|
[app.main.data.workspace.changes :as dch]
|
||||||
|
@ -248,22 +249,27 @@
|
||||||
(ptk/reify ::change-shadow
|
(ptk/reify ::change-shadow
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ _ _]
|
(watch [_ _ _]
|
||||||
(rx/of (dch/update-shapes ids (fn [shape]
|
(rx/of (dch/update-shapes
|
||||||
(let [;; If we try to set a gradient to a shadow (for example using the color selection from multiple shapes) let's use the first stop color
|
ids
|
||||||
attrs (cond-> attrs
|
(fn [shape]
|
||||||
(:gradient attrs) (get-in [:gradient :stops 0]))
|
(let [;; If we try to set a gradient to a shadow (for
|
||||||
new-attrs (merge (get-in shape [:shadow index :color]) attrs)]
|
;; example using the color selection from
|
||||||
(assoc-in shape [:shadow index :color] new-attrs))))))))
|
;; multiple shapes) let's use the first stop
|
||||||
|
;; color
|
||||||
|
attrs (cond-> attrs
|
||||||
|
(:gradient attrs) (get-in [:gradient :stops 0]))
|
||||||
|
new-attrs (merge (get-in shape [:shadow index :color]) attrs)]
|
||||||
|
(assoc-in shape [:shadow index :color] new-attrs))))))))
|
||||||
|
|
||||||
(defn add-shadow
|
(defn add-shadow
|
||||||
[ids shadow]
|
[ids shadow]
|
||||||
|
(dm/assert! (sm/coll-of-uuid? ids))
|
||||||
(ptk/reify ::add-shadow
|
(ptk/reify ::add-shadow
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ _ _]
|
(watch [_ _ _]
|
||||||
(let [add (fn [shape attrs] (assoc shape :shadow (into [attrs] (:shadow shape))))]
|
(let [add-shadow (fn [shape]
|
||||||
(rx/of (dch/update-shapes
|
(update shape :shadow #(into [shadow] %)))]
|
||||||
ids
|
(rx/of (dch/update-shapes ids add-shadow))))))
|
||||||
#(add % shadow)))))))
|
|
||||||
|
|
||||||
(defn add-stroke
|
(defn add-stroke
|
||||||
[ids stroke]
|
[ids stroke]
|
||||||
|
@ -304,9 +310,9 @@
|
||||||
(ptk/reify ::reorder-shadow
|
(ptk/reify ::reorder-shadow
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ _ _]
|
(watch [_ _ _]
|
||||||
(rx/of (dch/update-shapes
|
(rx/of (dch/update-shapes
|
||||||
ids
|
ids
|
||||||
#(swap-attrs % :shadow index new-index))))))
|
#(swap-attrs % :shadow index new-index))))))
|
||||||
|
|
||||||
(defn reorder-strokes
|
(defn reorder-strokes
|
||||||
[ids index new-index]
|
[ids index new-index]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue