Skip to content

pantoken-root / platforms/wordpress/src / toThemeJson

関数: toThemeJson() ​

toThemeJson(tokens, options?): ThemeJson

実験的

IR のトークンリストを WordPress theme.json に変換する。

パラメーター ​

tokens ​

読み取り専用 Token[]

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

options? ​

ToThemeJsonOptions = {}

ToThemeJsonOptions.

戻り値 ​

ThemeJson

theme.json のドキュメント。

例 ​

IR をライトモードの theme.json に変換する

ts
import { toThemeJson } from "@pantoken/wordpress";
import { byTheme } from "@pantoken/tokens";

const doc = toThemeJson(byTheme("rebrand"));
doc.settings.color.palette; // [{ slug, name, color }, …]

ダークモード

ts
import { toThemeJson } from "@pantoken/wordpress";
import { byTheme } from "@pantoken/tokens";

const doc = toThemeJson(byTheme("canvas"), { mode: "dark" });