mirror of
https://github.com/penpot/penpot.git
synced 2026-08-01 19:06:18 +00:00
Merge pull request #7972 from penpot/niwinz-staging-bugfix-7
🐛 Fix exception on assinging gradient to shadow on multiple selection
This commit is contained in:
commit
f67f1a6a0e
@ -14,7 +14,7 @@
|
|||||||
[app.common.types.fills :as types.fills]
|
[app.common.types.fills :as types.fills]
|
||||||
[app.common.types.library :as ctl]
|
[app.common.types.library :as ctl]
|
||||||
[app.common.types.shape :as shp]
|
[app.common.types.shape :as shp]
|
||||||
[app.common.types.shape.shadow :refer [check-shadow]]
|
[app.common.types.shape.shadow :as types.shadow]
|
||||||
[app.common.types.text :as txt]
|
[app.common.types.text :as txt]
|
||||||
[app.main.broadcast :as mbc]
|
[app.main.broadcast :as mbc]
|
||||||
[app.main.data.helpers :as dsh]
|
[app.main.data.helpers :as dsh]
|
||||||
@ -406,30 +406,30 @@
|
|||||||
|
|
||||||
(defn change-shadow
|
(defn change-shadow
|
||||||
[ids attrs index]
|
[ids attrs index]
|
||||||
(ptk/reify ::change-shadow
|
(letfn [(update-shadow [shape]
|
||||||
ptk/WatchEvent
|
(let [;; If we try to set a gradient to a shadow (for
|
||||||
(watch [_ _ _]
|
;; example using the color selection from
|
||||||
(rx/of (dwsh/update-shapes
|
;; multiple shapes) let's use the first stop
|
||||||
ids
|
;; color
|
||||||
(fn [shape]
|
attrs (cond-> attrs
|
||||||
(let [;; If we try to set a gradient to a shadow (for
|
(:gradient attrs)
|
||||||
;; example using the color selection from
|
(-> (dm/get-in [:gradient :stops 0])
|
||||||
;; multiple shapes) let's use the first stop
|
(select-keys types.shadow/color-attrs)))
|
||||||
;; color
|
|
||||||
attrs (cond-> attrs
|
|
||||||
(:gradient attrs)
|
|
||||||
(dm/get-in [:gradient :stops 0]))
|
|
||||||
|
|
||||||
attrs' (-> (dm/get-in shape [:shadow index :color])
|
attrs' (-> (dm/get-in shape [:shadow index :color])
|
||||||
(merge attrs)
|
(merge attrs)
|
||||||
(d/without-nils))]
|
(d/without-nils))]
|
||||||
(assoc-in shape [:shadow index :color] attrs'))))))))
|
(assoc-in shape [:shadow index :color] attrs')))]
|
||||||
|
(ptk/reify ::change-shadow
|
||||||
|
ptk/WatchEvent
|
||||||
|
(watch [_ _ _]
|
||||||
|
(rx/of (dwsh/update-shapes ids update-shadow))))))
|
||||||
|
|
||||||
(defn add-shadow
|
(defn add-shadow
|
||||||
[ids shadow]
|
[ids shadow]
|
||||||
|
|
||||||
(assert
|
(assert
|
||||||
(check-shadow shadow)
|
(types.shadow/check-shadow shadow)
|
||||||
"expected a valid shadow struct")
|
"expected a valid shadow struct")
|
||||||
|
|
||||||
(assert
|
(assert
|
||||||
@ -1146,16 +1146,16 @@
|
|||||||
(defn- shadow->color-attr
|
(defn- shadow->color-attr
|
||||||
"Given a stroke map enriched with :shape-id, :index, and optionally
|
"Given a stroke map enriched with :shape-id, :index, and optionally
|
||||||
:has-token-applied / :token-name, returns a color attribute map.
|
:has-token-applied / :token-name, returns a color attribute map.
|
||||||
|
|
||||||
If :has-token-applied is true, adds token metadata to :attrs:
|
If :has-token-applied is true, adds token metadata to :attrs:
|
||||||
{:has-token-applied true
|
{:has-token-applied true
|
||||||
:token-name <token-name>}
|
:token-name <token-name>}
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
- stroke: map with stroke info, including :shape-id and :index
|
- stroke: map with stroke info, including :shape-id and :index
|
||||||
- file-id: current file UUID
|
- file-id: current file UUID
|
||||||
- libraries: map of shared color libraries
|
- libraries: map of shared color libraries
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
A map like:
|
A map like:
|
||||||
{:attrs {...color data...}
|
{:attrs {...color data...}
|
||||||
@ -1260,12 +1260,12 @@
|
|||||||
will include extra attributes in its :attrs map:
|
will include extra attributes in its :attrs map:
|
||||||
{:has-token-applied true
|
{:has-token-applied true
|
||||||
:token-name <token-name>}
|
:token-name <token-name>}
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
- shapes: vector of shape maps
|
- shapes: vector of shape maps
|
||||||
- file-id: current file UUID
|
- file-id: current file UUID
|
||||||
- libraries: map of shared color libraries
|
- libraries: map of shared color libraries
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
A vector of color attribute maps with metadata for each shape."
|
A vector of color attribute maps with metadata for each shape."
|
||||||
[shapes file-id libraries]
|
[shapes file-id libraries]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user