Skip to content

pantoken / platforms/wordpress/src / toThemeJson

Fonction: toThemeJson()

toThemeJson(tokens, options?): ThemeJson

Expérimental

Convertir une liste de tokens IR en un theme.json WordPress.

Paramètres

tokens

lecture seule Token[]

L'IR (p. ex. provenant de @pantoken/tokens).

options?

ToThemeJsonOptions = {}

ToThemeJsonOptions.

Renvoie

ThemeJson

Un document theme.json.

Exemples

Convertir un IR en un theme.json en mode clair

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

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

Mode sombre

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

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