Skip to content

pantoken / platforms/wordpress/src / toThemeJson

Funktion: toThemeJson()

toThemeJson(tokens, options?): ThemeJson

Eksperimentel

Konverter en IR-tokenliste til en WordPress theme.json.

Parametre

tokens

skrivbeskyttet Token[]

IR'en (f.eks. fra @pantoken/tokens).

options?

ToThemeJsonOptions = {}

ToThemeJsonOptions.

Returnerer

ThemeJson

Et theme.json dokument.

Eksempler

Konverter en IR til et light-mode theme.json

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

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

Mørk tilstand

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

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