mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 14:12:36 -05:00
Add helper to apply token to shape
This commit is contained in:
parent
581ced0ab8
commit
ab62c5b4ef
1 changed files with 13 additions and 1 deletions
|
@ -8,7 +8,8 @@
|
||||||
[cljs.test :as t :include-macros true]
|
[cljs.test :as t :include-macros true]
|
||||||
[frontend-tests.helpers.pages :as thp]
|
[frontend-tests.helpers.pages :as thp]
|
||||||
[frontend-tests.helpers.state :as ths]
|
[frontend-tests.helpers.state :as ths]
|
||||||
[token-tests.helpers.state :as tohs]))
|
[token-tests.helpers.state :as tohs]
|
||||||
|
[app.main.ui.workspace.tokens.token :as wtt]))
|
||||||
|
|
||||||
(t/use-fixtures :each
|
(t/use-fixtures :each
|
||||||
{:before thp/reset-idmap!})
|
{:before thp/reset-idmap!})
|
||||||
|
@ -36,6 +37,17 @@
|
||||||
{(:id radius-token) radius-token
|
{(:id radius-token) radius-token
|
||||||
(:id radius-ref-token) radius-ref-token})
|
(:id radius-ref-token) radius-ref-token})
|
||||||
|
|
||||||
|
(defn apply-token-to-shape [file shape-label token-label attributes]
|
||||||
|
(let [first-page-id (get-in file [:data :pages 0])
|
||||||
|
shape-id (thi/id shape-label)
|
||||||
|
token-id (thi/id token-label)
|
||||||
|
applied-attributes (wtt/attributes-map attributes token-id)]
|
||||||
|
(update-in file [:data
|
||||||
|
:pages-index first-page-id
|
||||||
|
:objects shape-id
|
||||||
|
:applied-tokens]
|
||||||
|
merge applied-attributes)))
|
||||||
|
|
||||||
(defn- setup-file
|
(defn- setup-file
|
||||||
[]
|
[]
|
||||||
(-> (cthf/sample-file :file-1 :page-label :page-1)
|
(-> (cthf/sample-file :file-1 :page-label :page-1)
|
||||||
|
|
Loading…
Add table
Reference in a new issue