Skip to content

pantoken / platforms/vanilla/src / toVanillaVariables

Hàm: toVanillaVariables()

toVanillaVariables(tokens, options?): Record<string, unknown>

Thử nghiệm

Chuyển một danh sách token IR thành một đối tượng variables.json của Vanilla Foundation.

Tham số

tokens

chỉ đọc Token[]

IR (ví dụ: từ @pantoken/tokens).

options?

ToVanillaOptions = {}

ToVanillaOptions.

Trả về

Record<string, unknown>

Đối tượng biến lồng nhau để PUT vào tài sản variables.json của chủ đề.

Các ví dụ

Chuyển IR thành đối tượng biến lồng nhau

ts
import { toVanillaVariables } from "@pantoken/vanilla";
import { byTheme } from "@pantoken/tokens";

const vars = toVanillaVariables(byTheme("rebrand"));
// { global: { mainColors: { primary: "#…" }, … }, titleBar: { … }, button: { … } }

Chế độ tối

ts
import { toVanillaVariables } from "@pantoken/vanilla";
import { byTheme } from "@pantoken/tokens";

const vars = toVanillaVariables(byTheme("canvas"), { mode: "dark" });