Skip to content

pantoken / platforms/wordpress/src / toThemeJson

Funktion: toThemeJson()

toThemeJson(tokens, options?): ThemeJson

Experimentell

Konvertera en IR-tokenlista till en WordPress theme.json.

Parametrar

tokens

skrivskyddad Token[]

IR:n (t.ex. från @pantoken/tokens).

options?

ToThemeJsonOptions = {}

ToThemeJsonOptions.

Returnerar

ThemeJson

Ett theme.json-dokument.

Exempel

Konvertera en IR till en 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örkt läge

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

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