Skip to content

pantoken / formats/css/src / buildCssFile

函式: buildCssFile()

buildCssFile(__namedParameters): string

Beta(測試)

建立一個 CSS 檔案字串:typed @property 註冊(頂層、與主題無關),接著 一或多個作用域宣告區段(其選擇器可能會被使用該建置重新改寫)。

參數

__namedParameters

comments

string[]

scope

string

properties?

PropertyRule[] = []

sections

CssSection[]

inherits?

boolean = true

回傳

string

範例

註冊一個型別化屬性並輸出一個作用域宣告

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

將一個區段包裹在 CSS 的層疊層中

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

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