Skip to content

pantoken / platforms/wordpress/src / toThemeJson

Funzione: toThemeJson()

toThemeJson(tokens, options?): ThemeJson

Sperimentale

Convertire un elenco di token IR in un theme.json di WordPress.

Parametri

tokens

readonly Token[]

L'IR (es. da @pantoken/tokens).

options?

ToThemeJsonOptions = {}

ToThemeJsonOptions.

Restituisce

ThemeJson

Un documento theme.json.

Esempi

Convertire un IR in un theme.json in modalità chiara

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

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

Modalità scura

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

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