mirror of
https://github.com/penpot/penpot.git
synced 2025-05-28 01:36:10 +02:00
25 lines
No EOL
853 B
Clojure
25 lines
No EOL
853 B
Clojure
(ns frontend-tests.tokens.helpers.tokens
|
|
(:require
|
|
[app.common.files.tokens :as cft]
|
|
[app.common.test-helpers.ids-map :as thi]
|
|
[app.common.types.tokens-lib :as ctob]))
|
|
|
|
(defn get-token [file name]
|
|
(some-> (get-in file [:data :tokens-lib])
|
|
(ctob/get-active-themes-set-tokens)
|
|
(get name)))
|
|
|
|
(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 (get-token file token-label)
|
|
applied-attributes (cft/attributes-map attributes token)]
|
|
(update-in file [:data
|
|
:pages-index first-page-id
|
|
:objects shape-id
|
|
:applied-tokens]
|
|
merge applied-attributes)))
|
|
|
|
(defn get-tokens-lib [file]
|
|
(get-in file [:data :tokens-lib])) |