Skip to content

pantoken / platforms/wordpress/src / toThemeJson

Função: toThemeJson()

toThemeJson(tokens, options?): ThemeJson

Experimental

Converter uma lista de tokens IR em um theme.json do WordPress.

Parâmetros

tokens

somente leitura Token[]

O IR (por exemplo, de @pantoken/tokens).

options?

ToThemeJsonOptions = {}

ToThemeJsonOptions.

Retorna

ThemeJson

Um documento theme.json.

Exemplos

Converter um IR para um theme.json em modo claro

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

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

Modo escuro

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

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