Skip to content

pantoken / design/swatches/src / toSwatches

Mahi: toSwatches()

toSwatches(tokens, mode?): Swatch[]

Whakamātautau

Whakaitihia te IR token ki te rārangi papatahi o ngā wāhanga tae: whakatau i ngā tohutoro, tīpakohia tētahi aratau, puritia anake ngā token e whai uara he tae hex (ka whakakorehia ngā tohu me ngā token kāore he tae).

Ngā Tawhā

tokens

panui-anake Token[]

Te IR (hei tauira, nō @pantoken/tokens).

mode?

Mode = "light"

Ko tēhea aratau tae hei whakatau (taunoa "light").

Whakahokia

Swatch[]

Te rārangi wāhanga tae, kua ingoa e te token (kāore te tūtohu --instui- i te tīmatanga).

Ngā tauira

Whakaitia te IR token ki ngā wāhanga tae aratau marama

ts
import { toSwatches } from "@pantoken/swatches";
import { tokens } from "@pantoken/tokens";

const swatches = toSwatches(tokens); // [{ name: "color-background-brand", hex: "#…" }, …]

Aratau pōuri

ts
import { toSwatches } from "@pantoken/swatches";
import { byTheme } from "@pantoken/tokens";

const swatches = toSwatches(byTheme("canvas"), "dark");