mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 23:49:45 -05:00
🐛 Fix problem when setting shadows/blurs
This commit is contained in:
parent
f0427e454e
commit
0576884a8b
1 changed files with 27 additions and 5 deletions
|
@ -7,6 +7,7 @@
|
||||||
(ns app.plugins.shape
|
(ns app.plugins.shape
|
||||||
"RPC for plugins runtime."
|
"RPC for plugins runtime."
|
||||||
(:require
|
(:require
|
||||||
|
[app.common.colors :as clr]
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.files.helpers :as cfh]
|
[app.common.files.helpers :as cfh]
|
||||||
[app.common.record :as crc]
|
[app.common.record :as crc]
|
||||||
|
@ -14,6 +15,7 @@
|
||||||
[app.common.text :as txt]
|
[app.common.text :as txt]
|
||||||
[app.common.types.shape :as cts]
|
[app.common.types.shape :as cts]
|
||||||
[app.common.types.shape.layout :as ctl]
|
[app.common.types.shape.layout :as ctl]
|
||||||
|
[app.common.uuid :as uuid]
|
||||||
[app.main.data.workspace :as udw]
|
[app.main.data.workspace :as udw]
|
||||||
[app.main.data.workspace.changes :as dwc]
|
[app.main.data.workspace.changes :as dwc]
|
||||||
[app.main.data.workspace.selection :as dws]
|
[app.main.data.workspace.selection :as dws]
|
||||||
|
@ -196,15 +198,35 @@
|
||||||
:get #(-> % proxy->shape :shadow array-to-js)
|
:get #(-> % proxy->shape :shadow array-to-js)
|
||||||
:set (fn [self value]
|
:set (fn [self value]
|
||||||
(let [id (obj/get self "$id")
|
(let [id (obj/get self "$id")
|
||||||
value (mapv #(utils/from-js %) value)]
|
value (mapv (fn [val]
|
||||||
(st/emit! (dwc/update-shapes [id] #(assoc % :shadows value)))))}
|
;; Merge default shadow properties
|
||||||
|
(d/patch-object
|
||||||
|
{:id (uuid/next)
|
||||||
|
:style :drop-shadow
|
||||||
|
:color {:color clr/black :opacity 0.2}
|
||||||
|
:offset-x 4
|
||||||
|
:offset-y 4
|
||||||
|
:blur 4
|
||||||
|
:spread 0
|
||||||
|
:hidden false}
|
||||||
|
(utils/from-js val)))
|
||||||
|
value)]
|
||||||
|
(st/emit! (dwc/update-shapes [id] #(assoc % :shadow value)))))}
|
||||||
|
|
||||||
{:name "blur"
|
{:name "blur"
|
||||||
:get #(-> % proxy->shape :blur utils/to-js)
|
:get #(-> % proxy->shape :blur utils/to-js)
|
||||||
:set (fn [self value]
|
:set (fn [self value]
|
||||||
(let [id (obj/get self "$id")
|
(if (nil? value)
|
||||||
value (utils/from-js value)]
|
(st/emit! (dwc/update-shapes [id] #(dissoc % :blur)))
|
||||||
(st/emit! (dwc/update-shapes [id] #(assoc % :blur value)))))}
|
(let [id (obj/get self "$id")
|
||||||
|
value
|
||||||
|
(d/patch-object
|
||||||
|
{:id (uuid/next)
|
||||||
|
:type :layer-blur
|
||||||
|
:value 4
|
||||||
|
:hidden false}
|
||||||
|
(utils/from-js value))]
|
||||||
|
(st/emit! (dwc/update-shapes [id] #(assoc % :blur value))))))}
|
||||||
|
|
||||||
{:name "exports"
|
{:name "exports"
|
||||||
:get #(-> % proxy->shape :exports array-to-js)
|
:get #(-> % proxy->shape :exports array-to-js)
|
||||||
|
|
Loading…
Add table
Reference in a new issue