Skip to content

pantoken-root / platforms/wordpress/src / toThemeJson

Függvény: toThemeJson() ​

toThemeJson(tokens, options?): ThemeJson

Kísérleti

Konvertálja az IR-tokenlistát WordPress theme.json formátumra.

Paraméterek ​

tokens ​

csak olvasható Token[]

Az IR (pl. @pantoken/tokens-ből).

options? ​

ToThemeJsonOptions = {}

ToThemeJsonOptions.

Visszatérési érték ​

ThemeJson

Egy theme.json dokumentum.

Példák ​

Konvertálja az IR-t light-mode theme.json fájllá

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

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

Sötét mód

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

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