Skip to content

pantoken-root / formats/css/src / buildCssFile

関数: buildCssFile() ​

buildCssFile(__namedParameters): string

ベータ

CSSファイルの文字列を構築する: 型付き @property 登録(トップレベル、テーマ非依存)の後に 1つ以上のスコープされた宣言セクション(そのセレクタは消費側のビルドで書き換えられる場合がある)を続ける。

パラメーター ​

__namedParameters ​

comments ​

string[]

scope ​

string

properties? ​

PropertyRule[] = []

sections ​

CssSection[]

inherits? ​

boolean = true

戻り値 ​

string

例 ​

型付きプロパティを1つ登録してスコープ付き宣言を出力する

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