mirror of
https://github.com/penpot/penpot.git
synced 2026-05-24 09:23:40 +00:00
* 🎉 Add tokens to plugins API documentation And add poc plugin example * 📚 Document better the tokens value in plugins API * 🔧 Refactor token validation schemas * 🔧 Use automatic validation in token proxies * 🔧 Use schemas to validate token creation * 🔧 Use multi schema for token value * 🔧 Use schema in token api methods * 🐛 Fix review comments --------- Co-authored-by: Andrey Antukh <niwi@niwi.nz>
31 lines
1.1 KiB
Clojure
31 lines
1.1 KiB
Clojure
;; This Source Code Form is subject to the terms of the Mozilla Public
|
|
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
;;
|
|
;; Copyright (c) KALEIDOS INC
|
|
|
|
(ns frontend-tests.tokens.helpers.tokens
|
|
(:require
|
|
[app.common.files.tokens :as cfo]
|
|
[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-tokens-in-active-sets)
|
|
(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 (cfo/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])) |