0.0.3 • Published 6 years ago
heropatterns-helper v0.0.3
Heropatterns Helper
Node.js helper functions to convert heropatterns to JPEGs, PNGs, SVGs, and ZIPs
Getting Started
Installation
Install with NPM.
npm install heropatterns-helper sharpInstall with Yarn.
yarn add heropatterns-helper sharpPlease note that Sharp.js is a peer dependency for toJpeg, toPng, and toZip.
Setup and Usage
Import the library
const heropatterns = require('heropatterns-helper');
const {
toJpeg,
toPng,
toSvg,
toZip,
getMetadata,
FileType,
} = require('heropatterns-helper');Helper functions
// returns object { width, height, backgroundColor, foregroundColor, svg, }
getMetadata(cssString);// returns buffer with jpeg
toJpeg(heroPatternSvg);// returns buffer with png
toPng(heroPatternSvg);// returns buffer with svg
toSvg(heroPatternSvg);// The FileType as imported above
export const FileType = {
JPEG: 'JPEG',
PNG: 'PNG',
SVG: 'SVG',
ZIP: 'ZIP',
};
// if you have already created file buffers
// the zip function can reuse them
const files = {
[FileType.JPEG]: await toJpeg(heroPatternSvg),
};
// returns buffer with zip
toZip(heroPatternSvg, files, fileName, licenseText);License
Heropatterns Helper Code: MIT (see license.md)