Skip to content

pantoken-root / platforms/wordpress/src / toThemeJson

Funksjon: toThemeJson() ​

toThemeJson(tokens, options?): ThemeJson

Eksperimentell

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

Parametere ​

tokens ​

skrivbeskyttet Token[]

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

options? ​

ToThemeJsonOptions = {}

ToThemeJsonOptions.

Returnerer ​

ThemeJson

Et theme.json-dokument.

Eksempler ​

Konverter en IR til en theme.json for lysmodus

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 modus

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

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