Skip to content

pantoken-root / platforms/vanilla/src / toVanillaVariables

関数: toVanillaVariables() ​

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

実験的

IRのトークン一覧をVanilla Foundationのvariables.jsonオブジェクトに変換します.

パラメーター ​

tokens ​

読み取り専用 Token[]

IR(例: @pantoken/tokens からのもの)。

options? ​

ToVanillaOptions = {}

ToVanillaOptions.

戻り値 ​

Record<string, unknown>

テーマのvariables.jsonアセットにPUTするネストされたvariablesオブジェクト。

例 ​

IRをネストされたvariablesオブジェクトに変換する

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

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

ダークモード

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

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