0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-21 06:02:32 -05:00

Update opacity

This commit is contained in:
Florian Schroedl 2024-07-04 11:06:48 +02:00
parent b43d16008f
commit 322c8ef8ec
2 changed files with 26 additions and 2 deletions

View file

@ -156,8 +156,7 @@
(dwt/update-dimensions shape-ids :height value)))))
(defn update-opacity [value shape-ids]
(st/emit!
(dch/update-shapes shape-ids #(assoc % :opacity value))))
(dch/update-shapes shape-ids #(assoc % :opacity value)))
(defn update-stroke-width
[value shape-ids]

View file

@ -112,6 +112,31 @@
(t/is (= (:width rect-1') 100))
(t/is (= (:height rect-1') 100))))))))
(t/deftest test-apply-opacity
(t/testing "applies opacity token and updates the shapes opacity")
(t/async
done
(let [file (-> (setup-file)
(toht/add-token :token-target {:value "0.5"
:name "opacity.medium"
:type :opacity}))
store (ths/setup-store file)
rect-1 (cths/get-shape file :rect-1)
events [(wtc/apply-token {:shape-ids [(:id rect-1)]
:attributes #{:opacity}
:token (toht/get-token file :token-target)
:on-update-shape wtc/update-opacity})]]
(tohs/run-store-async
store done events
(fn [new-state]
(let [file' (ths/get-file-from-store new-state)
token-target' (toht/get-token file' :token-target)
rect-1' (cths/get-shape file' :rect-1)]
(t/is (some? (:applied-tokens rect-1')))
(t/is (= (:opacity (:applied-tokens rect-1')) (:id token-target')))
;; TODO Fix opacity shape update not working?
#_(t/is (= (:opacity rect-1') 0.5))))))))
(t/deftest test-toggle-token-none
(t/testing "should apply token to all selected items, where no item has the token applied"
(t/async