Skip to content

pantoken-root / formats/css/src / buildCssFile

Funktion: buildCssFile() ​

buildCssFile(__namedParameters): string

Beta

Erstellt einen CSS-Datei-String: typisierte @property Registrierungen (Top-Level, themenunabhängig) gefolgt von einem oder mehreren bereichsgebundenen Deklarationsabschnitten (deren Selektor vom konsumierenden Build umgeschrieben werden kann).

Parameter ​

__namedParameters ​

comments ​

string[]

scope ​

string

properties? ​

PropertyRule[] = []

sections ​

CssSection[]

inherits? ​

boolean = true

Rückgabe ​

string

Beispiele ​

Registriere eine typisierte Eigenschaft und gib eine bereichsgebundene Deklaration aus

ts
import { buildCssFile } from "@pantoken/css";

buildCssFile({
  comments: ["/* my tokens */"],
  scope: ":root",
  properties: [{ name: "--instui-color-brand", syntax: "<color>", value: "#0374b5" }],
  sections: [{ pairs: [["--instui-color-text-base", "var(--instui-color-brand)"]] }],
});

Wickle einen Abschnitt in eine CSS-Cascade-Schicht ein

ts
import { buildCssFile } from "@pantoken/css";

buildCssFile({
  comments: [],
  scope: ":root",
  sections: [{ layer: "pantoken", pairs: [["--instui-spacing-space-md", "1rem"]] }],
});