Skip to content

pantoken / platforms/wordpress/src / toThemeJson

Funció: toThemeJson()

toThemeJson(tokens, options?): ThemeJson

Experimental

Converteix una llista de tokens IR a theme.json de WordPress.

Paràmetres

tokens

només de lectura Token[]

La IR (p. ex. de @pantoken/tokens).

options?

ToThemeJsonOptions = {}

ToThemeJsonOptions.

Retorna

ThemeJson

Un document theme.json.

Exemples

Converteix un IR a un theme.json en mode clar

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

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

Mode fosc

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

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