Skip to content

pantoken / platforms/wordpress/src / toThemeJson

Funktion: toThemeJson()

toThemeJson(tokens, options?): ThemeJson

Experimentell

Wandelt eine IR-Tokenliste in ein WordPress theme.json um.

Parameter

tokens

readonly Token[]

Das IR (z. B. von @pantoken/tokens).

options?

ToThemeJsonOptions = {}

ToThemeJsonOptions.

Rückgabe

ThemeJson

Ein theme.json-Dokument.

Beispiele

Einen IR in eine Light-Mode theme.json konvertieren

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

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

Dunkelmodus

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

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