Skip to content

pantoken / platforms/wordpress/src / toThemeJson

Funksjon: toThemeJson()

toThemeJson(tokens, options?): ThemeJson

Eksperimentell

Konverter ei IR-tokenliste til ein WordPress theme.json.

Parametrar

tokens

skrivbeskytta Token[]

IR-en (til dømes frå @pantoken/tokens).

options?

ToThemeJsonOptions = {}

ToThemeJsonOptions.

Returnerer

ThemeJson

Eit theme.json-dokument.

Døme

Konverter ein IR til ei theme.json i 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" });