Skip to content

pantoken-root / formats/css/src / buildCssFile

Hàm: buildCssFile() ​

buildCssFile(__namedParameters): string

Beta

Xây dựng một chuỗi tệp CSS: đăng ký được gõ @property (cấp cao nhất, không phụ thuộc chủ đề) tiếp theo là một hoặc nhiều phần khai báo có phạm vi (mà trình build tiêu thụ có thể viết lại bộ chọn của chúng).

Tham số ​

__namedParameters ​

comments ​

string[]

scope ​

string

properties? ​

PropertyRule[] = []

sections ​

CssSection[]

inherits? ​

boolean = true

Trả về ​

string

Các ví dụ ​

Đăng ký một thuộc tính được gõ và phát sinh một khai báo có phạm vi

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)"]] }],
});

Bao bọc một phần trong lớp xếp tầng (cascade) của CSS

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

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