Skip to content

pantoken-root / platforms/wordpress/src / toThemeJson

Fungsi: toThemeJson() ​

toThemeJson(tokens, options?): ThemeJson

Eksperimental

Tukarkan senarai token IR kepada theme.json WordPress.

Parameter ​

tokens ​

hanya-baca Token[]

IR (contohnya daripada @pantoken/tokens).

options? ​

ToThemeJsonOptions = {}

ToThemeJsonOptions.

Mengembalikan ​

ThemeJson

Dokumen theme.json.

Contoh ​

Tukarkan IR ke theme.json mod terang

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

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

Mod gelap

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

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