Skip to content

pantoken / platforms/wordpress/src / toThemeJson

ฟังก์ชัน: toThemeJson()

toThemeJson(tokens, options?): ThemeJson

ทดลอง

แปลงรายการโทเค็นของ IR ให้เป็น WordPress theme.json.

พารามิเตอร์

tokens

อ่านอย่างเดียว Token[]

IR (เช่น จาก @pantoken/tokens)

options?

ToThemeJsonOptions = {}

ToThemeJsonOptions.

คืนค่า

ThemeJson

เอกสาร theme.json

ตัวอย่าง

แปลง IR เป็น 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 }, …]

โหมดมืด

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

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