Skip to content

pantoken / platforms/wordpress/src / toThemeJson

Функція: toThemeJson()

toThemeJson(tokens, options?): ThemeJson

Експериментальний

Перетворити список токенів IR у WordPress theme.json.

Параметри

tokens

readonly Token[]

IR (наприклад, з @pantoken/tokens).

options?

ToThemeJsonOptions = {}

ToThemeJsonOptions.

Повертає

ThemeJson

Документ theme.json.

Приклади

Перетворити IR на light-mode 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" });