mirror of
https://github.com/penpot/penpot.git
synced 2025-01-08 07:50:43 -05:00
Merge pull request #223 from tokens-studio/fic-spacing-crash-on-non-layout
Fix app crashing when spacing padding is applied to a shape without a…
This commit is contained in:
commit
dde8ab0680
1 changed files with 11 additions and 7 deletions
|
@ -138,19 +138,23 @@
|
||||||
:token-type-props updated-token-type-props
|
:token-type-props updated-token-type-props
|
||||||
:selected-shapes selected-shapes})))
|
:selected-shapes selected-shapes})))
|
||||||
|
|
||||||
(defn update-layout-spacing [value shape-ids attributes]
|
(defn update-layout-spacing [value selected-shapes attributes]
|
||||||
|
(doseq [shape selected-shapes]
|
||||||
|
(let [shape-id (:id shape)]
|
||||||
(if-let [layout-gap (cond
|
(if-let [layout-gap (cond
|
||||||
(:row-gap attributes) {:row-gap value}
|
(:row-gap attributes) {:row-gap value}
|
||||||
(:column-gap attributes) {:column-gap value})]
|
(:column-gap attributes) {:column-gap value})]
|
||||||
(st/emit! (dwsl/update-layout shape-ids {:layout-gap layout-gap}))
|
(st/emit! (dwsl/update-layout [shape-id] {:layout-gap layout-gap}))
|
||||||
(st/emit! (dwsl/update-layout shape-ids {:layout-padding (zipmap attributes (repeat value))}))))
|
(when (:layout shape)
|
||||||
|
(st/emit! (dwsl/update-layout [shape-id] {:layout-padding (zipmap attributes (repeat value))})))))))
|
||||||
|
|
||||||
|
|
||||||
(defn apply-spacing-token [{:keys [token-id token-type-props selected-shapes]} attributes]
|
(defn apply-spacing-token [{:keys [token-id token-type-props selected-shapes]} attributes]
|
||||||
(let [token (dt/get-token-data-from-token-id token-id)
|
(let [token (dt/get-token-data-from-token-id token-id)
|
||||||
attributes (set attributes)
|
attributes (set attributes)
|
||||||
updated-token-type-props (assoc token-type-props
|
updated-token-type-props (assoc token-type-props
|
||||||
:on-update-shape update-layout-spacing
|
:on-update-shape (fn [value shape-ids]
|
||||||
|
(update-layout-spacing value selected-shapes attributes))
|
||||||
:attributes attributes)]
|
:attributes attributes)]
|
||||||
(wtc/on-apply-token {:token token
|
(wtc/on-apply-token {:token token
|
||||||
:token-type-props updated-token-type-props
|
:token-type-props updated-token-type-props
|
||||||
|
|
Loading…
Reference in a new issue