Skip to content

pantoken / packages/core/src / defineToken

Funkcja: defineToken()

defineToken(input): Token

Beta

Zbuduj w pełni ukształtowany Token na podstawie częściowego wejścia, używając domyślnie inherits i syntax.

Parametry

input

TokenInput

Zwraca

Token

Przykłady

Wykryj składnię na podstawie konkretnej wartości

ts
import { defineToken } from "@pantoken/core";

defineToken({ name: "--instui-color-x", value: "#0374B5" });
// → { name: "--instui-color-x", syntax: "<color>", inherits: true, value: "#0374B5" }

Pojedyncza wartość var() zapisuje refersTo; light-dark() ustawia themed

ts
import { defineToken } from "@pantoken/core";

defineToken({ name: "--instui-brand", value: "var(--instui-color-background-brand)" });
// → syntax "*", refersTo: "--instui-color-background-brand"

defineToken({ name: "--instui-bg", value: "light-dark(#fff, #000)" });
// → syntax "*", themed: true