Skip to content

pantoken-root / design/swatches/src / toSvg

ฟังก์ชัน: toSvg() ​

toSvg(swatches, options?): string

ทดลอง

เรนเดอร์สวอตช์เป็นแผ่นตัวอย่าง SVG แบบจัดกลุ่ม.

พารามิเตอร์ ​

swatches ​

อ่านอย่างเดียว Swatch[]

พาเลต (เช่น จาก toSwatches).

options? ​

ToSvgOptions = {}

ToSvgOptions.

คืนค่า ​

string

เอกสาร SVG เป็นสตริง.

ตัวอย่าง ​

สร้างแผ่นตัวอย่างสำหรับ README

ts
import { writeFileSync } from "node:fs";
import { swatches, toSvg } from "@pantoken/swatches";

writeFileSync("palette.svg", toSvg(swatches));

ตัวอย่างเฉพาะพาเลตหลัก พร้อมหัวข้อและกริดที่กว้างขึ้น

ts
import { swatches, toSvg } from "@pantoken/swatches";

const core = swatches.filter((s) => !s.name.startsWith("primitive-"));
const svg = toSvg(core, { title: "Instructure core colors", columns: 8 });