0.0.15 • Published 3 months ago
figma-to-html v0.0.15
figma-to-html
Install
$ pnpm install figma-to-html
Usage
import { FigmaParser } from "figma-to-html";
const figmaParser = new FigmaParser({
clientId: "clientId",
clientSecret: "clientSecret",
redirectUri: "redirectUri",
});
//single:figma url
figmaParser
.parse(url, { onProgress: (progress) => {} })
.then((htmlText) => {
console.log(htmlText);
})
.catch((error) => {
console.log(error);
});
//batch:figma url array
figmaParser
.parseBatch(urls, { onProgress: (progress) => {} })
.then((htmlText) => {
console.log(htmlText);
})
.catch((error) => {
console.log(error);
});
//image
figmaParser
.parseToImage(url)
.then((imageUrl) => {
console.log(imageUrl);
})
.catch((error) => {
console.log(error);
});
Options
Option | Type | Default | Required | Description |
---|---|---|---|---|
clientId | string | - | ✅ | figma clientId |
clientSecret | string | - | ✅ | figma clientSecret |
redirectUri | string | location.origin + location.pathname | figma redirectUri | |
tpl | boolean | true | template | |
placeholderImage | string | - | placeholder image url | |
imageResolver | (url: string, type: ImageType) => Promise<string> | base64 image resolver | image resolver | |
onProgress | (progress: number) => void | - | progress callback |
LICENSE
MIT